[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gb.highlight could do with none.highlight
[Thread Prev] | [Thread Next]
- Subject: gb.highlight could do with none.highlight
- From: Bruce Steers <bsteers4@xxxxxxxxx>
- Date: Thu, 19 Nov 2026 17:13:35 +0000
- To: Gambas Mailing List <user@xxxxxxxxxxxxxxxxxxxxxx>
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
| Re: gb.highlight could do with none.highlight | Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx> |