diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-09-29 12:04:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-29 12:04:45 +0200 |
commit | 3b532aa7ebddd47f8b041190c30b5b473dfbe116 (patch) | |
tree | 08e7612ccdf7b7e5f77f01cf567f33907415652a /editor/plugins | |
parent | c9e1aced53929159f3deaba21df258c991e7ef7f (diff) | |
parent | db89fef8fac26b829025bfd21e475f170e2bde8f (diff) |
Merge pull request #32410 from bojidar-bg/5739-highlight-singletons
Highlight singletons and class_names in GDScript
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 25 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.h | 1 |
2 files changed, 26 insertions, 0 deletions
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 073e6f74e9..9d3c580f02 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -224,6 +224,7 @@ void ScriptTextEditor::_load_theme_settings() { Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color"); Color basetype_color = EDITOR_GET("text_editor/highlighting/base_type_color"); Color type_color = EDITOR_GET("text_editor/highlighting/engine_type_color"); + Color usertype_color = EDITOR_GET("text_editor/highlighting/user_type_color"); Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color"); Color string_color = EDITOR_GET("text_editor/highlighting/string_color"); @@ -262,6 +263,7 @@ void ScriptTextEditor::_load_theme_settings() { colors_cache.keyword_color = keyword_color; colors_cache.basetype_color = basetype_color; colors_cache.type_color = type_color; + colors_cache.usertype_color = usertype_color; colors_cache.comment_color = comment_color; colors_cache.string_color = string_color; @@ -325,6 +327,29 @@ void ScriptTextEditor::_set_theme_for_script() { } _update_member_keywords(); + //colorize user types + List<StringName> global_classes; + ScriptServer::get_global_class_list(&global_classes); + + for (List<StringName>::Element *E = global_classes.front(); E; E = E->next()) { + + text_edit->add_keyword_color(E->get(), colors_cache.usertype_color); + } + + //colorize singleton autoloads (as types, just as engine singletons are) + List<PropertyInfo> props; + ProjectSettings::get_singleton()->get_property_list(&props); + for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { + String s = E->get().name; + if (!s.begins_with("autoload/")) { + continue; + } + String path = ProjectSettings::get_singleton()->get(s); + if (path.begins_with("*")) { + text_edit->add_keyword_color(s.get_slice("/", 1), colors_cache.usertype_color); + } + } + //colorize comments List<String> comments; script->get_language()->get_comment_delimiters(&comments); diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index 0ea8726ecc..eba75befd4 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -91,6 +91,7 @@ class ScriptTextEditor : public ScriptEditorBase { Color keyword_color; Color basetype_color; Color type_color; + Color usertype_color; Color comment_color; Color string_color; } colors_cache; |