[Tkinter-discuss] Here's a tough one -- dynamic, multi-line XML syntax highlighting

Tim Jones tjmac at tolisgroup.com
Mon Mar 28 19:35:12 CEST 2005


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
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 1816 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tkinter-discuss/attachments/20050328/4fbc7539/attachment.bin


More information about the Tkinter-discuss mailing list