diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2016-05-17 09:33:44 +0200 |
---|---|---|
committer | Rémi Verschelde <remi@verschelde.fr> | 2016-05-17 09:33:44 +0200 |
commit | 02f3e7e766ef33de51f0d2dffdb5b1abf4b44022 (patch) | |
tree | e4f1c15d24eae8bb0f4cd815546e5a4d92ac5f09 | |
parent | 68dc685f1f6182d306fd7a3b31b27ab7c8e10b73 (diff) | |
parent | b2bf266ddc799c8421c544b860c36ba1f110ba9c (diff) |
Merge pull request #4659 from Paulb23/hex_notation_highlighting
Fixed hex notation highlighting
-rw-r--r-- | scene/gui/text_edit.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 1ddf614ec4..03024daff5 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -56,6 +56,10 @@ static bool _is_number(CharType c) { return (c >= '0' && c <= '9'); } +static bool _is_hex_symbol(CharType c) { + return ((c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')); +} + static bool _is_pair_right_symbol(CharType c) { return c == '"' || @@ -673,6 +677,7 @@ void TextEdit::_notification(int p_what) { bool in_word = false; bool in_function_name = false; bool in_member_variable = false; + bool is_hex_notation = false; Color keyword_color; // check if line contains highlighted word @@ -731,20 +736,31 @@ void TextEdit::_notification(int p_what) { in_region=-1; //reset regions that end at end of line } + // allow ABCDEF in hex notation + if (is_hex_notation && (_is_hex_symbol(str[j]) || is_number)) { + is_number = true; + } else { + is_hex_notation = false; + } + + // check for dot or 'x' for hex notation in floating point number + if ((str[j] == '.' || str[j] == 'x') && !in_word && prev_is_number && !is_number) { + is_number = true; + is_symbol = false; + + if (str[j] == 'x' && str[j-1] == '0') { + is_hex_notation = true; + } + } + if (!in_word && _is_char(str[j])) { in_word = true; } - if (in_keyword || in_word) { + if ((in_keyword || in_word) && !is_hex_notation) { is_number = false; } - // check for dot in floating point number - if (str[j] == '.' && !in_word && prev_is_number) { - is_number = true; - is_symbol = false; - } - if (is_symbol && str[j] != '.' && in_word) { in_word = false; } |