|
|
(5 intermediate revisions by 2 users not shown) |
Line 1: |
Line 1: |
− | = Repl = | + | = Y caret = |
| | | |
− | var p1,p2: TPoint;
| + | Both are 1-based. Currently Y coordinates are always the same. This may change in future. |
− | begin
| |
− | p1 := SynEdit.LogicalCaretXY; | |
− | p2 := SynEdit.LogicalCaretXY;
| |
− | p2.x := p2.x + UTF8CharacterLength(@SynEdit.LineText[p2.x]); // byte len of char AFTER current caret
| |
− | SynEdit.TextBetweenPoints[p1,p2] := '';
| |
| | | |
− | Bad example. What it must do? replace One char with empty string? Show example how to replace 4 chars with S string. [[User:Alex22|Alex22]] 03:55, 12 June 2014 (CEST)
| + | It's not OK? Y coords are NOT same, coz of folding, of previous lines? [[User:Alex22|Alex22]] |
| | | |
− | :: Improved example. How to calculate bytepos of a utf8 char is not a SynEdit topic. This should be covered on its owe wiki page / or on a page related to utf8. If exists it can be linked. - Martin | + | :: Physical and Logical caret return the same y. There is no mapping of lines according to folding. |
− | | + | :: Physical does not change the Y for folded. There are functions to map this. |
− | ::: How to write examp, which replaces string from (x=2,y=10) to (x=4,y=20) with string S ?
| |
− | ::: b) better remove @SynEdit.LineText[p2.x] , it's not good for exm. [[User:Alex22|Alex22]] | |
− | | |
− | :::: if x=2/y=10 are correct logical positions (1-based first byte pos of a char)
| |
− | :::: (there is a unit that defines the function point / use codetools to find, it, or assign by hand to p.x/p.y of point)
| |
− | :::: Last byte replaced is at x=3 y=20
| |
− | :::: SynEdit.TextBetweenPoints[point(2,10),point(4,20)] := s;
| |
− | :::: This is identical to setting the text selection, and replacing it. Except, this can keep the current selection. -- Martin
| |
Y caret
Both are 1-based. Currently Y coordinates are always the same. This may change in future.
It's not OK? Y coords are NOT same, coz of folding, of previous lines? Alex22
- Physical and Logical caret return the same y. There is no mapping of lines according to folding.
- Physical does not change the Y for folded. There are functions to map this.