Table of Contents

Class CodeHighlighter

Namespace
Godot
Assembly
GodotSharp.dll

By adjusting various properties of this resource, you can change the colors of strings, comments, numbers, and other text patterns inside a TextEdit control.

public class CodeHighlighter : SyntaxHighlighter, IDisposable
Inheritance
CodeHighlighter
Implements
Inherited Members

Constructors

CodeHighlighter()

public CodeHighlighter()

Properties

ColorRegions

Sets the color regions. All existing regions will be removed. The Dictionary key is the region start and end key, separated by a space. The value is the region color.

public Dictionary ColorRegions { get; set; }

Property Value

Dictionary

FunctionColor

Sets color for functions. A function is a non-keyword string followed by a '('.

public Color FunctionColor { get; set; }

Property Value

Color

KeywordColors

Sets the keyword colors. All existing keywords will be removed. The Dictionary key is the keyword. The value is the keyword color.

public Dictionary KeywordColors { get; set; }

Property Value

Dictionary

MemberKeywordColors

Sets the member keyword colors. All existing member keyword will be removed. The Dictionary key is the member keyword. The value is the member keyword color.

public Dictionary MemberKeywordColors { get; set; }

Property Value

Dictionary

MemberVariableColor

Sets color for member variables. A member variable is non-keyword, non-function string proceeded with a '.'.

public Color MemberVariableColor { get; set; }

Property Value

Color

NumberColor

Sets the color for numbers.

public Color NumberColor { get; set; }

Property Value

Color

SymbolColor

Sets the color for symbols.

public Color SymbolColor { get; set; }

Property Value

Color

Methods

AddColorRegion(string, string, Color, bool)

Adds a color region such as comments or strings.

Both the start and end keys must be symbols. Only the start key has to be unique.

lineOnly denotes if the region should continue until the end of the line or carry over on to the next line. If the end key is blank this is automatically set to true.

public void AddColorRegion(string startKey, string endKey, Color color, bool lineOnly = false)

Parameters

startKey string
endKey string
color Color
lineOnly bool

AddKeywordColor(string, Color)

Sets the color for a keyword.

The keyword cannot contain any symbols except '_'.

public void AddKeywordColor(string keyword, Color color)

Parameters

keyword string
color Color

AddMemberKeywordColor(string, Color)

Sets the color for a member keyword.

The member keyword cannot contain any symbols except '_'.

It will not be highlighted if preceded by a '.'.

public void AddMemberKeywordColor(string memberKeyword, Color color)

Parameters

memberKeyword string
color Color

ClearColorRegions()

Removes all color regions.

public void ClearColorRegions()

ClearKeywordColors()

Removes all keywords.

public void ClearKeywordColors()

ClearMemberKeywordColors()

Removes all member keywords.

public void ClearMemberKeywordColors()

GetKeywordColor(string)

Returns the color for a keyword.

public Color GetKeywordColor(string keyword)

Parameters

keyword string

Returns

Color

GetMemberKeywordColor(string)

Returns the color for a member keyword.

public Color GetMemberKeywordColor(string memberKeyword)

Parameters

memberKeyword string

Returns

Color

HasColorRegion(string)

Returns true if the start key exists, else false.

public bool HasColorRegion(string startKey)

Parameters

startKey string

Returns

bool

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

HasKeywordColor(string)

Returns true if the keyword exists, else false.

public bool HasKeywordColor(string keyword)

Parameters

keyword string

Returns

bool

HasMemberKeywordColor(string)

Returns true if the member keyword exists, else false.

public bool HasMemberKeywordColor(string memberKeyword)

Parameters

memberKeyword string

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

RemoveColorRegion(string)

Removes the color region that uses that start key.

public void RemoveColorRegion(string startKey)

Parameters

startKey string

RemoveKeywordColor(string)

Removes the keyword.

public void RemoveKeywordColor(string keyword)

Parameters

keyword string

RemoveMemberKeywordColor(string)

Removes the member keyword.

public void RemoveMemberKeywordColor(string memberKeyword)

Parameters

memberKeyword string