[QScintilla] Unable to add new keywords into already existing lexers.

Sarbojit Sarkar sarkar.iitr at gmail.com
Fri Feb 24 12:01:40 GMT 2012


Thanks Phil for your response.
So you are saying subclass should work. It was not working because of
missing space? I did that but still it is not working. I mean even after
doing the changes suggested by you cpp lexer is not considering these
strings as keywords.
Also I try to put a breakpoint to see if "keywords" function created by me
is getting called or not. It is not getting called. I have not clue who is
suppose to make the call and why it is not calling.

Please let me know if I am missing something here.





On Thu, Feb 23, 2012 at 12:11 PM, Phil Thompson <phil at riverbankcomputing.com
> wrote:

> On Wed, 22 Feb 2012 12:04:56 +0530, Sarbojit Sarkar
> <sarkar.iitr at gmail.com>
> wrote:
> > Hi,
> >   I have started playing with QScintilla few days back and I am quite
> happy
> > to see broad range of already existing lexers. Now I have a requirement
> > where I am planning to add few keywords into existing lexer. By googling
> it
> > seems that I have to create a subclass and need to redefine "const char*
> > keywords(int set) const" function. I did that but did not observer any
> > change. Here is my code,
> >
> > class myLex : public QsciLexerCPP
> > {
> > public:
> >     const char* keywords(int set) const;
> > };
> >
> > const char* myLex::keywords(int set) const
> > {
> >     if (set == 1)
> >         return
> >             "and and_eq asm auto bitand bitor bool break case "
> >             "catch char class compl const const_cast continue "
> >             "default delete do double dynamic_cast else enum "
> >             "explicit export extern false float for friend goto if "
> >             "inline int long mutable namespace new not not_eq "
> >             "operator or or_eq private protected public register "
> >             "reinterpret_cast return short signed sizeof static "
> >             "static_cast struct switch template this throw true "
> >             "try typedef typeid typename union unsigned using "
> >             "virtual void volatile wchar_t while xor xor_eq"
> >             "mov";* // my new keyword*
>
> You are missing a space - you've replaced "xor_eq" with "xor_eqmov".
>
> >     if (set == 3)
> >         return
> >             "a addindex addtogroup anchor arg attention author b "
> >             "brief bug c class code date def defgroup deprecated "
> >             "dontinclude e em endcode endhtmlonly endif "
> >             "endlatexonly endlink endverbatim enum example "
> >             "exception f$ f[ f] file fn hideinitializer "
> >             "htmlinclude htmlonly if image include ingroup "
> >             "internal invariant interface latexonly li line link "
> >             "mainpage name namespace nosubgrouping note overload "
> >             "p page par param post pre ref relates remarks return "
> >             "retval sa section see showinitializer since skip "
> >             "skipline struct subsection test throw todo typedef "
> >             "union until var verbatim verbinclude version warning "
> >             "weakgroup $ @ \\ & < > # { }";
> >
> >     if (set == 16)
> >         return "mdef mend"; *// my new keywords*
> >     return 0;
> > }
>
> The lexer only supports sets 1 to 4. I've updated the docs to reflect
> this.
>
> > Please let me know in case I have missed something.
> >
> > Also I wanted to play with existing colour scheme that lexer is
> following.
> > wondering if it is possible.
>
> Reimplement defaultPaper(), defaultColor() etc in your sub-class, or just
> call setPaper(), setColor().
>
> > Any help, link or suggestion will help a lot.
> >
> > thanks
>
> Phil
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/qscintilla/attachments/20120224/b31fa574/attachment.html>


More information about the QScintilla mailing list