reckfellENGINE

CodeHighlighter

Configurable lexical highlighting for keywords, numbers, calls and colored regions.

On this page
class CodeHighlighterReckfellSharpInherits SyntaxHighlighter

CodeHighlighter is a ready lexical implementation for TextEdit rather than a C# compiler or semantic analyzer. Assign a separate instance to each editor, configure token colors, then add keywords and comment/string regions. No complete language rule set is loaded automatically.

KeywordColors and MemberKeywordColors map exact case-sensitive words to Color. MemberKeywordColors applies to unqualified words; a word after a dot uses MemberVariableColor. Important limitation: opaque black with alpha 1 is the unset-color marker in keyword tables and is not applied even when HasKeywordColor returns true. Use a custom SyntaxHighlighter for that exact color.

Keyword tables are shared with supplied dictionaries and getter results. In-place edits do not invalidate the cache; ClearKeywordColors also clears the caller’s shared table. Prefer Add/Remove methods or separately prepared tables. Call EmitChanged after changing rules; after mutating a shared table, call ClearHighlightingCache before EmitChanged.

AddColorRegion defines literal opening/closing symbols. An empty closer always makes a region line-only; lineOnly true does so even with a closer. Longer openers are checked before shorter ones. ColorRegions uses "opener closer" keys but does not preserve lineOnly: reading and reassigning the table can turn a line-only region into a multiline region. Use AddColorRegion for exact configuration.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

CodeHighlighterConstructor
# CodeHighlighter
C#
public CodeHighlighter();

Creates a lexical highlighter with empty keyword and region tables. Attach an editor and configure a palette; not a complete syntax configuration for a particular language.

Properties7

ColorRegionsProperty
# ColorRegions
C#
public Reckfell.Collections.Dictionary ColorRegions { get; set; }

Snapshot Dictionary of regions: keys are "opener closer", or only "opener" for a line-only region; values are Color. Assignment replaces regions without sharing the container. Does not encode explicit lineOnly with a nonempty closer; use AddColorRegion for that.

FunctionColorProperty
# FunctionColor
C#
public Color FunctionColor { get; set; }

Lexical color for names before an opening call parenthesis. A text rule rather than compiler semantic classification. The setter clears the resource cache; call EmitChanged to refresh the editor.

KeywordColorsProperty
# KeywordColors
C#
public Reckfell.Collections.Dictionary KeywordColors { get; set; }

Shared Dictionary mapping exact words to Color. Assignment replaces the table and clears the resource cache. In-place changes to the shared dictionary do not clear the cache. Opaque black with alpha 1 is not applied as a keyword color. Use EmitChanged to refresh the editor.

MemberKeywordColorsProperty
# MemberKeywordColors
C#
public Reckfell.Collections.Dictionary MemberKeywordColors { get; set; }

Shared Dictionary for unqualified member-word colors. A word after a dot does not use this rule; MemberVariableColor applies. Assignment clears the resource cache, but in-place shared-table changes do not. Opaque black with alpha 1 is treated as unset.

MemberVariableColorProperty
# MemberVariableColor
C#
public Color MemberVariableColor { get; set; }

Lexical color for words after a dot. A text rule rather than compiler semantic classification. The setter clears the resource cache; call EmitChanged to refresh the editor.

NumberColorProperty
# NumberColor
C#
public Color NumberColor { get; set; }

Lexical color for numbers. A text rule rather than compiler semantic classification. The setter clears the resource cache; call EmitChanged to refresh the editor.

SymbolColorProperty
# SymbolColor
C#
public Color SymbolColor { get; set; }

Lexical color for symbol characters. A text rule rather than compiler semantic classification. The setter clears the resource cache; call EmitChanged to refresh the editor.

Methods28

AddColorRegionvoid
# AddColorRegion
C#
public void AddColorRegion(string startKey, string endKey, Color color, bool lineOnly = false);

Adds a literal comment/string region. Delimiters consist of symbol characters; use a nonempty opener without spaces. Openers must be unique: RemoveColorRegion before replacing. An empty closer always means line-only; lineOnly true limits to one line even with a closer. Longer openers are checked before shorter ones.

Parameters
NameTypeDefault
startKeystring—
endKeystring—
colorColor—
lineOnlyboolfalse
startKey

Unique nonempty opening delimiter made of symbol characters.

endKey

Closing delimiter; an empty string forces the region to one line.

color

Rule Color; for keyword/member words, opaque black with alpha 1 is treated as unset.

lineOnly

Do not carry the region onto the next line even with a nonempty endKey.

AddKeywordColorvoid
# AddKeywordColor
C#
public void AddKeywordColor(string keyword, Color color);

Adds or replaces an exact case-sensitive keyword color and clears the resource cache. Not a regex. Notify the editor through EmitChanged after changing rules.

Parameters
NameTypeDefault
keywordstring—
colorColor—
keyword

Exact case-sensitive keyword rather than a regex.

color

Rule Color; for keyword/member words, opaque black with alpha 1 is treated as unset.

AddMemberKeywordColorvoid
# AddMemberKeywordColor
C#
public void AddMemberKeywordColor(string memberKeyword, Color color);

Adds or replaces an exact unqualified member-word color. Not intended for a name after a dot. Clears the resource cache; then notify the editor through EmitChanged.

Parameters
NameTypeDefault
memberKeywordstring—
colorColor—
memberKeyword

Exact unqualified member word; the table setter takes a Dictionary of words and Color.

color

Rule Color; for keyword/member words, opaque black with alpha 1 is treated as unset.

ClearColorRegionsvoid
# ClearColorRegions
C#
public void ClearColorRegions();

Removes all colored regions and clears their multiline-state cache. Retains keyword tables.

ClearKeywordColorsvoid
# ClearKeywordColors
C#
public void ClearKeywordColors();

Clears the shared keyword table and cache. If supplied externally, the original Dictionary also becomes empty.

ClearMemberKeywordColorsvoid
# ClearMemberKeywordColors
C#
public void ClearMemberKeywordColors();

Clears the shared member table and resource cache. An externally supplied Dictionary is cleared too.

GetColorRegionsReckfell.Collections.Dictionary
# GetColorRegions
C#
public Reckfell.Collections.Dictionary GetColorRegions();

Snapshot Dictionary of regions: keys are "opener closer", or only "opener" for a line-only region; values are Color. Assignment replaces regions without sharing the container. Does not encode explicit lineOnly with a nonempty closer; use AddColorRegion for that.

Returns Reckfell.Collections.Dictionary

Snapshot Dictionary of regions: keys are "opener closer", or only "opener" for a line-only region; values are Color. Assignment replaces regions without sharing the container. Does not encode explicit lineOnly with a nonempty closer; use AddColorRegion for that.

GetFunctionColorColor
# GetFunctionColor
C#
public Color GetFunctionColor();

Lexical color for names before an opening call parenthesis. A text rule rather than compiler semantic classification. The setter clears the resource cache; call EmitChanged to refresh the editor.

Returns Color

Lexical color for names before an opening call parenthesis. A text rule rather than compiler semantic classification. The setter clears the resource cache; call EmitChanged to refresh the editor.

GetKeywordColorColor
# GetKeywordColor
C#
public Color GetKeywordColor(string keyword);

Stored color of an existing keyword. Check HasKeywordColor first: a missing rule is an error rather than a way to obtain the theme color.

Parameters
NameTypeDefault
keywordstring—
keyword

Exact case-sensitive keyword rather than a regex.

Returns Color

Stored color of an existing keyword. Check HasKeywordColor first: a missing rule is an error rather than a way to obtain the theme color.

GetKeywordColorsReckfell.Collections.Dictionary
# GetKeywordColors
C#
public Reckfell.Collections.Dictionary GetKeywordColors();

Shared Dictionary mapping exact words to Color. Assignment replaces the table and clears the resource cache. In-place changes to the shared dictionary do not clear the cache. Opaque black with alpha 1 is not applied as a keyword color. Use EmitChanged to refresh the editor.

Returns Reckfell.Collections.Dictionary

Shared Dictionary mapping exact words to Color. Assignment replaces the table and clears the resource cache. In-place changes to the shared dictionary do not clear the cache. Opaque black with alpha 1 is not applied as a keyword color. Use EmitChanged to refresh the editor.

GetMemberKeywordColorColor
# GetMemberKeywordColor
C#
public Color GetMemberKeywordColor(string memberKeyword);

Color of an existing member rule. Check HasMemberKeywordColor first; a missing key produces an error.

Parameters
NameTypeDefault
memberKeywordstring—
memberKeyword

Exact unqualified member word; the table setter takes a Dictionary of words and Color.

Returns Color

Color of an existing member rule. Check HasMemberKeywordColor first; a missing key produces an error.

GetMemberKeywordColorsReckfell.Collections.Dictionary
# GetMemberKeywordColors
C#
public Reckfell.Collections.Dictionary GetMemberKeywordColors();

Shared Dictionary for unqualified member-word colors. A word after a dot does not use this rule; MemberVariableColor applies. Assignment clears the resource cache, but in-place shared-table changes do not. Opaque black with alpha 1 is treated as unset.

Returns Reckfell.Collections.Dictionary

Shared Dictionary for unqualified member-word colors. A word after a dot does not use this rule; MemberVariableColor applies. Assignment clears the resource cache, but in-place shared-table changes do not. Opaque black with alpha 1 is treated as unset.

GetMemberVariableColorColor
# GetMemberVariableColor
C#
public Color GetMemberVariableColor();

Lexical color for words after a dot. A text rule rather than compiler semantic classification. The setter clears the resource cache; call EmitChanged to refresh the editor.

Returns Color

Lexical color for words after a dot. A text rule rather than compiler semantic classification. The setter clears the resource cache; call EmitChanged to refresh the editor.

GetNumberColorColor
# GetNumberColor
C#
public Color GetNumberColor();

Lexical color for numbers. A text rule rather than compiler semantic classification. The setter clears the resource cache; call EmitChanged to refresh the editor.

Returns Color

Lexical color for numbers. A text rule rather than compiler semantic classification. The setter clears the resource cache; call EmitChanged to refresh the editor.

GetSymbolColorColor
# GetSymbolColor
C#
public Color GetSymbolColor();

Lexical color for symbol characters. A text rule rather than compiler semantic classification. The setter clears the resource cache; call EmitChanged to refresh the editor.

Returns Color

Lexical color for symbol characters. A text rule rather than compiler semantic classification. The setter clears the resource cache; call EmitChanged to refresh the editor.

HasColorRegionbool
# HasColorRegion
C#
public bool HasColorRegion(string startKey);

Whether an exact region opener is registered. Does not test whether a text position is inside the region.

Parameters
NameTypeDefault
startKeystring—
startKey

Unique nonempty opening delimiter made of symbol characters.

Returns bool

Whether an exact region opener is registered. Does not test whether a text position is inside the region.

HasKeywordColorbool
# HasKeywordColor
C#
public bool HasKeywordColor(string keyword);

Whether the table contains the key. true does not guarantee a visible color: opaque black with alpha 1 is the unset marker.

Parameters
NameTypeDefault
keywordstring—
keyword

Exact case-sensitive keyword rather than a regex.

Returns bool

Whether the table contains the key. true does not guarantee a visible color: opaque black with alpha 1 is the unset marker.

HasMemberKeywordColorbool
# HasMemberKeywordColor
C#
public bool HasMemberKeywordColor(string memberKeyword);

Whether the member table contains the key. Does not guarantee application to a qualified name after a dot.

Parameters
NameTypeDefault
memberKeywordstring—
memberKeyword

Exact unqualified member word; the table setter takes a Dictionary of words and Color.

Returns bool

Whether the member table contains the key. Does not guarantee application to a qualified name after a dot.

RemoveColorRegionvoid
# RemoveColorRegion
C#
public void RemoveColorRegion(string startKey);

Removes a region by its exact opening delimiter and clears the resource cache. Call EmitChanged after rule changes.

Parameters
NameTypeDefault
startKeystring—
startKey

Unique nonempty opening delimiter made of symbol characters.

RemoveKeywordColorvoid
# RemoveKeywordColor
C#
public void RemoveKeywordColor(string keyword);

Removes a keyword rule and clears the resource cache. Removal is visible to every owner of a shared table. Does not delete the word from text.

Parameters
NameTypeDefault
keywordstring—
keyword

Exact case-sensitive keyword rather than a regex.

RemoveMemberKeywordColorvoid
# RemoveMemberKeywordColor
C#
public void RemoveMemberKeywordColor(string memberKeyword);

Removes a member rule from the shared table and clears the resource cache. Does not edit document text.

Parameters
NameTypeDefault
memberKeywordstring—
memberKeyword

Exact unqualified member word; the table setter takes a Dictionary of words and Color.

SetColorRegionsvoid
# SetColorRegions
C#
public void SetColorRegions(Reckfell.Collections.Dictionary colorRegions);

Snapshot Dictionary of regions: keys are "opener closer", or only "opener" for a line-only region; values are Color. Assignment replaces regions without sharing the container. Does not encode explicit lineOnly with a nonempty closer; use AddColorRegion for that.

Parameters
NameTypeDefault
colorRegionsReckfell.Collections.Dictionary—
colorRegions

Dictionary mapping "opener closer" to Color; explicit lineOnly with a nonempty closer is not encoded.

SetFunctionColorvoid
# SetFunctionColor
C#
public void SetFunctionColor(Color color);

Lexical color for names before an opening call parenthesis. A text rule rather than compiler semantic classification. The setter clears the resource cache; call EmitChanged to refresh the editor.

Parameters
NameTypeDefault
colorColor—
color

Rule Color; for keyword/member words, opaque black with alpha 1 is treated as unset.

SetKeywordColorsvoid
# SetKeywordColors
C#
public void SetKeywordColors(Reckfell.Collections.Dictionary keywords);

Shared Dictionary mapping exact words to Color. Assignment replaces the table and clears the resource cache. In-place changes to the shared dictionary do not clear the cache. Opaque black with alpha 1 is not applied as a keyword color. Use EmitChanged to refresh the editor.

Parameters
NameTypeDefault
keywordsReckfell.Collections.Dictionary—
keywords

Shared Dictionary with string keys and Color values; do not mutate in place without clearing the cache.

SetMemberKeywordColorsvoid
# SetMemberKeywordColors
C#
public void SetMemberKeywordColors(Reckfell.Collections.Dictionary memberKeyword);

Shared Dictionary for unqualified member-word colors. A word after a dot does not use this rule; MemberVariableColor applies. Assignment clears the resource cache, but in-place shared-table changes do not. Opaque black with alpha 1 is treated as unset.

Parameters
NameTypeDefault
memberKeywordReckfell.Collections.Dictionary—
memberKeyword

Exact unqualified member word; the table setter takes a Dictionary of words and Color.

SetMemberVariableColorvoid
# SetMemberVariableColor
C#
public void SetMemberVariableColor(Color color);

Lexical color for words after a dot. A text rule rather than compiler semantic classification. The setter clears the resource cache; call EmitChanged to refresh the editor.

Parameters
NameTypeDefault
colorColor—
color

Rule Color; for keyword/member words, opaque black with alpha 1 is treated as unset.

SetNumberColorvoid
# SetNumberColor
C#
public void SetNumberColor(Color color);

Lexical color for numbers. A text rule rather than compiler semantic classification. The setter clears the resource cache; call EmitChanged to refresh the editor.

Parameters
NameTypeDefault
colorColor—
color

Rule Color; for keyword/member words, opaque black with alpha 1 is treated as unset.

SetSymbolColorvoid
# SetSymbolColor
C#
public void SetSymbolColor(Color color);

Lexical color for symbol characters. A text rule rather than compiler semantic classification. The setter clears the resource cache; call EmitChanged to refresh the editor.

Parameters
NameTypeDefault
colorColor—
color

Rule Color; for keyword/member words, opaque black with alpha 1 is treated as unset.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.