[Gambas-user] Highlight Editor - highlighting more than 1 line

Benoit Minisini gambas at ...1...
Fri Nov 7 12:49:46 CET 2008


On vendredi 7 novembre 2008, Rolf-Werner Eilert wrote:
> Hi folks,
>
> a long time ago, I mentioned this, but Benoit meant it was a matter of
> my code :-) Since I didn't have an opportunity to check it out, I just
> tried it again today.
>
> This is what I found out about the example with the web site HTML code:
> Highlight Editor will highlight more than one line if the text contains
> a comment embraced by <!-- --> but only if you set it to
> Highlight.Comment and nothing else.
>
>  From my point of view, it shouldn't matter which property of
> highlighting you use, it's just a choice of colors, right? So try this:
>
> Let the Highlight Editor run and look for the first comment line
>
> <!--<h3>And do it each time you download a new version !</h3>-->
>
> Just insert a Return somewhere within the comment. You'll see that it
> stays gray, as it should.
>
> Stop the program. In the source code, there is
>
>        SELECT CASE iState
>          CASE Highlight.Normal
>            IF sCar = "<" THEN
>              IF String.Mid$(sText, iInd, 4) = "<!--" THEN
>                iState = Highlight.Comment
>                iNextState = Highlight.Comment
>              ELSE
>
> Now, just change the two Hightlight.Comment to something else, e. g.
> Highlight.Breakpoint and let the program run again. As you will see, all
> comments now appear in red. Do as before, insert a Return somewhere in
> the comment.
>
> What comes out is, that it starts black ("Highlight.Normal") on the new
> line, then interprets the following commands as usual.
>
> I hope this makes it somewhat clearer what I meant then. In my case,
> there is an editor for the printing forms I've created for my programs.
> Its format is very much like HTML, but it reacts slighty different.
> There are commands in {} and strings within these commands in []. There
> can be a linebreak at any point within a command structure, so there are
> some longer definitions (for tables) which reach over several lines to
> make them easier to read.
>
> Adapting the Highlight Editor to my needs was easy, but at this point it
> fails: all new lines following within a {} start in black, and the
> hassle only ends with the closing bracket some lines below.
>
> For me this is only a small issue, but anyway it's somewhat annoying not
> to know why and what :-) So, is it a bug or a feature or am I just too
> stupid to see the way?
>
> Thanks for all comments.
>
> Rolf
>

I'm not sure if your highlighting algorithm is wrong or if you misunderstood 
the Highlight class.

What I can say is: 

The Highlight event highlights only one specific line. 

Once you have highlighted the line, you must set the Highlight.State property 
to the state of the beginning of the next line.

When you enter the highlight event, the Highlight state is set to the state of 
the first character of the line.

This way, you can start a token on a line, and ends it on another line, as the 
HTML highlighting routine does with "<!--" and "-->".

Regards,

-- 
Benoit Minisini




More information about the User mailing list