[QScintilla] Trying to set different color for different set of keywords in QsciLexerCPP
Jonas O.
ezjonas at gmail.com
Sat Nov 6 19:44:27 GMT 2010
On Sat, Nov 6, 2010 at 19:04, Phil Thompson <phil at riverbankcomputing.com> wrote:
> On Sat, 6 Nov 2010 18:38:12 +0100, "Jonas O." <ezjonas at gmail.com> wrote:
>> Hello, and first thanks for bringing Scintilla to Qt ! I'm quite happy
>> to see all those nifty features made that much simple to implement
>> (current line highlight, margin numbers, select line form left click
>> in the margin, etc).
>>
>> However I'm having one little problem, I want to color some keyword
>> sets with a different than other keyword sets.
>> I created my own lexer by duplicating the QsciLexerCPP files, but I
>> need some starting point to see how I can do that; the SendScintilla
>> function is not very documented and does not forward to any scintilla
>> doc (I also read it's useless to ask here to learn how to create a
>> lexer, but I just want to color certain separately, not create my own
>> language).
>>
>> I hope someone could help me at least a little, I guess someone have
>> to know how to do it, the creator of QScintilla maybe ? The QScintilla
>> lexer classes did not appear magically...
>
> You don't need to create a new lexer - just subclass QsciLexerCPP and
> reimplement the keywords() method to handle the case where the keyword set
> is 2 (see QsciLexerCPP::KeywordSet2). You need to return a string for set 2
> containing the keywords you want coloured differently. If some of these
> appear in the default set 1 then you will also need to handle that set by
> returning a string that doesn't contain those keywords.
>
> You may also want to reimplement defaultColor(), defaultFont() etc. to
> provide different defaults for the KeywordSet2 style.
>
> Phil
>
I see, but I want to create several sets with each one having a
different color, the set 2 will only give me one color, how can it
select a different color for each set ?
More information about the QScintilla
mailing list