This project is read-only.

More than 32 Styles for a specific lexer?

Oct 16, 2013 at 8:54 PM

I would like to extend an existing lexer i a way that it supports more than the (default) 32 different styles. I currently use the Lua Lexer which supports 9 Styles for custom keywords (WORD, WORD2, ..., WORD8).

I read in the Documentation that I can extend the amount of Styles by using SCI_SETSTYLEBITS and setting the stylbits to a higher value than the default 5.

I did so, but how can I now add new keywords? There is still only WORD to WORD8, so how can I add WORD9, WORD10 and so on?

Oct 16, 2013 at 9:03 PM
The style bits actually have no effect with the current version of Scintilla, it's always 8 bits for style info. To add more sets of keywords though, you'll have to write your own lexer.
Oct 16, 2013 at 9:14 PM
Edited Oct 17, 2013 at 5:00 PM

yes I noticed that I can add in the lexer a new WORD, but the problem is that I can only add one, not more. I would really like to use the native Lua Lexer as it does exactly what I need apart from the fact that I need a few more styles.

In the Lua Lexer source code there is for example the statement:
WordList &keywords = *keywordlists[0];
WordList &keywords2 = *keywordlists[1];
WordList &keywords3 = *keywordlists[2];
WordList &keywords4 = *keywordlists[3];
WordList &keywords5 = *keywordlists[4];
WordList &keywords6 = *keywordlists[5];
WordList &keywords7 = *keywordlists[6];
WordList &keywords8 = *keywordlists[7];
If I now add a new keyword entry like:
WordList &keywords9 = *keywordlists[8];
and make the corresponding changes in the code, it does work and I get one new style. The strange thing is, that if I add more than one new style with this method it doesn't work and the styling doesn't even work at all (for all keywords).

Could you please tell me how I could extend the Lua Lexer to have more styles/what am I doing wrong?


Ok, nevermind. I found out that you have to increase the constant KEYWORDSET_MAX which is used in LexerBase.h. After that its possible to extend the number of styles in the lexer.