Rename insert mode to overtype mode
This commit is contained in:
parent
b700011314
commit
b799e5583a
@ -391,6 +391,13 @@
|
|||||||
Returns if the given line is wrapped.
|
Returns if the given line is wrapped.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="is_overtype_mode_enabled" qualifiers="const">
|
||||||
|
<return type="bool">
|
||||||
|
</return>
|
||||||
|
<description>
|
||||||
|
Gets if the user is in overtype mode.
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="menu_option">
|
<method name="menu_option">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<argument index="0" name="option" type="int" />
|
<argument index="0" name="option" type="int" />
|
||||||
@ -620,6 +627,15 @@
|
|||||||
Sets OpenType feature [code]tag[/code]. More info: [url=https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags]OpenType feature tags[/url].
|
Sets OpenType feature [code]tag[/code]. More info: [url=https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags]OpenType feature tags[/url].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="set_overtype_mode_enabled">
|
||||||
|
<return type="void">
|
||||||
|
</return>
|
||||||
|
<argument index="0" name="enabled" type="bool">
|
||||||
|
</argument>
|
||||||
|
<description>
|
||||||
|
If [code]True[/code] set the user into overtype mode. When the user types it will override existing text.
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="set_selection_mode">
|
<method name="set_selection_mode">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<argument index="0" name="mode" type="int" enum="TextEdit.SelectionMode" />
|
<argument index="0" name="mode" type="int" enum="TextEdit.SelectionMode" />
|
||||||
|
@ -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. */
|
/* 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();
|
begin_complex_operation();
|
||||||
|
|
||||||
/* Make sure we don't try and remove empty space. */
|
/* 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);
|
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();
|
end_complex_operation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1222,12 +1222,12 @@ void TextEdit::_notification(int p_what) {
|
|||||||
if (caret.draw_pos.x >= xmargin_beg && caret.draw_pos.x < xmargin_end) {
|
if (caret.draw_pos.x >= xmargin_beg && caret.draw_pos.x < xmargin_end) {
|
||||||
caret.visible = true;
|
caret.visible = true;
|
||||||
if (draw_caret) {
|
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.
|
//Block or underline caret, draw trailing carets at full height.
|
||||||
int h = cache.font->get_height(cache.font_size);
|
int h = cache.font->get_height(cache.font_size);
|
||||||
|
|
||||||
if (t_caret != Rect2()) {
|
if (t_caret != Rect2()) {
|
||||||
if (insert_mode) {
|
if (overtype_mode) {
|
||||||
t_caret.position.y = TS->shaped_text_get_descent(rid);
|
t_caret.position.y = TS->shaped_text_get_descent(rid);
|
||||||
t_caret.size.y = caret_width;
|
t_caret.size.y = caret_width;
|
||||||
} else {
|
} else {
|
||||||
@ -1238,7 +1238,7 @@ void TextEdit::_notification(int p_what) {
|
|||||||
|
|
||||||
draw_rect(t_caret, caret_color, false);
|
draw_rect(t_caret, caret_color, false);
|
||||||
} else { // End of the line.
|
} else { // End of the line.
|
||||||
if (insert_mode) {
|
if (overtype_mode) {
|
||||||
l_caret.position.y = TS->shaped_text_get_descent(rid);
|
l_caret.position.y = TS->shaped_text_get_descent(rid);
|
||||||
l_caret.size.y = caret_width;
|
l_caret.size.y = caret_width;
|
||||||
} else {
|
} else {
|
||||||
@ -2287,7 +2287,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (k->is_action("ui_text_toggle_insert_mode", true)) {
|
if (k->is_action("ui_text_toggle_insert_mode", true)) {
|
||||||
set_insert_mode(!insert_mode);
|
set_overtype_mode_enabled(!overtype_mode);
|
||||||
accept_event();
|
accept_event();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3254,6 +3254,14 @@ void TextEdit::_update_caches() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Text manipulation */
|
/* 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
|
// Overridable actions
|
||||||
void TextEdit::handle_unicode_input(const uint32_t p_unicode) {
|
void TextEdit::handle_unicode_input(const uint32_t p_unicode) {
|
||||||
@ -4516,15 +4524,6 @@ bool TextEdit::is_drawing_spaces() const {
|
|||||||
return draw_spaces;
|
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() {
|
bool TextEdit::is_insert_text_operation() {
|
||||||
return (current_op.type == TextOperation::TYPE_INSERT);
|
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);
|
ClassDB::bind_method(D_METHOD("is_overriding_selected_font_color"), &TextEdit::is_overriding_selected_font_color);
|
||||||
|
|
||||||
/* Text manipulation */
|
/* 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
|
// Overridable actions
|
||||||
ClassDB::bind_method(D_METHOD("backspace"), &TextEdit::backspace);
|
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. */
|
/* Remove the old character if in insert mode and no selection. */
|
||||||
if (insert_mode && !had_selection) {
|
if (overtype_mode && !had_selection) {
|
||||||
begin_complex_operation();
|
begin_complex_operation();
|
||||||
|
|
||||||
/* Make sure we don't try and remove empty space. */
|
/* 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 };
|
const char32_t chr[2] = { (char32_t)p_unicode, 0 };
|
||||||
insert_text_at_caret(chr);
|
insert_text_at_caret(chr);
|
||||||
|
|
||||||
if ((insert_mode && !had_selection) || (had_selection)) {
|
if ((overtype_mode && !had_selection) || (had_selection)) {
|
||||||
end_complex_operation();
|
end_complex_operation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,6 +188,8 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Text manipulation */
|
/* Text manipulation */
|
||||||
|
bool overtype_mode = false;
|
||||||
|
|
||||||
String cut_copy_line = "";
|
String cut_copy_line = "";
|
||||||
|
|
||||||
/* Caret. */
|
/* Caret. */
|
||||||
@ -348,8 +350,6 @@ private:
|
|||||||
bool scroll_past_end_of_file_enabled = false;
|
bool scroll_past_end_of_file_enabled = false;
|
||||||
bool highlight_current_line = false;
|
bool highlight_current_line = false;
|
||||||
|
|
||||||
bool insert_mode = false;
|
|
||||||
|
|
||||||
bool smooth_scroll_enabled = false;
|
bool smooth_scroll_enabled = false;
|
||||||
bool scrolling = false;
|
bool scrolling = false;
|
||||||
bool dragging_minimap = false;
|
bool dragging_minimap = false;
|
||||||
@ -525,6 +525,8 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/* Text manipulation */
|
/* Text manipulation */
|
||||||
|
void set_overtype_mode_enabled(const bool p_enabled);
|
||||||
|
bool is_overtype_mode_enabled() const;
|
||||||
|
|
||||||
// Overridable actions
|
// Overridable actions
|
||||||
void handle_unicode_input(const uint32_t p_unicode);
|
void handle_unicode_input(const uint32_t p_unicode);
|
||||||
@ -779,9 +781,6 @@ public:
|
|||||||
void set_draw_spaces(bool p_draw);
|
void set_draw_spaces(bool p_draw);
|
||||||
bool is_drawing_spaces() const;
|
bool is_drawing_spaces() const;
|
||||||
|
|
||||||
void set_insert_mode(bool p_enabled);
|
|
||||||
bool is_insert_mode() const;
|
|
||||||
|
|
||||||
double get_v_scroll() const;
|
double get_v_scroll() const;
|
||||||
void set_v_scroll(double p_scroll);
|
void set_v_scroll(double p_scroll);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user