diff options
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/text_edit.cpp | 40 | ||||
-rw-r--r-- | scene/gui/text_edit.h | 6 |
2 files changed, 32 insertions, 14 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 321bbb9338..1a29e6c5f1 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -672,6 +672,7 @@ void TextEdit::_notification(int p_what) { bool in_keyword=false; bool in_word = false; bool in_function_name = false; + bool in_member_variable = false; Color keyword_color; // check if line contains highlighted word @@ -803,14 +804,28 @@ void TextEdit::_notification(int p_what) { } } + if (!in_function_name && !in_member_variable && !in_keyword && !is_number && in_word) { + int k = j; + while(k > 0 && !_is_symbol(str[k]) && str[k] != '\t' && str[k] != ' ') { + k--; + } + + if (str[k] == '.') { + in_member_variable = true; + } + } + if (is_symbol) { in_function_name = false; + in_member_variable = false; } if (in_region>=0) color=color_regions[in_region].color; else if (in_keyword) color=keyword_color; + else if (in_member_variable) + color=cache.member_variable_color; else if (in_function_name) color=cache.function_color; else if (is_symbol) @@ -1132,7 +1147,7 @@ void TextEdit::_consume_pair_symbol(CharType ch) { int new_column,new_line; - _begin_complex_operation(); + begin_complex_operation(); _insert_text(get_selection_from_line(), get_selection_from_column(), ch_single, &new_line, &new_column); @@ -1145,7 +1160,7 @@ void TextEdit::_consume_pair_symbol(CharType ch) { get_selection_to_column() + to_col_offset, ch_single_pair, &new_line,&new_column); - _end_complex_operation(); + end_complex_operation(); cursor_set_line(get_selection_to_line()); cursor_set_column(get_selection_to_column() + to_col_offset); @@ -1599,7 +1614,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { // remove the old character if in insert mode if (insert_mode) { - _begin_complex_operation(); + begin_complex_operation(); // make sure we don't try and remove empty space if (cursor.column < get_line(cursor.line).length()) { @@ -1610,7 +1625,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { _insert_text_at_cursor(chr); if (insert_mode) { - _end_complex_operation(); + end_complex_operation(); } } } @@ -1686,10 +1701,10 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { cursor_set_line(selection.from_line); cursor_set_column(selection.from_column); - _begin_complex_operation(); + begin_complex_operation(); _remove_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column); _insert_text_at_cursor(txt); - _end_complex_operation(); + end_complex_operation(); selection.active=true; selection.from_column=sel_column; selection.from_line=sel_line; @@ -1747,7 +1762,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { } if (clear) { - _begin_complex_operation(); + begin_complex_operation(); selection.active=false; update(); _remove_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column); @@ -2396,7 +2411,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { // remove the old character if in insert mode and no selection if (insert_mode && !had_selection) { - _begin_complex_operation(); + begin_complex_operation(); // make sure we don't try and remove empty space if (cursor.column < get_line(cursor.line).length()) { @@ -2416,11 +2431,11 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { } if (insert_mode && !had_selection) { - _end_complex_operation(); + end_complex_operation(); } if (selection.active != had_selection) { - _end_complex_operation(); + end_complex_operation(); } accept_event(); } else { @@ -3050,6 +3065,7 @@ void TextEdit::_update_caches() { cache.font_selected_color=get_color("font_selected_color"); cache.keyword_color=get_color("keyword_color"); cache.function_color=get_color("function_color"); + cache.member_variable_color=get_color("member_variable_color"); cache.number_color=get_color("number_color"); cache.selection_color=get_color("selection_color"); cache.mark_color=get_color("mark_color"); @@ -3614,12 +3630,12 @@ void TextEdit::clear_undo_history() { } -void TextEdit::_begin_complex_operation() { +void TextEdit::begin_complex_operation() { _push_current_op(); next_operation_is_complex=true; } -void TextEdit::_end_complex_operation() { +void TextEdit::end_complex_operation() { _push_current_op(); ERR_FAIL_COND(undo_stack.size() == 0); diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index cd27469914..3b85ef0b23 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -79,6 +79,7 @@ class TextEdit : public Control { Color keyword_color; Color number_color; Color function_color; + Color member_variable_color; Color selection_color; Color mark_color; Color breakpoint_color; @@ -266,8 +267,6 @@ class TextEdit : public Control { void _cursor_changed_emit(); void _text_changed_emit(); - void _begin_complex_operation(); - void _end_complex_operation(); void _push_current_op(); /* super internal api, undo/redo builds on it */ @@ -319,6 +318,9 @@ public: //void delete_char(); //void delete_line(); + void begin_complex_operation(); + void end_complex_operation(); + void set_text(String p_text); void insert_text_at_cursor(const String& p_text); void insert_at(const String& p_text, int at); |