diff options
| author | Paul Batty | 2016-04-02 20:46:42 +0100 |
|---|---|---|
| committer | Rémi Verschelde | 2016-04-02 22:19:54 +0200 |
| commit | 01471e4c096c95d90288e9acb03b9b800436ad8f (patch) | |
| tree | 3cc771adcd8f28e935ed95b68a9b9a7a89f8df3c /scene/gui/text_edit.cpp | |
| parent | bac8248316f8aaf2890a5c7a4add2f3a562e5891 (diff) | |
| download | godot-01471e4c096c95d90288e9acb03b9b800436ad8f.tar.gz godot-01471e4c096c95d90288e9acb03b9b800436ad8f.tar.zst godot-01471e4c096c95d90288e9acb03b9b800436ad8f.zip | |
Function syntax highlighting
(cherry picked from commit 50aa78210c0e31ea8a348bdd8a2432159dc61879)
Diffstat (limited to 'scene/gui/text_edit.cpp')
| -rw-r--r-- | scene/gui/text_edit.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 9f1aad9c2..99efce42c 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -671,6 +671,7 @@ void TextEdit::_notification(int p_what) { bool prev_is_number = false; bool in_keyword=false; bool in_word = false; + bool in_function_name = false; Color keyword_color; // check if line contains highlighted word @@ -790,11 +791,28 @@ void TextEdit::_notification(int p_what) { } } + if (!in_function_name && in_word && !in_keyword) { + + int k = j; + while(k < str.length() && !_is_symbol(str[k]) && str[k] != '\t' && str[k] != ' ') { + k++; + } + + if (str[k] == '(') { + in_function_name = true; + } + } + + if (is_symbol) { + in_function_name = false; + } if (in_region>=0) color=color_regions[in_region].color; else if (in_keyword) color=keyword_color; + else if (in_function_name) + color=cache.function_color; else if (is_symbol) color=symbol_color; else if (is_number) @@ -2958,6 +2976,7 @@ void TextEdit::_update_caches() { cache.font_color=get_color("font_color"); cache.font_selected_color=get_color("font_selected_color"); cache.keyword_color=get_color("keyword_color"); + cache.function_color=get_color("function_color"); cache.number_color=get_color("number_color"); cache.selection_color=get_color("selection_color"); cache.mark_color=get_color("mark_color"); |
