Actually, I seem to have hit on a solution. It seems that the two instances of multi-line highlighting that I mentioned (comments and CDATA) are the ONLY two instances there are. And in each of these two cases, there are five subcases: when the user inserts/removes a new start-delimeter, inserts/removes a new end-delimeter, or makes some change between 2 delimeters (changing a delimeter to make it invalid counts as "removing" it). With this in mind, I was able to manually test for these cases and change the highlighting myself, without having to go back to expat and re-parse the file. For all OTHER cases, I use expat to just re-parse that one line. So far, it seems to be working perfectly, and it's certainly much more efficient than before!

Thanks anyway for the suggestions :-)

Tim Jones wrote:
On Mar 28, 2005, at 10:21 AM, Jared Cohen wrote:

Not a bad idea, but real syntax highlighting doesn't work that way. If I'm programming C++ and I type the word "int", the word gets highlighted as a keyword the instant I type the "t", not when there's a pause in my typing. If that were the case, then I could type an entire paragraph and the highlighting wouldn't change until I was done.

Thanks anyway though. Any other ideas? :-)

How about a maintained list of keywords as part of your syntax dictionary that effect from the current insertion point forward (<!-- for example) and keywords that effect the entire document (--> for example)? This way you're not always parsing the entire text on an insertion. And, you might consider only updating the text that is visible at the moment of updating.

As another thought, how about auto-completion of the block for the user: i.e.: They type '<!--' and you automatically insert the closing '-->' on the next line or on a new line at the end of a selected section.

I can't think of anything else at the moment. Have you also considered examining what is done in VIM's syntax highlighting?

Tim
--
Tim Jones tjmac [at] tolisgroup [dot] com


Tim Jones wrote:
On Mar 28, 2005, at 10:10 AM, Jared Cohen wrote:

<snip>

 When that happens with every single keystroke, it adds up to a whole lot of highlighting. There's got to be a better way, but I can't think of one. Can anyone help?


How about using a timer to monitor the delay between keystrokes?  This way, you only update the highlight if the user pauses in their typing rather than after each keyup.

Tim
--
Tim Jones                                                 tjmac [at] tolisgroup [dot] com



_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to