diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/control.cpp | 4 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 38 | ||||
-rw-r--r-- | scene/gui/text_edit.h | 1 |
3 files changed, 39 insertions, 4 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index b74f3fa17e..b393f926e7 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -602,8 +602,8 @@ void Control::_notification(int p_notification) { if (!is_visible()) { - - get_viewport()->_gui_hid_control(this); + if(get_viewport() != NULL) + get_viewport()->_gui_hid_control(this); _modal_stack_remove(); minimum_size_changed(); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 3948de7689..c9dd2dacf9 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -47,6 +47,15 @@ static bool _is_symbol(CharType c) { return c!='_' && ((c>='!' && c<='/') || (c>=':' && c<='@') || (c>='[' && c<='`') || (c>='{' && c<='~') || c=='\t'); } +static bool _is_char(CharType c) { + + return (c>='a' && c<='z') || (c>='A' && c<='Z') || c=='_'; +} + +static bool _is_number(CharType c) { + return (c >= '0' && c <= '9'); +} + static bool _is_pair_right_symbol(CharType c) { return c == '"' || @@ -659,7 +668,9 @@ void TextEdit::_notification(int p_what) { int char_ofs=0; int ofs_y=i*get_row_height()+cache.line_spacing/2; bool prev_is_char=false; + bool prev_is_number = false; bool in_keyword=false; + bool in_word = false; Color keyword_color; // check if line contains highlighted word @@ -712,13 +723,32 @@ void TextEdit::_notification(int p_what) { color = cache.font_color; //reset //find keyword - bool is_char = _is_text_char(str[j]); - bool is_symbol=_is_symbol(str[j]); + bool is_char = _is_text_char(str[j]); + bool is_symbol = _is_symbol(str[j]); + bool is_number = _is_number(str[j]); if (j==0 && in_region>=0 && color_regions[in_region].line_only) { in_region=-1; //reset regions that end at end of line } + if (!in_word && _is_char(str[j])) { + in_word = true; + } + + if (in_keyword || in_word) { + 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; + } + if (is_symbol && cri_map.has(j)) { @@ -767,8 +797,11 @@ void TextEdit::_notification(int p_what) { color=keyword_color; else if (is_symbol) color=symbol_color; + else if (is_number) + color=cache.number_color; prev_is_char=is_char; + prev_is_number=is_number; } int char_w; @@ -2946,6 +2979,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.number_color=get_color("number_color"); cache.selection_color=get_color("selection_color"); cache.mark_color=get_color("mark_color"); cache.current_line_color=get_color("current_line_color"); diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 86696ca5a5..e7e6760379 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -76,6 +76,7 @@ class TextEdit : public Control { Color font_color; Color font_selected_color; Color keyword_color; + Color number_color; Color selection_color; Color mark_color; Color breakpoint_color; |