[Gambas-user] Highlight editor - Highlight help

Benoit Minisini gambas at ...1...
Thu Mar 6 20:01:36 CET 2008


On lundi 3 mars 2008, MaxVK wrote:
> Hi there, Iv been struggling with this for a while now. I am using the HTML
> highlighting code that comes in the documentation and the example and I
> want to include some more code that will highlight CSS as well as HTML.
>
> Can anyone point me in the right direction with some code to look through
> or some direct explanation about how the highlighting actually works?
> Please don't suggest reading the example code because Iv been doing that
> for two days now and I'm still none the wiser about how to get this
> working.
>
> I'm also looking to try and check spelling as I type. I can get the last
> word typed so I can spell check it, but I need to be able to highlight the
> word in some way (Presumably as an error), and I'm assuming that this will
> need to be done in the highlight event, although again, Iv failed miserably
> when Iv tried to get it working.
>
> Can anyone help please?
>
> Cheers
>
> Max

Each time a line must be highlighted, the Editor raises the Highlight event.

Then, in the Highlight event handler, you must tell the Editor the highlight 
state of each UTF-8 character of the line that must be highlighted.

All that is done by using the static methods, properties and constants of the 
Highlight class.

The text of the line is stored in Higlight.Text.

The state of one character is represented by one of the Highlight constants: 
Comment, DataType, Function, Keyword, and so on. Look in the Highlight.Add 
documentation for the list of all possible states.

The state of each character is defined by successive calls to the 
Highlight.Add() method. The first call defines the state of the first 
character, the second call the state of the second character, and so on...

The state of the analyze at the beginning of the line is stored in the 
Highlight.State and, optionally, the Highlight.Tag properties. These two 
properties are two integers.

After the last call to Highlight.Add(), i.e. when you have finished analyzing 
the current line, you must set Highlight.State and, optionally, Highlight.Tag 
to the state of the analyze at the end of the line.

There is another property, Highlight.ShowLimit. Use it to tell the Editor that 
the current line is the first line of a method, and that it should draw a 
separator (if the corresponding Editor option is set of course).

Is it clearer now?

-- 
Benoit Minisini




More information about the User mailing list