Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

SyntaxHighlighter

繼承: Resource < RefCounted < Object

被繼承: CodeHighlighter, EditorSyntaxHighlighter

語法高亮器的基底類別。可以向 TextEdit 提供語法高亮資料。

說明

語法高亮器的基底類別。向 TextEdit 提供語法高亮資料。關聯的 TextEdit 節點會根據需要呼叫 SyntaxHighlighter

注意:不應在多個 TextEdit 節點間共用 SyntaxHighlighter 實例。

方法

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()


方法說明

void _clear_highlighting_cache() virtual 🔗

虛方法,覆蓋後可以清空本地快取。


Dictionary _get_line_syntax_highlighting(line: int) virtual const 🔗

虛方法,覆蓋後可以返回語法高亮資料。

詳情見 get_line_syntax_highlighting()


void _update_cache() virtual 🔗

虛方法,覆蓋後可以更新本地快取。


void clear_highlighting_cache() 🔗

清空所有快取的語法高亮資料。

然後呼叫可覆蓋的 _clear_highlighting_cache() 方法。


Dictionary get_line_syntax_highlighting(line: int) 🔗

Returns the syntax highlighting data for the line at index line. If the line is not cached, calls _get_line_syntax_highlighting() first to calculate the data.

Each entry is a column number containing a nested Dictionary. The column number denotes 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: Possible return value. This means columns 0 to 4 should be red, and columns 5 to the end of the line should be green:

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

TextEdit get_text_edit() const 🔗

返回關聯的 TextEdit 節點。


void update_cache() 🔗

清除然後更新 SyntaxHighlighter 快取。為一個回呼函式覆蓋 _update_cache()

注意:當關聯的 TextEdit 節點更新它自己的快取時,該函式會被自動呼叫。