Up to date

This page is up to date for Redot 4.3. If you still find outdated information, please create an issue.

SyntaxHighlighterΒΆ

Inherits: Resource < RefCounted < Object

Inherited By: CodeHighlighter, EditorSyntaxHighlighter

Base class for syntax highlighters. Provides syntax highlighting data to a TextEdit.

DescriptionΒΆ

Base class for syntax highlighters. Provides syntax highlighting data to a TextEdit. The associated TextEdit will call into the SyntaxHighlighter on an as-needed basis.

Note: A SyntaxHighlighter instance should not be used across multiple TextEdit nodes.

MethodsΒΆ

void

_clear_highlighting_cache() virtual

Dictionary

_get_line_syntax_highlighting(line: int) virtual const

void

_update_cache() virtual

void

clear_highlighting_cache()

Dictionary

get_line_syntax_highlighting(line: int)

TextEdit

get_text_edit() const

void

update_cache()


Method DescriptionsΒΆ

void _clear_highlighting_cache() virtual πŸ”—

Virtual method which can be overridden to clear any local caches.


Dictionary _get_line_syntax_highlighting(line: int) virtual const πŸ”—

Virtual method which can be overridden to return syntax highlighting data.

See get_line_syntax_highlighting for more details.


void _update_cache() virtual πŸ”—

Virtual method which can be overridden to update any local caches.


void clear_highlighting_cache() πŸ”—

Clears all cached syntax highlighting data.

Then calls overridable method _clear_highlighting_cache.


Dictionary get_line_syntax_highlighting(line: int) πŸ”—

Returns syntax highlighting data for a single line. If the line is not cached, calls _get_line_syntax_highlighting to calculate the data.

The return Dictionary is column number to Dictionary. The column number notes the start of a region, the region will end if another region is found, or at the end of the line. The nested Dictionary contains the data for that region, currently only the key "color" is supported.

Example return:

var color_map = {
    0: {
        "color": Color(1, 0, 0)
    },
    5: {
        "color": Color(0, 1, 0)
    }
}

This will color columns 0-4 red, and columns 5-eol in green.


TextEdit get_text_edit() const πŸ”—

Returns the associated TextEdit node.


void update_cache() πŸ”—

Clears then updates the SyntaxHighlighter caches. Override _update_cache for a callback.

Note: This is called automatically when the associated TextEdit node, updates its own cache.