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

Fwd: Non consecutive line numbers with textEditor component


On Wed, 24 Jul 2024 at 19:51, Stéphane Aulery <lkppo@xxxxxxx> wrote:

> Le 24/07/2024 à 20:17, Bruce Steers a écrit :
> >
> >     This somewhat special area must offer three things:
> >
> >     - Line numbering (on/off)
> >     - A view of the matches with context (not always consecutive so the
> >     numbering is not either)
> >     - On double click, a file editor opens the file at the indicated line
> >     and column
> >
> >     An editor area seems more appropriate to me, but I don't know if the
> >     numbering can be non-consecutive or at least the non-interesting
> lines
> >     can be hidden or folded.
> >
> >     Is this feasible with a TextEditor component?
> >
> >     PS: Screenshots are here: http://saulery.free.fr/Gambas/
> >     <http://saulery.free.fr/Gambas/>
> >
> > Anything is possible.
> > I do not think the TextEditor will do this by default but you could do
> > the following (as i myself have done in a few projects) ......
> >
> > Copy the comp/src/gb.form.editor/.src folder into your own projects
> > folder (but not the "test" folder)
> > un-select gb.form.editor from your project properties components.
> >
> > Now you can examine/study/edit the TextEditor imported into your project
> > to your hearts content and make it do anything.
> > (Mine has a keystroke recorder plus many other additions)
> >
> > One of the best things I find about gambas is the ability to import
> > various components and edit them.
> >
> > It's brilliantly set up to enable people to add their own custom
> > features that not every one may want so stops the main program being
> > "bloated"
> >
> > If it does not do something (unusual) that you want it to it is often
> > fairly simple to customize your own components :)
>
> Very interesting. It seems more accessible to me than trying to create
> an HTML page.
>
> The double click should be simple but the lines for non-consecutive I
> have to be inventive.
>
> Can I rename the customize component to have both in the same rpoject?
>
> --
> Stéphane Aulery


Yes of course. It's not as easy as just modifying normally. There are the
following things to watch out for...
Inside TextEditor.class there will be references to the "TextEditor"
object, for example "Dim hEditor As TextEditor"
If you rename your imported TextEditor.class to MyTextEditor.class then you
must change all references to inside the class of TextEditor to MyTextEditor
There are a number of files in the TextEditor source folder
https://gitlab.com/gambas/gambas/-/tree/master/comp/src/gb.form.editor/.src
that you will have to rename and change the internal references or they
will conflict with the component files.

It's probably easier to add a property, an array or something, say
CustomLineNumbers as Integer[] to the normal TextEditor.class and if you
fill this array then the editor will use the custom numbering you have
created.  and if you do not fill the array it behaves as normal.

You can scan the TextEditor source to find where exactly the Line number
drawing occurs and modify this routine to work your own way (or use the
default way depending on your setting)

Probably here in the DrawMargin method:
https://gitlab.com/gambas/gambas/-/blob/master/comp/src/gb.form.editor/.src/TextEditor.class?ref_type=heads#L1793

Respects
BruceS

Follow-Ups:
Re: Fwd: Non consecutive line numbers with textEditor componentStéphane Aulery <lkppo@xxxxxxx>