Help understanding QLexers
kristof.mulier at telenet.be
kristof.mulier at telenet.be
Sat Jan 23 11:54:35 GMT 2021
Hi Andrea,
Did you have a look at the QScintilla (unofficial) documentation page?
Here is the page about lexers:
https://qscintilla.com/#syntax_highlighting
And here about your specific question:
https://qscintilla.com/#syntax_highlighting/subclass_qscilexercustom/all_about_styles
Hope it helps.
Kind regards,
Kristof Mulier
PS: I wrote this website together with my friend Matic Kukovec. My friend Johan Cockx made the backend for this website.
----- Oorspronkelijk bericht -----
Van: "Andrea" <mariofutire at gmail.com>
Aan: "QScintilla" <qscintilla at riverbankcomputing.com>
Verzonden: Vrijdag 22 januari 2021 22:17:27
Onderwerp: Help understanding QLexers
Hi
I am trying to understand how to create a new QLexer for a new language.
Looking at all existing lexers they have an anonymous enum which links some integers 0, 1 to
symbolic names.
Example:
//! This enum defines the meanings of the different styles used by the
//! Lua lexer.
enum {
//! The default.
Default = 0,
//! A block comment.
Comment = 1,
//! A line comment.
LineComment = 2,
//! A number.
Number = 4,
The problem I have is that I cannot understand how the interface uses these private values to call
functions like
QColor QsciLexerLua::defaultColor(int style) const
{
switch (style)
{
case Default:
return QColor(0x00,0x00,0x00);
case Comment:
case LineComment:
return QColor(0x00,0x7f,0x00);
case Number:
return QColor(0x00,0x7f,0x7f);
How does the scidocument know that we have decided that a Number is 4?
Or that a Comment is 1?
Not all lexers share the same ids for the common values.
In other words, I can reassign the numbers in the enum and I do not see how the "caller" could be aware.
I was expecting that some of the interface functions returned these values, but I could not find any.
Cheers
More information about the QScintilla
mailing list