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

gb.highlight could do with none.highlight


I've been making an editor that uses gb.highlight.

I just hit a bug (in my own coding) that before i started changing a lot of
code I thought of a simple workaround that worked.

The bug was this...

I had many lines of code similar to this...
If TextHighlightr[MyEditor.Highlight].CanReWrite Then

All was good untill i laded a document that did not use highlighting so the
editors Highlight property was either blank or "none"

So then i looked at the code and all the places i'd have to change to work
differently if there was no highlighter.  there were many places :(

But then i had an epiphany..
I added the following as TextHighlighter.class in my project....
' Gambas class file

Export
Create Static

Static Public Function _get(Optional Name As String = "none") As
TextHighlighter

  If Not name Then Name = "none"
    If Not TextHighlighter.List.Exist("none") Then
      If Not Exist("/tmp/none.highlight") Then
File.Save("/tmp/none.highlight", "")
      TextHighlighter.Register("none", "none", "/tmp/none.highlight")
    Endif
    Return Super[Name]

End


So it saves a blank file and loads it as none.highlight.
and if a call to the TextHighlighter[Name] array lacks a name or it is
"none" it no longer throws an error.

all my code is still working n the dummy none.highlight.

Benoit, do you think TextHighlighter.class could support a blank name or
"none" in the array call _get() ?

It would make using TextHighlighter.class with TextEditor.Highlght property
much easier.

Respects
BruceS

Follow-Ups:
Re: gb.highlight could do with none.highlightBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>