summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2018-01-12 11:00:41 -0300
committerJuan Linietsky <reduzio@gmail.com>2018-01-12 11:01:09 -0300
commit419705db6e481214eb6464fbb53cc09575590bb8 (patch)
tree2cd5a4b77704e2d0f80ab353f3b52aaaeb1b560f /scene
parentab9f7f4fc235678f948e227d7d53965685d0b9c2 (diff)
Add special coloring to members, to make shadowing more obvious.
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/text_edit.cpp25
-rw-r--r--scene/gui/text_edit.h4
2 files changed, 29 insertions, 0 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 8f37628c33..d673f21077 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1025,6 +1025,21 @@ void TextEdit::_notification(int p_what) {
const Color *col = keywords.custom_getptr(range, hash);
+ if (!col) {
+ col = member_keywords.custom_getptr(range, hash);
+
+ if (col) {
+ for (int k = j - 1; k >= 0; k--) {
+ if (str[k] == '.') {
+ col = NULL; //member indexing not allowed
+ break;
+ } else if (str[k] > 32) {
+ break;
+ }
+ }
+ }
+ }
+
if (col) {
in_keyword = true;
@@ -4138,6 +4153,16 @@ void TextEdit::add_color_region(const String &p_begin_key, const String &p_end_k
update();
}
+void TextEdit::add_member_keyword(const String &p_keyword, const Color &p_color) {
+ member_keywords[p_keyword] = p_color;
+ update();
+}
+
+void TextEdit::clear_member_keywords() {
+ member_keywords.clear();
+ update();
+}
+
void TextEdit::set_syntax_coloring(bool p_enabled) {
syntax_coloring = p_enabled;
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 5ce751faa8..acbf41aa81 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -210,6 +210,7 @@ class TextEdit : public Control {
//syntax coloring
HashMap<String, Color> keywords;
+ HashMap<String, Color> member_keywords;
Vector<ColorRegion> color_regions;
@@ -546,6 +547,9 @@ public:
void add_color_region(const String &p_begin_key = String(), const String &p_end_key = String(), const Color &p_color = Color(), bool p_line_only = false);
void clear_colors();
+ void add_member_keyword(const String &p_keyword, const Color &p_color);
+ void clear_member_keywords();
+
int get_v_scroll() const;
void set_v_scroll(int p_scroll);