summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorBojidar Marinov <bojidar.marinov.bg@gmail.com>2019-09-28 13:11:06 +0300
committerBojidar Marinov <bojidar.marinov.bg@gmail.com>2019-09-28 13:13:18 +0300
commitdb89fef8fac26b829025bfd21e475f170e2bde8f (patch)
tree0ad8fddbd4d265174407027e438a88ac196ce119 /editor/plugins
parent3481c47e7148fa31151c95d0adf198a370358351 (diff)
Highlight singletons and class_names in GDScript
Also, implement a small QoL change for auto-typed variables. Closes #5739
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/script_text_editor.cpp25
-rw-r--r--editor/plugins/script_text_editor.h1
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;