From b799e5583acd40f62603305c8a6b2fb31dfca9e3 Mon Sep 17 00:00:00 2001 From: Paulb23 Date: Fri, 9 Jul 2021 13:40:05 +0100 Subject: Rename insert mode to overtype mode --- scene/gui/code_edit.cpp | 4 ++-- scene/gui/text_edit.cpp | 31 ++++++++++++++++--------------- scene/gui/text_edit.h | 9 ++++----- 3 files changed, 22 insertions(+), 22 deletions(-) (limited to 'scene') diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp index aabfde88ff..f9ba1f7f60 100644 --- a/scene/gui/code_edit.cpp +++ b/scene/gui/code_edit.cpp @@ -555,7 +555,7 @@ void CodeEdit::_handle_unicode_input(const uint32_t p_unicode) { } /* Remove the old character if in insert mode and no selection. */ - if (is_insert_mode() && !had_selection) { + if (is_overtype_mode_enabled() && !had_selection) { begin_complex_operation(); /* Make sure we don't try and remove empty space. */ @@ -594,7 +594,7 @@ void CodeEdit::_handle_unicode_input(const uint32_t p_unicode) { insert_text_at_caret(chr); } - if ((is_insert_mode() && !had_selection) || (had_selection)) { + if ((is_overtype_mode_enabled() && !had_selection) || (had_selection)) { end_complex_operation(); } } diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index bcd4cbd7f3..9fc018d33e 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1222,12 +1222,12 @@ void TextEdit::_notification(int p_what) { if (caret.draw_pos.x >= xmargin_beg && caret.draw_pos.x < xmargin_end) { caret.visible = true; if (draw_caret) { - if (caret_type == CaretType::CARET_TYPE_BLOCK || insert_mode) { + if (caret_type == CaretType::CARET_TYPE_BLOCK || overtype_mode) { //Block or underline caret, draw trailing carets at full height. int h = cache.font->get_height(cache.font_size); if (t_caret != Rect2()) { - if (insert_mode) { + if (overtype_mode) { t_caret.position.y = TS->shaped_text_get_descent(rid); t_caret.size.y = caret_width; } else { @@ -1238,7 +1238,7 @@ void TextEdit::_notification(int p_what) { draw_rect(t_caret, caret_color, false); } else { // End of the line. - if (insert_mode) { + if (overtype_mode) { l_caret.position.y = TS->shaped_text_get_descent(rid); l_caret.size.y = caret_width; } else { @@ -2287,7 +2287,7 @@ void TextEdit::_gui_input(const Ref &p_gui_input) { return; } if (k->is_action("ui_text_toggle_insert_mode", true)) { - set_insert_mode(!insert_mode); + set_overtype_mode_enabled(!overtype_mode); accept_event(); return; } @@ -3254,6 +3254,14 @@ void TextEdit::_update_caches() { } /* Text manipulation */ +void TextEdit::set_overtype_mode_enabled(const bool p_enabled) { + overtype_mode = p_enabled; + update(); +} + +bool TextEdit::is_overtype_mode_enabled() const { + return overtype_mode; +} // Overridable actions void TextEdit::handle_unicode_input(const uint32_t p_unicode) { @@ -4516,15 +4524,6 @@ bool TextEdit::is_drawing_spaces() const { return draw_spaces; } -void TextEdit::set_insert_mode(bool p_enabled) { - insert_mode = p_enabled; - update(); -} - -bool TextEdit::is_insert_mode() const { - return insert_mode; -} - bool TextEdit::is_insert_text_operation() { return (current_op.type == TextOperation::TYPE_INSERT); } @@ -5068,6 +5067,8 @@ void TextEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("is_overriding_selected_font_color"), &TextEdit::is_overriding_selected_font_color); /* Text manipulation */ + ClassDB::bind_method(D_METHOD("set_overtype_mode_enabled", "enabled"), &TextEdit::set_overtype_mode_enabled); + ClassDB::bind_method(D_METHOD("is_overtype_mode_enabled"), &TextEdit::is_overtype_mode_enabled); // Overridable actions ClassDB::bind_method(D_METHOD("backspace"), &TextEdit::backspace); @@ -5441,7 +5442,7 @@ void TextEdit::_handle_unicode_input(const uint32_t p_unicode) { } /* Remove the old character if in insert mode and no selection. */ - if (insert_mode && !had_selection) { + if (overtype_mode && !had_selection) { begin_complex_operation(); /* Make sure we don't try and remove empty space. */ @@ -5455,7 +5456,7 @@ void TextEdit::_handle_unicode_input(const uint32_t p_unicode) { const char32_t chr[2] = { (char32_t)p_unicode, 0 }; insert_text_at_caret(chr); - if ((insert_mode && !had_selection) || (had_selection)) { + if ((overtype_mode && !had_selection) || (had_selection)) { end_complex_operation(); } } diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 14d5db49e2..816443d198 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -188,6 +188,8 @@ private: }; /* Text manipulation */ + bool overtype_mode = false; + String cut_copy_line = ""; /* Caret. */ @@ -348,8 +350,6 @@ private: bool scroll_past_end_of_file_enabled = false; bool highlight_current_line = false; - bool insert_mode = false; - bool smooth_scroll_enabled = false; bool scrolling = false; bool dragging_minimap = false; @@ -525,6 +525,8 @@ protected: public: /* Text manipulation */ + void set_overtype_mode_enabled(const bool p_enabled); + bool is_overtype_mode_enabled() const; // Overridable actions void handle_unicode_input(const uint32_t p_unicode); @@ -779,9 +781,6 @@ public: void set_draw_spaces(bool p_draw); bool is_drawing_spaces() const; - void set_insert_mode(bool p_enabled); - bool is_insert_mode() const; - double get_v_scroll() const; void set_v_scroll(double p_scroll); -- cgit v1.2.3