[QScintilla] QScintilla 2.8.4: custom lexer and QsciLexerCustom::styleText() in particular

Alan Garny agarny at hellix.com
Sat Jan 17 10:51:49 GMT 2015


Hi,

 

I am using QScintilla 2.8.4 in my project, together with my own custom
lexer. I do this by reimplementing QsciLexerCustom and
QsciLexerCustom::styleText() in particular. Now, this is all working fine,
except when scrolling down a big file, in which case calls to styleText()
become increasingly slower. Say that I open a big file and that I am at the
'top' of the file, then there will be a call to styleText() to style the
part of the file that is visible in the QScintilla editor. So far so good.
Now, say that I scroll down the file by pressing the down key, with the view
of reaching the end of the file. As expected, this will result in successive
calls to styleText(). However, what I didn't expect is that the 'start'
value (passed to styleText()) remains constant (in my quick tests, on
Windows, it remains equal to 0 while it goes from 0 to 64 on OS X). The
'end' value, however, does increase as you would expect, which means that
the further down the file you get, the longer the amount of text styleText()
wants you to style. So, could it be that there is an issue with QScintilla
somewhere? For now, to avoid this big slow down, I am overriding the 'start'
value as follows: 

 

    start = qMax(start,
editor()->positionFromLineIndex(editor()->SendScintilla(QsciScintilla::SCI_G
ETFIRSTVISIBLELINE), 0));

 

I wish I didn't have to do this, but at least it does speed up the styling
quite a bit.

 

Otherwise, on a somewhat related note, I noticed that, more often than not,
styleText() gets called when there seems to be no need for it to be called.
For example, if I open a file (no matter the size) and don't move the caret
or anything, then styleText() will get continuously called with the same
'start' value and an 'end' value that takes one of two values.

 

Cheers, Alan.

 

PS: just in case, my current lexer code can be found at
https://github.com/opencor/opencor/blob/master/src/plugins/editing/PrettyCel
lMLView/src/prettycellmlviewlexer.cpp.

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/qscintilla/attachments/20150117/ec602e0b/attachment.html>


More information about the QScintilla mailing list