2

I am trying to create a custom lexer based off of JavaScript for QScintilla. I have figured out how to add keywords the the lexer. However, I can not figure out how to alter the way they look when typed in like it does when you type the word function, for example.

Like here

I need to figure out how to do this with, for example, the word "fill".

Here's the code I currently have:

    QsciLexer *lexer=new QsciLexerJavaScript;
    QsciAPIs *api = new QsciAPIs(lexer);
    api->add("fill");
    api->prepare();
    ui->textEdit->setLexer(lexer);
crank123
  • 251
  • 1
  • 4
  • 17
  • There is not much documentation around about QScintilla. But this might help you: http://qscintilla.com/ – K.Mulier Jan 24 '17 at 21:51

1 Answers1

1

You need to subclass the QsciLexerCustom class. Then you need to make/configure several QsciStyle objects inside that class. The actual syntax highlighting is done in the styleText() function, which you need to override.

You can find detailed explanation on this website:

https://qscintilla.com/

More specifically on this page:

https://qscintilla.com/syntax-highlighting/

I hope it helps

K.Mulier
  • 8,069
  • 15
  • 79
  • 141
  • When I have the time to pick my project back up I'll try it out! Thank you very much! Looks to be exactly what I'm looking for! Thank you! – crank123 Jun 16 '17 at 03:55
  • 1
    You're welcome. My friend and I invested a lot of time in making that website when we noticed that not much documentation about QScintilla exist. – K.Mulier Jun 16 '17 at 16:42
  • 1
    @crank123 if this answer helped you, could you select it with the green checkmark? That would be awesome ;-) – K.Mulier Jun 16 '17 at 16:43