Fixed hex notation highlighting
This commit is contained in:
parent
7913e792ac
commit
b2bf266ddc
|
@ -56,6 +56,10 @@ static bool _is_number(CharType c) {
|
||||||
return (c >= '0' && c <= '9');
|
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) {
|
static bool _is_pair_right_symbol(CharType c) {
|
||||||
return
|
return
|
||||||
c == '"' ||
|
c == '"' ||
|
||||||
|
@ -673,6 +677,7 @@ void TextEdit::_notification(int p_what) {
|
||||||
bool in_word = false;
|
bool in_word = false;
|
||||||
bool in_function_name = false;
|
bool in_function_name = false;
|
||||||
bool in_member_variable = false;
|
bool in_member_variable = false;
|
||||||
|
bool is_hex_notation = false;
|
||||||
Color keyword_color;
|
Color keyword_color;
|
||||||
|
|
||||||
// check if line contains highlighted word
|
// 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
|
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])) {
|
if (!in_word && _is_char(str[j])) {
|
||||||
in_word = true;
|
in_word = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_keyword || in_word) {
|
if ((in_keyword || in_word) && !is_hex_notation) {
|
||||||
is_number = false;
|
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) {
|
if (is_symbol && str[j] != '.' && in_word) {
|
||||||
in_word = false;
|
in_word = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue