[QScintilla] QScintilla suggestion to add dynamically to add keywords support

Phil Thompson phil at riverbankcomputing.com
Fri May 2 13:57:49 BST 2014


On 01/05/2014 11:15 pm, Jeremi Roivas wrote:
> Hello since I have looked the lexers it seams QScintilla api don't
> support at the moment dynamic keyword handling.
> 
>  It seams that Lexer->readKeywords(int set) is there put some
> funtionality to use dynamic keywordlists are missing.
> 
>  My suggestion to add functionality to QsciScintilla.h:
> 
>  void loadKeywords(int set, Qstring * keywords);
> 
>  QList returnKeywordTypes();
> 
>  for making array to handle sql databse saving and so on.
> 
>  This could add the dynamic keywords updating possible.

It's already possible. Sub-class your lexer and do something like...

const char *MyLexer::keywords(int set) const
{
     if (set == dynamic_set)
         return dynamic_keywords;

     return QsciLexerAVS::keywords(set);
}

void MyLexer::loadKeywords(int set, const char *keywords)
{
     dynamic_set = set;
     dynamic_keywords = keywords;

     if (editor())
         editor()->setLexer(this);
}

Phil


More information about the QScintilla mailing list