Merge pull request #95764 from passivestar/gdscript-syntax-highlighter
Expose GDScript syntax highlighter to editor plugins
This commit is contained in:
commit
f45421204c
|
@ -11,6 +11,7 @@ def get_doc_classes():
|
|||
return [
|
||||
"@GDScript",
|
||||
"GDScript",
|
||||
"GDScriptSyntaxHighlighter",
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="GDScriptSyntaxHighlighter" inherits="EditorSyntaxHighlighter" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
|
||||
<brief_description>
|
||||
A GDScript syntax highlighter that can be used with [TextEdit] and [CodeEdit] nodes.
|
||||
</brief_description>
|
||||
<description>
|
||||
[b]Note:[/b] This class can only be used for editor plugins because it relies on editor settings.
|
||||
[codeblocks]
|
||||
[gdscript]
|
||||
var code_preview = TextEdit.new()
|
||||
var highlighter = GDScriptSyntaxHighlighter.new()
|
||||
code_preview.syntax_highlighter = highlighter
|
||||
[/gdscript]
|
||||
[csharp]
|
||||
var codePreview = new TextEdit();
|
||||
var highlighter = new GDScriptSyntaxHighlighter();
|
||||
codePreview.SyntaxHighlighter = highlighter;
|
||||
[/csharp]
|
||||
[/codeblocks]
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
</class>
|
|
@ -165,6 +165,13 @@ void initialize_gdscript_module(ModuleInitializationLevel p_level) {
|
|||
|
||||
gdscript_translation_parser_plugin.instantiate();
|
||||
EditorTranslationParser::get_singleton()->add_parser(gdscript_translation_parser_plugin, EditorTranslationParser::STANDARD);
|
||||
} else if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
|
||||
ClassDB::APIType prev_api = ClassDB::get_current_api();
|
||||
ClassDB::set_current_api(ClassDB::API_EDITOR);
|
||||
|
||||
GDREGISTER_CLASS(GDScriptSyntaxHighlighter);
|
||||
|
||||
ClassDB::set_current_api(prev_api);
|
||||
}
|
||||
#endif // TOOLS_ENABLED
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue