On Dec 6, 8:08 am, "Edward K. Ream" <[EMAIL PROTECTED]> wrote:

> In essence, one can think of the highlightBlock method as *suggesting*
> that a range of text be colored.  But there is no requirement that
> this suggestion be followed!!!  Therefore, subclasses of
> QSyntaxHighlighter are free to highlight any range of text whenever
> they like.

Some simple tracing shows that QSyntaxHighlighter properly short-
circuits syntax coloring when keys are being typed quickly.  This is
probably the only essential optimization.

However, I should note that the scheme mentioned above implies, at
least in its naive version, that *all* text will be re-colorized
whenever any change is made.  In contrast, a line-oriented scheme
might colorize only changed lines, and indeed highlightBlock appears
to be called only on those changed lines.

Presumably, QSyntaxHighlighter remembers the (optional) state info for
the start of those lines, and the (overridden) code that is charged
with coloring each line can get that state info.

It may be possible to re-imagine what the state info means to get
these benefits.  The first thought is to set the state of a line to
the starting location of the last previous pattern match.  Alas,
highlightBlock only reports the string (line) to be colorized, *not*
the offset of the line in the entire string.  This is a major,
needless, hole in the api.  If the offset were given, it would be easy
to for the pattern-matching code to colorizer only the changed lines
reported by highlightBlock.

I suspect the Qt people will be willing to fill this hole.  It should
be easy to do, and it would open the door to non-line-oriented
coloring schemes.

In the meantime, it appears that we can be content with recoloring
everything whenever anything changes.  To repeat, QSyntaxHighlighter
does enough short-circuiting to make the extra work not too odious.

Edward
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to