[Lazarus] SynEdit.TextBetweenPoints (Martin?)

Bart bartjunk64 at gmail.com
Sun Aug 11 15:41:58 CEST 2019


Hi,

In my real app I don't have persistent blocks, so that should not be a problem.

> BlockBegin/BlockEnd are faster than SelStart/SelEnd.
> BlockBegin/End and SetTextBetweenPoints are comparable.

Speed is not of concern in my use case. The computer will always be
faster than any human typing in my editor ;-)
My old code uses SelStart etc (ported form a Delphi 3 app), but then I
could not get it to work properly if the selection spanned multiple
lines.
You then suggested I'lld use SetTextBetweenPoints.
This did not have that drawback.

> But SetTextBetweenPoints should be less work to use.
Apparently not for me <big grin>

IIRC then at some point in time I ran into problems (probably related
to new SetTextBetweenPoints API ???) with backwards blocks and empty
blocks.
Since my app is mostly private for me (I create all my htm pages with
it and use it instead of notepad whenever possible), I did not bother
too much.
However I seem to have a habit of selecting text from right to left,
so the bug triggered more often then not.
Once I was frustrated enough with it I investigated again and asked
for your help (again).
ATM I have it working, for which I thank you.
In my app, I solve the Lines.Count = 0 situation by simply adding an empty line.
This makes sense, in the way that the function will always insert text
in the editor, so linecount would have been altered in that case
anyway.

One more question:
The current solution creates 2 "redo" points.
I have to press ^Z 2 times to undo the process.
Is there a way to make it so that the whole process can be undone in
one step (by invoking the default undo-mechanism of TSynEdit)?

Again, thanks for your help.

Bart


More information about the lazarus mailing list