For my app, there is a lamentable hole in the QSyntaxHighlighter interface. My app has been able to work around this hole, but it would be *so* much better if the hole could be plugged.<br><br>The problem is that QSyntaxHighlighter.highlightBlock is passed only the string to be colored, *not* the offset of that string in the entire text.<br>
<br>True, in a purely state-driven approach, this offset is not needed, but Leo's colorizer is based on the jEdit pattern matchers, and the offset is absolutely crucial. Details omitted :-)<br><br>Rather than adding an offset arg to highlightBlock, it might be more convenient for you and your users to add a new getter, say, offsetOfHighlightedBlock, that would, when called from highlightBlock give the desired global offset. Whatever is easiest for you will be fine with me.<br>
<br>For example, I want to do the following in the overridden highlightBlock method::<br><br>def highlightBlock (self,s):<br><br> all_s = self.w.text() # self.w is a QTextEdit<br> i = self.offsetOfHighlightedBlock()<br>
assert s == all_s[i:i+len(s)]<br> ...<br><br>Thanks.<br><br>Edward<br>--------------------------------------------------------------------<br>Edward K. Ream email: <a href="mailto:edreamleo@gmail.com">edreamleo@gmail.com</a><br>
Leo: <a href="http://webpages.charter.net/edreamleo/front.html">http://webpages.charter.net/edreamleo/front.html</a><br>--------------------------------------------------------------------<br><br>