On Dec 6, 8:08 am, "Edward K. Ream" <[EMAIL PROTECTED]> wrote:
> The colorizer should work as soon as jeditColorizer.setTag calls > QSyntaxHighlighter.setFormat. We are close. > In particular, setTag is being called with the proper tags and index ranges. Well, the holes in QSyntaxHighlighter are starting to become quite an obstacle. Here is the docs for setFormat: QQQ QSyntaxHighlighter.setFormat (self, int start, int count, QTextCharFormat format) This function is applied to the syntax highlighter's current text block (i.e. the text that is passed to the highlightBlock() function). QQQ In other words, 'start' is a *line* offset, not a global offset into the entire text. This causes a major problem, because the pattern matchers all deal with global offsets. Another problem is that the state returned by previousBlockState is an int, not a general data structure. Here is the situation as I see it: 1. We could create a state dict that associates a state with an arbitrary data structure. To make this work, the "states" must in essence be a unique key. So the colorizer will assign new int keys when a line is first colorized, that is, when previousBlockState returns -1. These keys are *not* line numbers, they are simply "allocated" as needed. The state dict could contain info such as a) the offset of the beginning of the line and b) a good restart point for the pattern matcher methods. 2. The big problem happens when the user inserts one or more lines. The question is, what will previousBlockState return? If it returns -1 we *might* be justified in assuming there is no previous line, in which case we can deduce that the global offset is 0. All following changed lines *might* have previousBlockState != -1, because *we have just colorized* the previous lines. I'll have to experiment with this. If this is what happens there *might* be a way around the holes. I love this stuff :-) To repeat, the only way to make setFormat work properly is to have a *foolproof* way of associating global offsets with line offsets. If this isn't possible, I shall have to ask the Qt people for help. It would actually be quite easy for them to provide it: just pass the global offset of the start of the block as an arg to highlightBlock. 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 -~----------~----~----~----~------~----~------~--~---
