On 24/01/2021 18:03, Andrea wrote:
On 23/01/2021 11:54, [email protected] wrote:
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.
It helps to a degree.
I seem to understand that LexerCustom is very powerful and requires
subclasses to
1) define all the styles they need
2) apply them in styleText() when they are needed
and there is no leak of the definition of is a number or a comment
outside this class.
But it leaves open a few questions
1) why are the other lexers not inheriting form custom, what do they
do which is different?
2) all other lexers seems to offer much more usable interface based on
keywords (sets of keywords)
And in a lot of cases, this is all it is needed. Add a couple of
options to define what is a string (" vs '), what is a comment and
people do not need to think how to implement styleText().
So, I still think the interface is upside down.
Custom should have been the base class.
Then a keyword-based implementation (from which all existing lexers
derive from)
And if one needs a really special lexer, then she can derive and do
something completely different.
But I think I am very confused about how to read the documentation.
This is what I need to understand.
https://www.scintilla.org/ScintillaDoc.html#SCI_SETKEYWORDS
The QsciLexer classes are just wrappers around the configuration of the
corresponding Scintilla lexers. Those lexers are completely independent
and hardcode the meaning of the different values - hence the lack of
consistency.
Phil