Only compiling gb.highlight with the new hightlight?

Post

Posted
Rating:
#1 (In Topic #1306)
Regular
sergioabreu is in the usergroup ‘Regular’
 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"
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
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?
Online now: No Back to the top

Post

Posted
Rating:
#3
Regular
sergioabreu is in the usergroup ‘Regular’
Found the syntax to load highlighter

Now texteditor do not accept the new key as highlight.

Code

  myTextEditor.highlight = "javascript" ' = ok
  myTextEditor.highlight = "php" ' or python, that I just loaded = error
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
sergioabreu is in the usergroup ‘Regular’
I Got to Load at least. I am doing also php highlight.
The syntax accepted is:

Code

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

myTextEditor.highlight = "php"  'that I loaded above

It throws an error saying can't load php highlighter.

Maybe I am missing some step.
Online now: No Back to the top

Post

Posted
Rating:
#5
Guru
BruceSteers is in the usergroup ‘Guru’
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.
Online now: No Back to the top

Post

Posted
Rating:
#6
Guru
BruceSteers is in the usergroup ‘Guru’
 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.
Online now: No Back to the top

Post

Posted
Rating:
#7
Regular
sergioabreu is in the usergroup ‘Regular’
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.

<COLOR color="#0000FF">Now everything is working fine</COLOR>.

PS: I have converted the code to use Theme as you suggested. Thanks  :)
Online now: No Back to the top

Post

Posted
Rating:
#8
Regular
sergioabreu is in the usergroup ‘Regular’
 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.
Online now: No Back to the top

Post

Posted
Rating:
#9
Guru
BruceSteers is in the usergroup ‘Guru’

sergioabreu said

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.

<COLOR color="#0000FF">Now everything is working fine</COLOR>.

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
Online now: No Back to the top

Post

Posted
Rating:
#10
Guru
BruceSteers is in the usergroup ‘Guru’

sergioabreu said

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.
Online now: No Back to the top

Post

Posted
Rating:
#11
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
 Generally, the way this is handled here for strings that are Symbols is to use Upper() on them. That way there is no conflict between "abacus","Abacus", "ABACUS" or even "aBaCus".
In other words Theme(Upper(<whatevercasethekeywordmaybe>)) will always resolve … as long as your theme uses uppercase keys.
hth
t'other B

Online now: No Back to the top

Post

Posted
Rating:
#12
Regular
sergioabreu is in the usergroup ‘Regular’
I was just philosophizing Bruce. I didn't ask anything, only "wondered if".
Because I have seen some keys insensitive in gambas:

Code

              key["t"] = 84
              key["T"] = 84

The above post shows how the developer team would do this.

I would do this inside some class (a private translation function):

Code

  Private Function getHighLighterThemeStyle( insens as String, theme as TextHighLighterTheme ) as TextHighLigherThemeStyle
        SELECT CASE Upper(insens)
            case "LABEL"
                return theme["Label"]
            case "ID"
                return theme["Id"]
            case "SYMBOL"
                return theme["Symbol"]
         END SELECT
  End
Relax
Online now: No Back to the top

Post

Posted
Rating:
#13
Guru
BruceSteers is in the usergroup ‘Guru’
Essentially you just need to capitalize whatever you use

String.UcaseFirst might be a better way

Code (gambas)

  1. Private Function getHighLighterThemeStyle( insens as String, theme as TextHighLighterTheme ) as TextHighLigherThemeStyle
  2.   Return theme[String.UCaseFirst(insens)]
  3.  

Ps use gb instead of code to insert gambas code into your posts as it formats it better :)

Code

[code numbers="1" param="gambas" scroll="1"]
' insert gambas code here
[/code]
Online now: No Back to the top
1 guest and 0 members have just viewed this.