Without having read all the code, a few things:
1) Why not stick with the x/y notion? Wyt trying to map the caret into an offset of the entire text?
But anyway, if necessary: TSynMemo has code to do that (I really should move that to SynEdit, one day...).
SynMemo and SynEdit are identical, except for:
- SynMemo has the caret to offset and back
- SynMemo has a forwarder to Lines.Append or similar
- SynMemo has less published properties (they are there, but they are only public)
2)
Result:=Result+Edits[PageControl1.PageIndex].Edit.CaretX+3
That is wrong. Use "LogicalCaretX - 1"
CaretX is the screen pos (screen column) (also called Physical in source)
LogicalCaretX is the bytepos
For the he line 'A'#9'ü' with a tab width of 4. (note utf8 'ü' uses 2 bytes
Before a : | Log = 1 | Phys = 1 |
Between a and #9 : | Log = 2 | Phys = 2 |
Between #9 and ü : | Log = 3 | Phys = 5 |
After ü : | Log = 5 | Phys = 6 |
So if you are before 'a', then you do want to add 0, that is "LogicalCaretX - 1"
BlockBegin/End are always logical.
3) SynEdit has SearchReplaceEx: very powerful. If you do not specify the "replace flag", then it is a search.
Returns 0, if not found, 1 if found (on replace: number of replaced).
Found item will be selected.