summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/gdscript/config.py1
-rw-r--r--modules/gdscript/doc_classes/GDScriptSyntaxHighlighter.xml23
-rw-r--r--modules/gdscript/register_types.cpp7
3 files changed, 31 insertions, 0 deletions
diff --git a/modules/gdscript/config.py b/modules/gdscript/config.py
index a7d5c406e9..ecd33a5dac 100644
--- a/modules/gdscript/config.py
+++ b/modules/gdscript/config.py
@@ -11,6 +11,7 @@ def get_doc_classes():
return [
"@GDScript",
"GDScript",
+ "GDScriptSyntaxHighlighter",
]
diff --git a/modules/gdscript/doc_classes/GDScriptSyntaxHighlighter.xml b/modules/gdscript/doc_classes/GDScriptSyntaxHighlighter.xml
new file mode 100644
index 0000000000..63a9222901
--- /dev/null
+++ b/modules/gdscript/doc_classes/GDScriptSyntaxHighlighter.xml
@@ -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>
diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp
index 59e387eece..055f8e4110 100644
--- a/modules/gdscript/register_types.cpp
+++ b/modules/gdscript/register_types.cpp
@@ -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
}