[Lazarus] SynEdit and gutter behaviour

Bart bartjunk64 at gmail.com
Thu Sep 15 15:54:53 CEST 2011

On 9/15/11, Martin <lazarus at mfriebe.de> wrote:

> If you wish to change text by code (from your app, rather than user
> input), then you do not necessarily want to have to select the
> to-be-changed-text first.

I understood you incorrectly then.
It is the user that selects text, then clicks a button (or uses a key
shortcut) to perform actions on the selected text.
E.g. you can select text, press Ctrl+B and voila, the text is
surrounded by <b> and </b> tags.
(As you might have guessed by now, the application is primarily a html
text editor.)

> Well you loop through the lines? So you got the line-INDEX ?
> The line number(for the point is one based, so add one.
> The X pos is byte based. You should know at which byte in the string
> (again 1-based) the desired text starts
> e.g line with index 3 (4t line on screen:
> Foo Bar Some
> Bar is Point(5, 4) to Point(8, 4)
> the "F" in Foo is Point(1, 4) to Point(2, 4)
> point is X,Y

OK, that makes sense to me.
I will give that a try.

>> 2: Signal to the gutter that the given line has changed
> For 2:
> You need your own subclass of synedit, to get the internal line object.
>    procedure TSynEditStringList.MarkModified(AFirst, ALast: Integer);
> But there is (and never will be) direct access to TSynEditStringList

This sounds like, although it is possible, it is designed in such a
way that you are not really supposed/encouraged to do it that way...
For now, I'll skip that option.

> It is possible though that the modified state of lines can in future be
> published. Either via the visble lines (would need a typecast, as they
> are tstrings. Or directly on synedit => as for directly on synedit, I
> don't like it, too many properties, it needs a bit of structure.
> Feel free to come up with ideas. as for how it could be solved, then we
> can discuss, what would be accepted as patch

I severely got lost in all the SynEdit (and related) source code.
I would have expected that the GutterPart that does the (visual)
marking would have a property to determine (or even set?) if a line
was modified.

As for SynEdit itself. Every time I found a method that looked like it
might trigger a change in "Line.Modified" status, I ended up (using
Ctlr-Click) at a virtual abstract method declaration...

Thanks for the help so far.


More information about the Lazarus mailing list