I am afraid there is no single place....
For keyboard actions:
http://forum.lazarus-ide.org/index.php/topic,35592.msg243316For mouse actions (drag and drop edit / or whatever mouse actions you may have defined):
You need to dig into the code handling mouse actions.
For actions from menus, etc; Such as Paste (note that menu shortcuts, trigger the menu, not the keyboard): If they go through the CommandHandler => good, otherwise you need to handle in your code.
-------------------------------
Alternative you can write a subclass of TSynEditStringsLinked (need to subclass SynEdit to register it...)
And then hook all of (might be more in future versions)
procedure EditInsert(LogX, LogY: Integer; AText: String); virtual; abstract;
function EditDelete(LogX, LogY, ByteLen: Integer): String; virtual; abstract;
function EditReplace(LogX, LogY, ByteLen: Integer; AText: String): String; virtual; abstract;
procedure EditLineBreak(LogX, LogY: Integer); virtual; abstract;
procedure EditLineJoin(LogY: Integer; FillText: String = ''); virtual; abstract;
procedure EditLinesInsert(LogY, ACount: Integer; AText: String = ''); virtual; abstract;
procedure EditLinesDelete(LogY, ACount: Integer); virtual; abstract;
All editing goes through there. But that may include your programmatic edits (use a flag to indicate).
------------------------
As for storing info on per line base (read only flag).
See TSynEditStringTabData in TSynEditStringTabExpander
This gets auto adjusted if lines are inserted/removed. But you must take care of initializing new lines:
AddChangeHandler(senrLineCount, @LineCountChanged);
---
This will create one flag per line. A lot of data. If you need only 1 or 2 blocks, then store the begin/end of each block, and use the linecount changed hook to update the info.
---
If you use "shared" editors (clone window), you may need senrTextBufferChanged, since hooks are on the text buffer.
---------------------
Note:
All changes go into the undo system.
if you make changes in the protected lines, they must be part of the undo system. Or the undo system will fail.
And therefore if user actions are to be undone, so must be changes in your block.
---
Well to be precise (but that is implementation detail specific, and may break):
If you make changes that do not affect other x/y positions, then you could currently bypass the undo system (edit lines, without using EditReplace and co)
Background (again implementation specific, may change without warning).
Undo/Redo saves the absolute position(x/y) where a change was. If then another change adds/remove lines before (or chars on the same line, changing the x), then that other change must be undone first, or the undo will not work as expected.