diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_settings.cpp | 1 | ||||
-rw-r--r-- | editor/editor_themes.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/editor_preview_plugins.cpp | 20 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 7 | ||||
-rw-r--r-- | editor/plugins/shader_editor_plugin.cpp | 7 | ||||
-rw-r--r-- | editor/plugins/visual_shader_editor_plugin.cpp | 14 |
6 files changed, 43 insertions, 8 deletions
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 4ddae7c062..734fb7f467 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -787,6 +787,7 @@ void EditorSettings::_load_default_text_editor_theme() { _initial_set("text_editor/highlighting/symbol_color", Color(0.73, 0.87, 1.0)); _initial_set("text_editor/highlighting/keyword_color", Color(1.0, 1.0, 0.7)); + _initial_set("text_editor/highlighting/control_flow_keyword_color", Color(1.0, 0.85, 0.7)); _initial_set("text_editor/highlighting/base_type_color", Color(0.64, 1.0, 0.83)); _initial_set("text_editor/highlighting/engine_type_color", Color(0.51, 0.83, 1.0)); _initial_set("text_editor/highlighting/user_type_color", Color(0.42, 0.67, 0.93)); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 7cc9ebd63e..5718b1a5a2 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -1306,6 +1306,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { const Color symbol_color = Color(0.34, 0.57, 1.0).lerp(mono_color, dark_theme ? 0.5 : 0.3); const Color keyword_color = Color(1.0, 0.44, 0.52); + const Color control_flow_keyword_color = dark_theme ? Color(1.0, 0.55, 0.8) : Color(0.8, 0.4, 0.6); const Color basetype_color = dark_theme ? Color(0.26, 1.0, 0.76) : Color(0.0, 0.76, 0.38); const Color type_color = basetype_color.lerp(mono_color, dark_theme ? 0.4 : 0.3); const Color usertype_color = basetype_color.lerp(mono_color, dark_theme ? 0.7 : 0.5); @@ -1344,6 +1345,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { if (text_editor_color_theme == "Adaptive") { setting->set_initial_value("text_editor/highlighting/symbol_color", symbol_color, true); setting->set_initial_value("text_editor/highlighting/keyword_color", keyword_color, true); + setting->set_initial_value("text_editor/highlighting/control_flow_keyword_color", control_flow_keyword_color, true); setting->set_initial_value("text_editor/highlighting/base_type_color", basetype_color, true); setting->set_initial_value("text_editor/highlighting/engine_type_color", type_color, true); setting->set_initial_value("text_editor/highlighting/user_type_color", usertype_color, true); diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index a319a595c7..18cc5d43fb 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -487,10 +487,15 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size List<String> kwors; scr->get_language()->get_reserved_words(&kwors); + Set<String> control_flow_keywords; Set<String> keywords; for (List<String>::Element *E = kwors.front(); E; E = E->next()) { - keywords.insert(E->get()); + if (scr->get_language()->is_control_flow_keyword(E->get())) { + control_flow_keywords.insert(E->get()); + } else { + keywords.insert(E->get()); + } } int line = 0; @@ -502,6 +507,7 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size Color bg_color = EditorSettings::get_singleton()->get("text_editor/highlighting/background_color"); Color keyword_color = EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color"); + Color control_flow_keyword_color = EditorSettings::get_singleton()->get("text_editor/highlighting/control_flow_keyword_color"); Color text_color = EditorSettings::get_singleton()->get("text_editor/highlighting/text_color"); Color symbol_color = EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color"); Color comment_color = EditorSettings::get_singleton()->get("text_editor/highlighting/comment_color"); @@ -523,6 +529,7 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size col = x0; bool prev_is_text = false; + bool in_control_flow_keyword = false; bool in_keyword = false; bool in_comment = false; for (int i = 0; i < code.length(); i++) { @@ -541,6 +548,7 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size if (c != '_' && ((c >= '!' && c <= '/') || (c >= ':' && c <= '@') || (c >= '[' && c <= '`') || (c >= '{' && c <= '~') || c == '\t')) { //make symbol a little visible color = symbol_color; + in_control_flow_keyword = false; in_keyword = false; } else if (!prev_is_text && _is_text_char(c)) { int pos = i; @@ -549,7 +557,9 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size pos++; } String word = code.substr(i, pos - i); - if (keywords.has(word)) { + if (control_flow_keywords.has(word)) { + in_control_flow_keyword = true; + } else if (keywords.has(word)) { in_keyword = true; } @@ -557,11 +567,12 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size in_keyword = false; } - if (in_keyword) { + if (in_control_flow_keyword) { + color = control_flow_keyword_color; + } else if (in_keyword) { color = keyword_color; } } - Color ul = color; ul.a *= 0.5; img->set_pixel(col, y0 + line * 2, bg_color.blend(ul)); @@ -572,6 +583,7 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size col++; } else { prev_is_text = false; + in_control_flow_keyword = false; in_keyword = false; if (c == '\n') { diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 58e6717a3d..35fe6aded1 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -140,10 +140,15 @@ void EditorStandardSyntaxHighlighter::_update_cache() { /* Reserved words. */ const Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color"); + const Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color"); List<String> keywords; script->get_language()->get_reserved_words(&keywords); for (List<String>::Element *E = keywords.front(); E; E = E->next()) { - highlighter->add_keyword_color(E->get(), keyword_color); + if (script->get_language()->is_control_flow_keyword(E->get())) { + highlighter->add_keyword_color(E->get(), control_flow_keyword_color); + } else { + highlighter->add_keyword_color(E->get(), keyword_color); + } } /* Member types. */ diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index ed3b746678..3cdba9cf16 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -141,9 +141,14 @@ void ShaderTextEditor::_load_theme_settings() { List<String> keywords; ShaderLanguage::get_keyword_list(&keywords); const Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color"); + const Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color"); for (List<String>::Element *E = keywords.front(); E; E = E->next()) { - syntax_highlighter->add_keyword_color(E->get(), keyword_color); + if (ShaderLanguage::is_control_flow_keyword(E->get())) { + syntax_highlighter->add_keyword_color(E->get(), control_flow_keyword_color); + } else { + syntax_highlighter->add_keyword_color(E->get(), keyword_color); + } } // Colorize built-ins like `COLOR` differently to make them easier diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index acc77bd098..6564504ccd 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -736,6 +736,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { Color background_color = EDITOR_GET("text_editor/highlighting/background_color"); Color text_color = EDITOR_GET("text_editor/highlighting/text_color"); Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color"); + Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color"); Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color"); Color symbol_color = EDITOR_GET("text_editor/highlighting/symbol_color"); Color function_color = EDITOR_GET("text_editor/highlighting/function_color"); @@ -746,7 +747,11 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { expression_box->add_theme_color_override("background_color", background_color); for (List<String>::Element *E = VisualShaderEditor::get_singleton()->keyword_list.front(); E; E = E->next()) { - expression_syntax_highlighter->add_keyword_color(E->get(), keyword_color); + if (ShaderLanguage::is_control_flow_keyword(E->get())) { + expression_syntax_highlighter->add_keyword_color(E->get(), control_flow_keyword_color); + } else { + expression_syntax_highlighter->add_keyword_color(E->get(), keyword_color); + } } expression_box->add_theme_font_override("font", VisualShaderEditor::get_singleton()->get_theme_font("expression", "EditorFonts")); @@ -2803,6 +2808,7 @@ void VisualShaderEditor::_notification(int p_what) { Color background_color = EDITOR_GET("text_editor/highlighting/background_color"); Color text_color = EDITOR_GET("text_editor/highlighting/text_color"); Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color"); + Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color"); Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color"); Color symbol_color = EDITOR_GET("text_editor/highlighting/symbol_color"); Color function_color = EDITOR_GET("text_editor/highlighting/function_color"); @@ -2812,7 +2818,11 @@ void VisualShaderEditor::_notification(int p_what) { preview_text->add_theme_color_override("background_color", background_color); for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) { - syntax_highlighter->add_keyword_color(E->get(), keyword_color); + if (ShaderLanguage::is_control_flow_keyword(E->get())) { + syntax_highlighter->add_keyword_color(E->get(), control_flow_keyword_color); + } else { + syntax_highlighter->add_keyword_color(E->get(), keyword_color); + } } preview_text->add_theme_font_override("font", get_theme_font("expression", "EditorFonts")); |