[Gambas-user] Need help with TextEditor

Rolf-Werner Eilert rwe-sse at osnanet.de
Mon Sep 20 08:26:21 CEST 2021


Am 18.09.21 um 22:47 schrieb Bruce Steers:
> 
> 
> 
> On Sat, 18 Sept 2021 at 18:12, bb <adamnt42 at gmail.com 
> <mailto:adamnt42 at gmail.com>> wrote:
> 
>     On Sat, 2021-09-18 at 16:08 +0100, Bruce Steers wrote:
>      > On Fri, 17 Sept 2021 at 15:29, Rolf-Werner Eilert
>     <rwe-sse at osnanet.de <mailto:rwe-sse at osnanet.de>
>      > >
>      > wrote:
>      >
>      > > Am 16.09.21 um 19:09 schrieb Bruce Steers:
>      > > >
>      > > > On Thu, 16 Sept 2021 at 16:40, Rolf-Werner Eilert <
>      > > > rwe-sse at osnanet.de <mailto:rwe-sse at osnanet.de>
>      > > > <mailto:rwe-sse at osnanet.de <mailto:rwe-sse at osnanet.de>>> wrote:
>      > > >
>      > > >     Thank you for the links, Bruce. I browsed through several
>      > > > source
>      > > files,
>      > > >     and think I understood the principle.
>      > > >
>      > > >     What I miss is, how do I tell the highlighter which style is
>      > > > which
>      > > >     color?
>      > > >
>      > > >     In the HTML code for instance there is
>      > > >
>      > > >     Add(sQuote, Highlight.String)
>      > > >
>      > > >     But where is a definition for the color for Highlight.String?
>      > > > I
>      > > >     remember
>      > > >     in the old editor, I had to define colors for these.
>      > > >
>      > > >     If I get that to run, I guess I could do the rest by code. In
>      > > > my case
>      > > >     it's only two colors other than "Normal", one for "command"
>      > > > and one
>      > > for
>      > > >     "string".
>      > > >
>      > > >     Regards
>      > > >     Rolf
>      >
>      > No i'm afraid not.
>      > it's worse than that I think.
>      > You cannot currently create your own TextEditor highlighting routines
>      > without importing gb.form.editor and gb.eval.highlight into your
>      > project.
>      > (as far as i know,   i think this is what Ben meant by a parser
>      > generator)
>      >
>      > If you look at my ScriptEd project source here..
>      > https://gitlab.com/bsteers4/scripted/-/tree/old-gambas/.src
>     <https://gitlab.com/bsteers4/scripted/-/tree/old-gambas/.src>
>      >
>      > you can see 2 folders , TextEditor and gb.eval.highlight  , they are
>      > just
>      > copies of gb.form.editor and gb.eval.highlight.
>      > I imported the folders from gambas source then de-selected the
>      > components
>      > from my project properties as they were now built in.
>      > I added the TextHighlighter_Sh.class to gb.eval.highlight/ and the
>      > TextEditorMode_Sh.class to TextEditor/ (they started as copies of the
>      > C
>      > highligher) to that application before Sh highlighting was added to
>      > gambas.
>      >
>      > So i think currently this will be the only way t create your own
>      > independent highlighter/mode
>      >
>      > Though i could be mistaken and need correcting on this.
>      > Could someone (Ben) please confirm/deny if add-on highlighting can be
>      > done
>      > or is it the internal classes only that will highlight?
>      >
>      > All the best
>      > BruceS
>      > ----[ http://gambaswiki.org/wiki/doc/netiquette
>     <http://gambaswiki.org/wiki/doc/netiquette> ]----
> 
>     Have you tried overloading the relevant classes in your project?
>     I remember I did that once with Color.class to turn the constants into
>     properties so they were writable. (That class is not relevant for this
>     matter though. Also it is no longer relevant/required since Color was
>     enhanced a long while back.)
>     In this case, maybe adding a method is all that is required?
> 
>     b
> 
> 
> I tried various things but not really sure how to do it properly.
> I've hacked gb.eval.highlight in gambas to try to get it to load another 
> file with no success.
> I've made my projects own TextHighlighter.class to try to override the 
> methods, a bit clueless really.
> 
> 
> BruceS
> 
> 
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
> 
Never mind, Bruce ;) I still have the code from the old Editor component 
(qt4). This code seems to be pretty similar, so it will be easy to adapt 
it to the new TextEditor.

It is rather short as the only thing it's got to do is to make 
everything in {} blue and everything in [] green.

Thank you very much for your help!

Regards
Rolf


More information about the User mailing list