summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaulb23 <p_batty@hotmail.co.uk>2016-05-15 01:32:43 +0100
committerPaulb23 <p_batty@hotmail.co.uk>2016-05-15 01:32:43 +0100
commitb2bf266ddc799c8421c544b860c36ba1f110ba9c (patch)
tree2454d1c1fa9cb9ec1d52c2438460156ccb911145
parent7913e792acd656469b29fb90be1dbb7c06a855ba (diff)
Fixed hex notation highlighting
-rw-r--r--scene/gui/text_edit.cpp30
1 files changed, 23 insertions, 7 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 8df0c6d254..7bbdc38d50 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;
}