Only compiling gb.highlight with the new hightlight?

New to Gambas? Post your questions here. No question is too silly or too simple.
sergioabreu
Regular
Posts: 117
Joined: Tue Jul 09, 2024 9:27 am

Only compiling gb.highlight with the new hightlight?

Post by sergioabreu »

The only way I got to make a python.hightlight be loaded and work was downloading source code, isolating gb.highlight files, adding the new python.hightlight, recompiling, making the executable and puting it in usr/lib/gambas3

Am I missing some more user friendly way to do it? Because when I tried to add a hightlight folder in the project with the python.highlight, the file was not loaded automatically. If I called TextHighLighter.register("python", "python") with a hightlight folder in the project containg the file, it raised "Out of Memory"
Last edited by sergioabreu on Thu Aug 01, 2024 4:02 pm, edited 1 time in total.
User avatar
BruceSteers
Legend
Posts: 2159
Joined: Thu Jul 23, 2020 5:20 pm
Location: Isle of Wight

Re: Only compiling gb.highlight with the new hightlight?

Post by BruceSteers »

wiki shows this....
Static Sub Register ( Key As String [ , Name As String, Path As String ] )

does it work if you use the path part to your custom definition file in your highlight folder?
sergioabreu
Regular
Posts: 117
Joined: Tue Jul 09, 2024 9:27 am

Re: Only compiling gb.highlight with the new hightlight?

Post by sergioabreu »

Found the syntax to load highlighter

Now texteditor do not accept the new key as highlight.

Code: Select all

  myTextEditor.highlight = "javascript" ' = ok
  myTextEditor.highlight = "php" ' or python, that I just loaded = error
Last edited by sergioabreu on Thu Aug 01, 2024 6:00 pm, edited 2 times in total.
sergioabreu
Regular
Posts: 117
Joined: Tue Jul 09, 2024 9:27 am

Re: Only compiling gb.highlight with the new hightlight?

Post by sergioabreu »

I Got to Load at least. I am doing also php highlight.
The syntax accepted is:

Code: Select all

TextHighlighter.Register("php", "php", "highlight/php.highlight")
I dumped the TextHighLighter.List and php and python are there.
python that was compiled in gh.highlight, and works.
php that is loaded from project, enters to the TextHighLighter List, but when I try to attribute php to TextEditor.HighLight it it invokes CreateCustomHighLighter and get a file not found.

So, when I use in the code:

Code: Select all

myTextEditor.highlight = "php"  'that I loaded above
It throws an error saying can't load php highlighter.

Maybe I am missing some step.
User avatar
BruceSteers
Legend
Posts: 2159
Joined: Thu Jul 23, 2020 5:20 pm
Location: Isle of Wight

Re: Only compiling gb.highlight with the new hightlight?

Post by BruceSteers »

My guess is the highlight file you are using is an incomplete modified copy of another one.

some lines may contain @include statements that are for using other files the highlighter needs.

If i copy the sh.highlight file into my project and try to load it i get a "file not found" error.

It is because i lack the _number.regexp file.

I can either remove the 1st line from the highlighter if i'm not going to use it
@include _number.regexp

Or I can also add the _number.regexp file to my highlight folder.

if you have just copied the javascript.highlight file and none of it's "include" files then that's probably your problem.
User avatar
BruceSteers
Legend
Posts: 2159
Joined: Thu Jul 23, 2020 5:20 pm
Location: Isle of Wight

Re: Only compiling gb.highlight with the new hightlight?

Post by BruceSteers »

I looked at the source and realised the path is not needed, as you say it should be handled.

It automatically tries looking for a highlight/KeyName.highlight file so just giving a php key name for the highlight/php.highlight file should work.

TextHighlighter.Register("php") should load a php.highlight file in a highlight folder.

So a "cannot load file" error is from within the highlight file itself.

That's probably a bug Benoit may fix. Or give a better error message.
sergioabreu
Regular
Posts: 117
Joined: Tue Jul 09, 2024 9:27 am

Re: Only compiling gb.highlight with the new hightlight?

Post by sergioabreu »

The error was that apart from highlight folder and the correct path informed, it requires a custom folder to work too.

Custom folder with:
* CustomHighlighter.class
* .project template

These files are needed to compile the "on the fly" new class.

Now everything is working fine.

PS: I have converted the code to use Theme as you suggested. Thanks :)
sergioabreu
Regular
Posts: 117
Joined: Tue Jul 09, 2024 9:27 am

Re: The Keys of Theme could be case insensitive?

Post by sergioabreu »

If the key for Theme were case insensitive would cause some problem ?

I informed "symbol" as a Key and it raised me an Error of null object.

It would be nice if Theme["Symbol"] and Theme["symbol"] both worked.
User avatar
BruceSteers
Legend
Posts: 2159
Joined: Thu Jul 23, 2020 5:20 pm
Location: Isle of Wight

Re: Only compiling gb.highlight with the new hightlight?

Post by BruceSteers »

sergioabreu wrote: Fri Aug 02, 2024 1:45 am The error was that apart from highlight folder and the correct path informed, it requires a custom folder to work too.

Custom folder with:
* CustomHighlighter.class
* .project template

These files are needed to compile the "on the fly" new class.

Now everything is working fine.

PS: I have converted the code to use Theme as you suggested. Thanks :)
That's odd, I just made a highlight folder and put the sh.highlight file in there (I renamed to shh) everything worked as expected.
glad you found a way though
User avatar
BruceSteers
Legend
Posts: 2159
Joined: Thu Jul 23, 2020 5:20 pm
Location: Isle of Wight

Re: The Keys of Theme could be case insensitive?

Post by BruceSteers »

sergioabreu wrote: Fri Aug 02, 2024 2:05 am If the key for Theme were case insensitive would cause some problem ?

I informed "symbol" as a Key and it raised me an Error of null object.

It would be nice if Theme["Symbol"] and Theme["symbol"] both worked.
Generally Key names are case sensitive. changing the way gambas works could possibly break peoples existing software,
you must accept how it is. Don't be lazy and inaccurate with your code.

Not many like ideas of changing how gambas works as it could break existing software, so we use it as it is, If we want something different we can do it ourselves in our own software but the main gambas stays how it's designed, the only code breaking changes that ever happen are bug fixes.

If that's what you are asking for, you want something to work different for you in gambas. or you just moaning about your "bad case scenario", as it were.

We are here to help you learn some gambas,
We are not gambas developers. for that you want the gambas developers mailing list not this help forum.
Post Reply