SyntaxHighlighter
Text-highlighting resource with color-transition maps and its own cache.
Create a separate SyntaxHighlighter per TextEdit and assign it through TextEdit.SyntaxHighlighter. The resource stores one editor context: assigning another rebinds it even if the first still references the same resource. Do not share one instance across simultaneous editors.
For custom highlighting, inherit SyntaxHighlighter and override _GetLineSyntaxHighlighting. Return a Dictionary whose key is a Unicode code-point column and whose value is a nested Dictionary containing "color" as a Color. Each color applies until the next key or line end. Transitions at 0 and 5 define two spans rather than one color entry per character.
Use GetLineSyntaxHighlighting to request data through the cache. The returned dictionary is shared with the cache: read it without clearing or modifying it in place. Disposing the C# dictionary wrapper is different from Clear. Line edits automatically invalidate corresponding data.
When custom rules change, clear the resource cache with ClearHighlightingCache or refresh state with UpdateCache, then call EmitChanged: TextEdit also maintains its own cache and listens for the resource’s Changed. ClearHighlightingCache alone does not guarantee an already drawn editor refresh.
GetTextEdit returns a borrowed reference. Do not free the editor through it. Align resource lifetime with the editor and do not request highlighting after the editor is freed; an external resource reference does not keep the UI alive.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
SyntaxHighlighterConstructor
public SyntaxHighlighter();Creates a resource without an attached editor. The base implementation defines no language rules; override _GetLineSyntaxHighlighting or use CodeHighlighter.
Methods7
ClearHighlightingCachevoid
public void ClearHighlightingCache();Clears line maps and invokes the clear hook without refreshing every setting. Also call EmitChanged to refresh TextEdit after rule changes: the editor has a separate cache.
GetLineSyntaxHighlightingReckfell.Collections.Dictionary
public Reckfell.Collections.Dictionary GetLineSyntaxHighlighting(int line);Returns a cached column → {"color": Color} transition map. Empty without an attached editor. Call this method rather than invoking the virtual hook directly. The dictionary is shared with the cache: do not mutate it in place; dispose the C# wrapper after reading.
| Name | Type | Default |
|---|---|---|
line | int | — |
lineExisting logical-line index; result columns count Unicode code points.
Reckfell.Collections.DictionaryReturns a cached column → {"color": Color} transition map. Empty without an attached editor. Call this method rather than invoking the virtual hook directly. The dictionary is shared with the cache: do not mutate it in place; dispose the C# wrapper after reading.
GetTextEditTextEdit
public TextEdit GetTextEdit();Borrowed context for one TextEdit, null before attachment. Does not keep the editor alive or permit use after it is freed. A shared resource returns the most recently attached editor.
TextEditBorrowed context for one TextEdit, null before attachment. Does not keep the editor alive or permit use after it is freed. A shared resource returns the most recently attached editor.
UpdateCachevoid
public void UpdateCache();Clears maps first, then invokes the update hook with a live attached editor. CodeHighlighter refreshes its base font color. Notify the editor with EmitChanged after external rule/data changes.
_ClearHighlightingCachevoid
public virtual void _ClearHighlightingCache();Hook for clearing parser state such as multiline regions. Called by ClearHighlightingCache/UpdateCache. An override replaces the standard hook, so prefer SyntaxHighlighter as the base for a fully custom analyzer.
_GetLineSyntaxHighlightingReckfell.Collections.Dictionary
public virtual Reckfell.Collections.Dictionary _GetLineSyntaxHighlighting(int line);Virtual hook computing one line’s map on a cache miss. Return a Dictionary with integer Unicode code-point columns and nested dictionaries containing a Color under "color". Read text through a live GetTextEdit; do not recursively request GetLineSyntaxHighlighting for the same line.
| Name | Type | Default |
|---|---|---|
line | int | — |
lineExisting logical-line index; result columns count Unicode code points.
Reckfell.Collections.DictionaryVirtual hook computing one line’s map on a cache miss. Return a Dictionary with integer Unicode code-point columns and nested dictionaries containing a Color under "color". Read text through a live GetTextEdit; do not recursively request GetLineSyntaxHighlighting for the same line.
_UpdateCachevoid
public virtual void _UpdateCache();Hook refreshing custom data after maps are cleared. UpdateCache calls it only with an attached editor. Do not edit document text while computing highlighting.