beaver-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Beaver-devel] Syntax Highlighting


From: Michael Terry
Subject: Re: [Beaver-devel] Syntax Highlighting
Date: Fri, 21 Mar 2003 13:00:03 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030319

Leslie Polzer wrote:
Hello Michael,

can you please explain the actions you take to refresh syhi on a change
to me?

Ok.  So, let's take an insert.  Deletions are not very different.

First, I find the two boundary GtkTextIter's. Then, I 'expand' them to push them out to whatever is interesting. For example, if the text is going from "ifthen" to "if hello then", i want to be able to catch the if and the then. So, I have a record of every ascii character's keyword status -- whether it appears in a keyword, whether it starts a keyword, or whether it ends a keyword. I go backward from start iter to find first character that isn't in a keyword or the first delimiter. The same for end iter, except I always go at least one forward, I think.

Then, I run the syhi engine on the text between the expanded iters. First, this removes any highlighting on the section. Then, it basically examines each character in turn and deletes any syhi GtkTextMarks it finds. If the character starts a 'special string' like a string or char marker, a line comment starter, or a block comment start or end, it creates a GtkTextMark and adds it to a list for the buffer. If it finds a keyword, it colors it.

At the end, if it deleted or created any GtkTextMark's, it will refresh the 'special string' colors. So, it will run through our list of GtkTextMark's and color each apropriately. i.e., if it sees a Mark that represents a block comment start, it will continue scanning through the list for a block comment end and when it sees one, will stop and color all intermediate text.

That's the basic idea.  Want any more info?

-mt

Attachment: pgpDjaPyRLSw6.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]