Sign in Join
Wiki copytemporary

SynEdit Markup: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: SynEdit Markup

OldNewLine
1+For more info on SynEdit go to: [[SynEdit]]\
2+This page is a draft ....
3+
4+# Terminology
5+
6+Coloring
7+Applying attributes to the Text. Fore- and Background-color, Bold, Italic, Underline, Colored Frame or partial Frame (includes zig-zag line). Also referred to as **highlighting**, though this term is ambiguous as it can refer to either all coloring, or coloring by the Highlighter only.
8+
9+Highligher
10+[[SynEdit Highlighter]]
11+
12+Markup
13+TSynEditMarkup
14+
15+token
16+A fragment of text. Usually a part of a line. This can be at word boundaries, but also go down to individual letters.
17+
18+# About TSynEditMarkup
19+
20+TSynEditMarkup allows to alter the coloring provided by the Highlighter.
21+
22+It is used for:
23+
24+- coloring the selection
25+- coloring the current line
26+- coloring special lines (error, breakpoint....)
27+- coloring matching brackets "()"
28+- coloring "ctrl links" =\> when you can click an identifier to jump to its declaration
29+- coloring the current word (word at caret)
30+- coloring matching begin/end
31+- coloring "lowlight" inactive ifdef (using codetools)
32+
33+and more
34+
35+# Where the color comes from
36+
37+SynEdits paint method retrieves the text as a serious of "token".
38+
39+The primary source of those tokens is the Highligher. In the line:
40+
41+``` pascal
42+a := 1; // comment
43+```
44+
45+The tokens might be
46+
47+- "a " normal text
48+- ":=" a symbol (painted in a different color)
49+- " " normal text
50+- "1" number (painted in a different color)
51+- ";" a symbol (painted in a different color)
52+- " " normal text
53+- "// coment" a comment (painted in a different color)
54+
55+See also [[SynEdit Highlighter]].
56+
57+Those token a retrieved via a list of TLazSynDisplayView (coupled with TSynEditStrings wrappers of the TextBuffer). This is not important for coloring. Though the TLazSynDisplayView could change color.
58+
59+Each token is then fed to the list of TSynEditMarkup. Each TSynEditMarkup can define additional coloring. If that happens the tokens will be broken into smaller parts, and the coloring will be combined/mixed/replaced as needed.
60+
61+# TSynEditMarkup
62+
63+TODO
64+
65+During paint the following method are called
66+
67+*
68+
69+``` pascal
70+ Procedure PrepareMarkupForRow(aRow : Integer); virtual;
71+ Procedure FinishMarkupForRow(aRow : Integer); virtual;
72+```
73+
74+*
75+
76+``` pascal
77+ Procedure BeginMarkup; virtual;
78+ Procedure EndMarkup; virtual;
79+```
80+
81+*
82+
83+``` pascal
84+ Procedure GetNextMarkupColAfterRowCol(const aRow: Integer;
85+ const aStartCol: TLazSynDisplayTokenBound;
86+ const AnRtlInfo: TLazSynDisplayRtlInfo;
87+ out ANextPhys, ANextLog: Integer); virtual; abstract;
88+```
89+
90+Given the current position (painting line number ARow, X is specified in AStartCol), the Markup must set ANextPhys or ANextLog to the next X pos at which it wants to change coloring.
91+
92+If the Markup wants to change text to Bold from X=5 to X=10 and X=15 to X=20, then
93+
94+- for any AStartCol in 1 to 4 =\> ANext... = 5 (switch to bold at 5)
95+- for any AStartCol in 5 to 9 =\> ANext... = 10 (switch to not modifying at 10)
96+- for any AStartCol in 10 to 14 =\> ANext... = 15 (switch to bold at 15)
97+- for any AStartCol in 15 to 19 =\> ANext... = 20 (switch to not modifying at 20)
98+
99+*
100+
101+``` pascal
102+ Function GetMarkupAttributeAtRowCol(const aRow: Integer;
103+ const aStartCol: TLazSynDisplayTokenBound;
104+ const AnRtlInfo: TLazSynDisplayRtlInfo) : TSynSelectedColor; virtual; abstract;
105+```
106+
107+If AStartCol is within any range for that the Markup want to change color, then it must return the correct * for any AStartCol in 5 to 9 =\> ANext... = 10 (switch to not modifying at 10)
108+
109+# See also
110+
111+- <https://forum.lazarus.freepascal.org/index.php/topic,47778.msg342734.html#msg342734>
112+
113+---
114+*From the Free Pascal wiki, page "SynEdit Markup", as it stood on 2024-03-12 after a change by Slawek, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
115+Category: Components
116+Category: Lazarus
117+Category: SynEdit

Back to history