File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ def get_doc_classes():
1111 return [
1212 "@GDScript" ,
1313 "GDScript" ,
14+ "GDScriptSyntaxHighlighter" ,
1415 ]
1516
1617
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <class name =" GDScriptSyntaxHighlighter" inherits =" EditorSyntaxHighlighter" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : noNamespaceSchemaLocation =" ../../../doc/class.xsd" >
3+ <brief_description >
4+ A GDScript syntax highlighter that can be used with [TextEdit] and [CodeEdit] nodes.
5+ </brief_description >
6+ <description >
7+ [b]Note:[/b] This class can only be used for editor plugins because it relies on editor settings.
8+ [codeblocks]
9+ [gdscript]
10+ var code_preview = TextEdit.new()
11+ var highlighter = GDScriptSyntaxHighlighter.new()
12+ code_preview.syntax_highlighter = highlighter
13+ [/gdscript]
14+ [csharp]
15+ var codePreview = new TextEdit();
16+ var highlighter = new GDScriptSyntaxHighlighter();
17+ codePreview.SyntaxHighlighter = highlighter;
18+ [/csharp]
19+ [/codeblocks]
20+ </description >
21+ <tutorials >
22+ </tutorials >
23+ </class >
Original file line number Diff line number Diff line change @@ -167,6 +167,13 @@ void initialize_gdscript_module(ModuleInitializationLevel p_level) {
167167
168168 gdscript_translation_parser_plugin.instantiate ();
169169 EditorTranslationParser::get_singleton ()->add_parser (gdscript_translation_parser_plugin, EditorTranslationParser::STANDARD);
170+ } else if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
171+ ClassDB::APIType prev_api = ClassDB::get_current_api ();
172+ ClassDB::set_current_api (ClassDB::API_EDITOR);
173+
174+ GDREGISTER_CLASS (GDScriptSyntaxHighlighter);
175+
176+ ClassDB::set_current_api (prev_api);
170177 }
171178#endif // TOOLS_ENABLED
172179}
You can’t perform that action at this time.
0 commit comments