[Lazarus] SynEdit and gutter behaviour
lazarus at mfriebe.de
Thu Sep 15 00:02:04 CEST 2011
On 14/09/2011 22:27, Bart wrote:
> On 9/14/11, Martin<lazarus at mfriebe.de> wrote:
>> Since it is of course not desired to select text only to change it,
> I really do not understand what you mean by that.
> Changing selected text is one of the key features I'm using this app for.
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
>> there is
>> SynEdit.TextBetweenPoints[Point(1,200), Point(20,200)]
>> which can be set to
>> SynEdit.TextBetweenPoints[Point(1,200), Point(20,200)] := 'foo';
> The whole purpose of this excercise is the following.
> In the SynEdit I load a textfile (html in this case) with Lines.LoadfromFile().
> Now after loading I want to see if there is a line which contains a
> html meta-tag defining the charset, something like:
> <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
> In that line I want to change the ISO-8859-1 part into something else.
> So my strategy was to loop through the lines, see if any line has the
> meta-tag I seek, then change the line.
> That part I have in working order.
> At this stage in the process I do not know at what "Point" this text
> is (the caret certainly is not there, so I can't use that as a
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
> Also, considering when I do this (changing Lines), I do not mind
> that all prvious "undo" will stop working.
> So, now I see 2 options:
> 1: Calculate the two points defining the text I want to change and use
> TextBetweenPoints() or
> 2: Signal to the gutter that the given line has changed
> I really have no idea how to achieve any of those 2 options ATM.
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
you can create a plugin (sourceeditor afaik does, at least once did) =>
but the whole plugin stuff, is under design => don't trust anything that
you find by exploring the units
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
More information about the Lazarus