Forum > SynEdit
Documentation for SynEdit (La biblia del SynEdit)
Edson:
I have written a document about highlighter before:
http://forum.lazarus.freepascal.org/index.php/topic,21952.0.html
Now I have a new document that includes the before, and covers the SynEdit component.
Well this is not so complete document but it's my humble contribution:
It's in spansih again, but I hope someone can translate.
EDITED: Link deleted. New links in the next posts.
Martin_fr:
Well I don't speak Spanish, but I had a look at it (just the top few pages), and it looks great (I can recognise some of the content.
as for logical versus physical, I can only judge the picture (top of page 12)
The picture (a table) has 2 rows: bytes and characters.
However the 2nd row should be "position/cell in display grid".
If you look at the tab: It is ONE SINGLE CHAR. But it takes several positions in the grid.
Btw so does the Chinese "あ". The "あ" takes 2 places in the grid. It is a so-called "full width" glyph. While latin a-z are half width glyphs. So yes, even in a strictly monospaced font, there are 2 sizes.
It is important to distinguish between:
- byte (logical)
- utf8 codepoint
- char
- glyph (not really important in this context)
- display-grid-cells (physical)
Martin_fr:
--- Quote ---SynEdit1.ExecuteCommand(ecChar,'x',nil);
--- End quote ---
There is a better way:
--- Code: --- procedure ClearAll;
procedure InsertTextAtCaret(aText: String; aCaretMode : TSynCaretAdjustMode = scamEnd);
property TextBetweenPoints[aStartPoint, aEndPoint: TPoint]: String // Logical Points
read GetTextBetweenPoints write SetTextBetweenPointsSimple;
property TextBetweenPointsEx[aStartPoint, aEndPoint: TPoint; CaretMode: TSynCaretAdjustMode]: String
write SetTextBetweenPointsEx;
procedure SetTextBetweenPoints(aStartPoint, aEndPoint: TPoint;
const AValue: String;
aFlags: TSynEditTextFlags = [];
aCaretMode: TSynCaretAdjustMode = scamIgnore;
aMarksMode: TSynMarksAdjustMode = smaMoveUp;
aSelectionMode: TSynSelectionMode = smNormal
);
--- End code ---
--- Code: ---SynEdit.InsertTextAtCaret('A');
--- End code ---
or to delete/replace text
--- Code: ---var p1,p2: TPoint;
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] := '';
--- End code ---
** EDIT: I see you did cover that later
Edson:
Thanks Martin for the observations.
I will correct and complete the document in the next revision. But InsertTextAtCaret() and TextBetweenPoints() are explained in the document. Maybe not so explained.
I don't have information about "full width" glyph. That's why I haven't included.
Do you know where can I find that information?
Martin_fr:
As I mentioned in my "Edit", I saw to late that you included InsertTextAtCaret
"full width" is a term you can google in te context of monospaced fonts. But you do not need to explain it.
I only gave it as example that tab #9 is not the only char that takes more than one cell.
You should make a difference between "character" and "display-grid-cell"
In your table the 2nd row is called character, but tab occupies 4 places. That is wrong: tab is one char. But 4 cells in the display grid.
Navigation
[0] Message Index
[#] Next page