[Gambas-user] Editor Control Custom Highlighting

Benoit Minisini gambas at ...1...
Tue Aug 30 14:30:35 CEST 2005


On Sunday 28 August 2005 21:29, Alex Schaller wrote:
> Hello Benoit!
>
> Yes, I have looked into the Editor_Highlight event handler in the example
> but I'm afraid it is a bit above me.
> Is there any change we could get a simpler demo explaining how to setup
> keywords, datatypes etc.
>
> I for one would greatly appreciate it!!
>
> Thanks,
>
> Alex
>

I will add comments when I have time...

The principle are:

* The Highlight event handler is called for each line.

* Each line character must be assigned a state, that is an integer between 1 
and 15. This state has associated constants in the Highligh static class. The 
constant names match the requirement of Gambas code highlighting.

* When the event handler is called, Highlight.State is initialized with the 
last state of the previous line, or Highlight.Normal if there is no previous 
line.

* Then you can browse the line text returned by Highlight.Text character by 
character, and call Highlight.Add() to add into an internal buffer the state 
of the current character, one by one. You can add several identical following 
states in one call if needed.

* You must be careful with UTF-8: some characters need more than one byte. Use 
the String class if needed.

* When you have finished highlighting the line, you must return in 
Highlight.State the final state of the line, i.e. the state *after* the last
character.

Regards,

-- 
Benoit Minisini
mailto:gambas at ...1...




More information about the User mailing list