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

Re: Highlight.Analize and other things


On Fri, 13 Nov 2026 at 12:43, Bruce Steers <bsteers4@xxxxxxxxx> wrote:

>
>
> On Thu, 12 Nov 2026 at 17:16, Benoît Minisini <
> benoit.minisini@xxxxxxxxxxxxxxxx> wrote:
>
>> Le 10/11/2026 à 20:29, Bruce Steers a écrit :
>> > IS the Highlight.Analize method and things like TextEditor.GetHighlight
>> > geared to work with the new gb.highlight system?
>> >
>> > I wonder as all uses of it i see compare types to gb.eval Highlight
>> > constants like Higlight.String, Highlight.Comment, etc but the new
>> > system expands the types to include others. for example a bash shebang
>> > line. (of which the is no constant)
>> >
>> > Am I able to use Highlight.class on other highlighters other than
>> gambas?
>> > The wiki says it's for gambas code but it might just need updating
>> since
>> > gb.highlight changes.
>> >
>> > Or is there some other function from gb.highlight that mirrors gb.eval
>> > Highlight.class functions for other highlighters to analize code?
>> >
>> > Respects
>> > BruceS
>> >
>>
>> 'Highlight.Analyze()' is for parsing Gambas code, and it uses
>> 'Highlight' constants.
>>
>> The 'gb.highlight' component has a custom 'TextHighlighter_Gambas' class
>> that uses 'Highlight.Analyze()', and that transforms the 'Highlight'
>> constants into highlighter states.
>>
>> What's the problem with that?
>>
>> --
>> Benoît Minisini.
>
>
> No problem with that. But i was not wanting to do anything with gambas
> files or gambas highlight, that's already been taken care of by you..
>
> I'm using shell highlighting and wanted to use analyze and get a list of
> it's symbols/types/etc to examine and work on.
> I figured the Analyze function worked with each highlighter as each
> highlighter must analyze the code it highlights.
> So my thinking was all highlighting must be able to Analyze() itself.
> But using Analyze on sh code makes no sense of the Symbol Type values.
> they are all wrong if it's not gambas code.
>
> I'm asking if there is an Analyze() method that works with other file type
> highlights,  not an alternative way to analyze gambas files.
> I could no find Analyze() as part of TextHighlighter.class. All i see is
> the gambas only gb.eval Hghlight.Analyze()
>
> Respects
> BruceS
>


Well I think I have found the missing piece in this puzzle.

    TextHighlighterTheme.GetStateIndex(State)

I have added a _get() method to Highlight.class in my project like this...

' Gambas class file  Highlight.class
Export
Create Static

Static Public Function _get(State As String) As Integer

  Return TextHighlighterTheme.GetStateIndex(State)

End

So now i have 2 alternatives after using the TextEditor.GetHighlight()
method

If aTypes[0] = Highlight.Comment   ' for gambas code
If aTypes[0] = Highlight["Comment"]  ' for others

If aTypes[0] = Highlight["Shebang"]  ' now both 19 on my shell scripts. (i
was confused here as Highlight.Datatype constant is 19 so this was where
things were wrong for me)

It seems the _get method getting TextHighlighter constants cannot be used
with gambas files, they are incompatible.

As for example Highlight["Comment"] = 6 and Highlight.Comment = 9

I assume being a Static function
the TextHighlighterTheme.GetStateIndex(State) results ar generic and the
same for all the different highlighters?

Respects
BruceS

Follow-Ups:
Re: Highlight.Analize and other thingsBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
References:
Highlight.Analize and other thingsBruce Steers <bsteers4@xxxxxxxxx>
Re: Highlight.Analize and other thingsBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: Highlight.Analize and other thingsBruce Steers <bsteers4@xxxxxxxxx>