On Tuesday, August 26, 2014 3:46:10 PM UTC-5, Edward K. Ream wrote:
> The PQSH class now controls Leo's syntax-coloring code *exactly* as QSH
did/does...
> No coloring actually happens yet, but...it may happen this evening.
> BTW, the code keeps getting simpler. It's almost embarrassing how little
QSH actually does.
Omg: Everything appears to work with these two dirt simple methods::
def setFormat(self,start,count,format):
'''Remember the requested formatting.'''
if start >= 0:
r = QtGui.QTextLayout.FormatRange()
r.start,r.length,r.format = start,count,format
self.formats.append(r)
def applyFormatChanges(self):
'''Apply self.formats to self._currentBlock.layout().'''
if self.formats:
layout = self._currentBlock.layout() # A QTextLayout.
layout.setAdditionalFormats(self.formats)
self.formats = []
cb = self._currentBlock
self._document.markContentsDirty(cb.position(),cb.length())
The contrast between the original C++ code and the code above is striking.
All the blah, blah, blah is gone!
To be fair, the original applyFormatChanges code messes with some fancy
additional layout features that I have completely ignored ;-) Only time
will tell if more complications are needed, but I suspect not.
Clearly, the code above adds no significant extra time to syntax coloring.
If you doubt this, consider all the work the Leo colorizer does before
calling setFormat!
We now appear to have a complete replacement for QSH, written entirely in
Python, and functionally just as fast as the original. Hurray!
The next step: PQSH.reformatBlocks will queue up smallish chunks for
coloring at idle time. This should allow Leo to respond to user events
with no noticeable delay.
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.