Sign in Join
Wiki copytemporary

ATSynEdit EControl adapter: what changed

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

OldNewLine
11# Intro
22
33[[ATSynEdit]] has adapter for lexers from SynWrite editor. It's EControl lexer engine.
44
55- Use repo <https://github.com/Alexey-T/EControl>
66- Use repo <https://github.com/Alexey-T/ATSynEdit_Ex>
77
88Unit ATSynEdit_Adapter_EControl contains class TATAdapterEControl. You must create object of this class and assign this object to editor property AdapterHilite.
99
1010For ex, if you have editor object:
1111
1212``` pascal
1313 //form's OnCreate
1414 Adapter:= TATAdapterEControl.Create(Self);
1515 Edit1.AdapterHilite:= Adapter;
1616```
1717
1818For ex, if you have 2 editor objects with the same text-source (see help topic [[ATSynEdit]]):
1919
2020``` pascal
2121 Adapter:= TATAdapterEControl.Create(Self);
2222 Adapter.AddEditor(Ed1);
2323 Adapter.AddEditor(Ed2);
2424 Ed1.AdapterHilite:= Adapter;
2525 Ed2.AdapterHilite:= Adapter;
2626```
2727
2828# Properties
2929
3030- Lexer: TecSyntAnalyzer. You must set this prop from SyntaxManager object. SyntaxManager is a collection of lexers, which is loaded from .lxl file. After you load SyntaxManager, get its any item and assign it to Lexer prop. Example exists in demo of ATSynEdit. Set to nil to disable adapter.
3131
3232- DynamicHiliteEnabled: boolean. This enables dynamic highlight, ie highlight of tokens depending on caret position. If enabled, adapter reads editor's caret-pos-changed event and recalculates hiliting if needed. Some lexers use this feature: HTML hilites tags with green if caret is inside tag; Pascal hilites "begin"/"end" with green if caret is inside block; rare C-like lexers hilite brackets.
3333
34-<figure>
35-<img src="atsynedit_dyn_hilite.png" title="atsynedit_dyn_hilite.png" />
36-<figcaption>atsynedit_dyn_hilite.png</figcaption>
37-</figure>
34+![](/wiki-images/5/58/Atsynedit_dyn_hilite.png)
3835
3936- OnParseBegin, OnParseDone: these events called by adapter on analyzing start and after analyzing finish. If big file parsed, OnParseDone will fire after few seconds, during which user may edit/scroll file.
4037
4138- procedure AddEditor(AEdit: TATSynEdit). This adds editor to internal list. This is to support 2+ editors which have single text-source (application has split-tab feature). Pass nil to clear internal list and disable adapter.
4239
4340# Syntax tree
4441
4542Support for syntax tree exists like in SynWrite. Many lexers support tree (most C-based, Pascal, HTML, CSS, Python...). You need to add TTreeView to your form and use it in this API. Set tree read/only.
4643
47-<figure>
48-<img src="atsynedit_tree.png" title="atsynedit_tree.png" />
49-<figcaption>atsynedit_tree.png</figcaption>
50-</figure>
44+![](/wiki-images/d/d0/Atsynedit_tree.png)
5145
5246``` pascal
5347 procedure TreeFill(ATree: TTreeView);
5448```
5549
5650It fills tree with nodes from adapter. Call it only after parsing is done. On parsing start, better clear the tree.
5751
5852``` pascal
5953 property TreeBusy: boolean
6054```
6155
6256It is true during filling of tree by TreeFill.
6357
6458``` pascal
6559 procedure TreeShowItemForCaret(Tree: TTreeView; P: TPoint);
6660```
6761
6862This focuses tree node, for given caret position. Only if position has a node.
6963
7064``` pascal
7165 function TreeGetPositionOfRange(R: TecTextRange): TPoint;
7266 function TreeGetRangeOfPosition(P: TPoint): TecTextRange;
7367```
7468
7569These get caret position from a range, or range from caret position. Range is object, it's stored in TTreeNode.Data of nodes. If you want to goto clicked tree item, add OnDblClick event to tree, and use this API. Example:
7670
7771``` pascal
7872procedure TfmMain.TreeDblClick(Sender: TObject);
7973var
8074 R: TecTextRange;
8175 P: TPoint;
8276begin
8377 if Tree.Selected=nil then exit;
8478 if Tree.Selected.Data=nil then exit;
8579 R:= TecTextRange(Tree.Selected.Data);
8680 P:= CurrentFrame.Adapter.TreeGetPositionOfRange(R);
8781 FTreeClick:= true;
8882 CurrentEditor.DoGotoPosEx(P);
8983 CurrentEditor.SetFocus;
9084 FTreeClick:= false;
9185end;
9286```
9387
9488# Syntax tree icons
9589
9690Many lexers support icons in tree (e.g. Pascal, C#). To show icons, use for tree ImageList with these 8 icons: folder, parts-1, parts-2, parts-3, box, func, arrow-1, arrow-2. Example of icons from CudaText:
9791
98-<figure>
99-<img src="atsynedit_tree_img.png" title="atsynedit_tree_img.png" />
100-<figcaption>atsynedit_tree_img.png</figcaption>
101-</figure>
92+![](/wiki-images/b/b9/Atsynedit_tree_img.png)
10293
10394---
10495*From the Free Pascal wiki, page "ATSynEdit EControl adapter", as it stood on 2020-02-09 after a change by Trev, 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).*
10596Category: ATSynEdit

Back to history