[QScintilla] Trying to set different color for different set of keywords in QsciLexerCPP

Jonas O. ezjonas at gmail.com
Mon Nov 8 22:24:16 GMT 2010


Any clue to what I should modify (I don't intend to keep to myself anyway...) ?

On Mon, Nov 8, 2010 at 23:14, Phil Thompson <phil at riverbankcomputing.com> wrote:
> On Mon, 8 Nov 2010 22:20:39 +0100, "Jonas O." <ezjonas at gmail.com> wrote:
>> I subclassed QsciLexerCPP with the QsciLexerCO class, I added the
>> required other functions and other stuff.
>
> Something that may be confusing you...
>
> The QsciLexer classes aren't lexers themselves - they manage the
> configuration of the underlying Scintilla lexers. You can't change the
> functionality of a lexer - like getting it to support more keyword sets.
> You can only configure a lexer - like redefining the contents of a keyword
> set.
>
>> Here is the enum:
>> enum
>> {
>>       BaseType = 20,
>>       Instruct = 21,
>>       Modifiers = 22,
>>       ClassRelated = 23,
>>       Oper = 24,
>>       Misc = 25
>> };
>
> The enum describes the different styles that the underlying Scintilla
> lexer implements. If you want to add more styles you have to modify the
> underlying lexer.
>
>> //Here is the keywords function:
>>
>> const char *QsciLexerCO :: keywords(int set) const
>> {
>>       switch (set)
>>       {
>>               case BaseType:
>>                       return
>>                       "bool char double enum float int long "
>>                       "short struct union void wchar_t";
>>
>>               case ClassRelated:
>>                       return
>>                       "class inline friend private protected public "
>>                       "template this virtual";
>>
>>               case Misc:
>>                       return
>>                       "asm namespace typedef using";
>>
>>               case Modifiers:
>>                       "auto const explicit extern mutable register "
>>                       "signed static unsigned volatile";
>>
>>               case Instruct:
>>                       return
>>                       "break case continue default do else "
>>                       "for goto if return switch while";
>>       }
>>
>>       return 0;
>>
>> }
>
> The Scintilla C++ lexer supports keyword sets 1, 2, 3 and 5. (Note that
> there is a bug in the documentation for QsciLexerCPP.GlobalClass which
> wrongly refers to set 4 rather than set 5.) These are rendered according to
> the styles Keyword, Keyword2, CommentDocKeyword and GlobalClass
> respectively.
>
> There isn't a lot you can do with the CommentDocKeyword because it is only
> recognised within comments. You can use the other three sets in any way you
> want. If you want more than three then you have to modify the underlying
> Scintilla lexer.
>
> Phil
>


More information about the QScintilla mailing list