Teodor Petrov:
> I want to somehow change the style of the source code. I think the least
> confusing for our users is if we treat these lines as comments
> (SCE_ASM_COMMENT). The information whether a line is asm or source
> code is stored outside of scintilla, in an array.
>
> Is it possible to call a lexer with a custom start:end positions from a
> SCN_STYLENEEDED event?
Lexers may treat the start and end positions as suggestions as they may want to move the start back to the beginning of some feature. You could examine the assembler lexers to see if they do anything like this.
It sounds like this is a read-only view so the C/C++ lines could have a comment indicator character (‘;’ or ‘#’) added. An alternative would be to add an invisible character (like ZWSP) and treat that as a comment in the assembler lexer.
For higher quality styling, the lexing of the C/C++ and assembler could be separated by using 3 documents - one containing the C/C++, another containing the assembler, and another with the combined text. The C/C++ and assembler documents are styled in hidden Scintilla instances (either one for each document or a single instance with documents selected into it for lexing). The combined document has its styles set by merging the styles from the language-specific documents. The merger would have to assign separate style number ranges to the 2 languages.
Neil