summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaulb23 <p_batty@hotmail.co.uk>2018-04-12 22:26:15 +0100
committerPaulb23 <p_batty@hotmail.co.uk>2018-04-20 20:54:31 +0100
commit4cd16f6ba90c0dce40672f550f403fb76a74a940 (patch)
tree3f1c6d9cddbb44fb6dcedbfea4af7c304ff4b229
parent28dfc7f915fab258d38cb6081ea0f1611b87da68 (diff)
Added GDScript function definition highlighting
-rw-r--r--editor/editor_settings.cpp6
-rw-r--r--editor/editor_themes.cpp6
-rw-r--r--modules/gdscript/editor/gdscript_highlighter.cpp11
-rw-r--r--modules/gdscript/editor/gdscript_highlighter.h1
4 files changed, 23 insertions, 1 deletions
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 85f6d99c67..15e8348b69 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -583,6 +583,9 @@ void EditorSettings::_load_default_text_editor_theme() {
_initial_set("text_editor/highlighting/word_highlighted_color", Color(0.8, 0.9, 0.9, 0.15));
_initial_set("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1));
_initial_set("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1));
+
+ // GDScript highlighter
+ _initial_set("text_editor/highlighting/gdscript/function_definition_color", Color::html("#01e1ff"));
}
bool EditorSettings::_save_text_editor_theme(String p_file) {
@@ -619,6 +622,9 @@ bool EditorSettings::_save_text_editor_theme(String p_file) {
cf->set_value(theme_section, "search_result_color", ((Color)get("text_editor/highlighting/search_result_color")).to_html());
cf->set_value(theme_section, "search_result_border_color", ((Color)get("text_editor/highlighting/search_result_border_color")).to_html());
+ //GDScript highlighter
+ cf->set_value(theme_section, "gdscript/function_definition_color", ((Color)get("text_editor/highlighting/gdscript/function_definition_color")).to_html());
+
Error err = cf->save(p_file);
if (err == OK) {
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 3582379e34..4bd7519ec0 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -1039,6 +1039,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
const Color comment_color = dim_color;
const Color string_color = Color::html(dark_theme ? "#ffd942" : "#ffd118").linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3);
+ const Color function_definition_color = Color::html(dark_theme ? "#01e1ff" : "#00a5ba");
+
const Color te_background_color = Color(0, 0, 0, 0);
const Color completion_background_color = base_color;
const Color completion_selected_color = alpha1;
@@ -1097,6 +1099,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
setting->set_initial_value("text_editor/highlighting/code_folding_color", code_folding_color, true);
setting->set_initial_value("text_editor/highlighting/search_result_color", search_result_color, true);
setting->set_initial_value("text_editor/highlighting/search_result_border_color", search_result_border_color, true);
+
+ setting->set_initial_value("text_editor/highlighting/gdscript/function_definition_color", function_definition_color, true);
} else if (text_editor_color_theme == "Default") {
setting->set_initial_value("text_editor/highlighting/symbol_color", Color::html("badfff"), true);
setting->set_initial_value("text_editor/highlighting/keyword_color", Color::html("ffffb3"), true);
@@ -1128,6 +1132,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
setting->set_initial_value("text_editor/highlighting/code_folding_color", Color(0.8, 0.8, 0.8, 0.8), true);
setting->set_initial_value("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1), true);
setting->set_initial_value("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1), true);
+
+ setting->set_initial_value("text_editor/highlighting/gdscript/function_definition_color", Color::html("#01e1ff"), true);
}
return theme;
diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp
index ac65b5bcb1..9e9e3df0ee 100644
--- a/modules/gdscript/editor/gdscript_highlighter.cpp
+++ b/modules/gdscript/editor/gdscript_highlighter.cpp
@@ -29,7 +29,9 @@
/*************************************************************************/
#include "gdscript_highlighter.h"
+#include "../gdscript_tokenizer.h"
#include "scene/gui/text_edit.h"
+#include "editor/editor_settings.h"
inline bool _is_symbol(CharType c) {
@@ -232,7 +234,12 @@ Map<int, TextEdit::HighlighterInfo> GDScriptSyntaxHighlighter::_get_line_syntax_
color = member_color;
} else if (in_function_name) {
next_type = FUNCTION;
- color = function_color;
+
+ if (previous_text == GDScriptTokenizer::get_token_name(GDScriptTokenizer::TK_PR_FUNCTION)) {
+ color = function_definition_color;
+ } else {
+ color = function_color;
+ }
} else if (is_symbol) {
next_type = SYMBOL;
color = symbol_color;
@@ -294,6 +301,8 @@ void GDScriptSyntaxHighlighter::_update_cache() {
function_color = text_editor->get_color("function_color");
number_color = text_editor->get_color("number_color");
member_color = text_editor->get_color("member_variable_color");
+
+ function_definition_color = EDITOR_DEF("text_editor/highlighting/gdscript/function_definition_color", Color::html("#01e1ff"));
}
SyntaxHighlighter *GDScriptSyntaxHighlighter::create() {
diff --git a/modules/gdscript/editor/gdscript_highlighter.h b/modules/gdscript/editor/gdscript_highlighter.h
index 91c913be86..2180021735 100644
--- a/modules/gdscript/editor/gdscript_highlighter.h
+++ b/modules/gdscript/editor/gdscript_highlighter.h
@@ -50,6 +50,7 @@ private:
Color font_color;
Color symbol_color;
Color function_color;
+ Color function_definition_color;
Color built_in_type_color;
Color number_color;
Color member_color;