diff options
Diffstat (limited to 'scene/gui/text_edit.cpp')
-rw-r--r-- | scene/gui/text_edit.cpp | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 3eb4e6d75a..9ab30b1976 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1560,8 +1560,7 @@ void TextEdit::_consume_pair_symbol(CharType ch) { } if ((ch == '\'' || ch == '"') && - cursor_get_column() > 0 && - _is_text_char(text[cursor.line][cursor_get_column() - 1])) { + cursor_get_column() > 0 && _is_text_char(text[cursor.line][cursor_get_column() - 1]) && !_is_pair_right_symbol(text[cursor.line][cursor_get_column()])) { insert_text_at_cursor(ch_single); cursor_set_column(cursor_position_to_move); return; @@ -2597,6 +2596,15 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } FALLTHROUGH; } +#ifdef APPLE_STYLE_KEYS + case KEY_B: { + if (!k->get_control()) { + scancode_handled = false; + break; + } + FALLTHROUGH; + } +#endif case KEY_LEFT: { if (k->get_shift()) @@ -2610,9 +2618,22 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { #ifdef APPLE_STYLE_KEYS if (k->get_command()) { - cursor_set_column(0); + // Start at first column (it's slightly faster that way) and look for the first non-whitespace character. + int new_cursor_pos = 0; + for (int i = 0; i < text[cursor.line].length(); ++i) { + if (!_is_whitespace(text[cursor.line][i])) { + new_cursor_pos = i; + break; + } + } + if (new_cursor_pos == cursor.column) { + // We're already at the first text character, so move to the very beginning of the line. + cursor_set_column(0); + } else { + // We're somewhere to the right of the first text character; move to the first one. + cursor_set_column(new_cursor_pos); + } } else if (k->get_alt()) { - #else if (k->get_alt()) { scancode_handled = false; @@ -2660,6 +2681,15 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } FALLTHROUGH; } +#ifdef APPLE_STYLE_KEYS + case KEY_F: { + if (!k->get_control()) { + scancode_handled = false; + break; + } + FALLTHROUGH; + } +#endif case KEY_RIGHT: { if (k->get_shift()) @@ -2721,6 +2751,15 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } FALLTHROUGH; } +#ifdef APPLE_STYLE_KEYS + case KEY_P: { + if (!k->get_control()) { + scancode_handled = false; + break; + } + FALLTHROUGH; + } +#endif case KEY_UP: { if (k->get_alt()) { @@ -2774,6 +2813,15 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } FALLTHROUGH; } +#ifdef APPLE_STYLE_KEYS + case KEY_N: { + if (!k->get_control()) { + scancode_handled = false; + break; + } + FALLTHROUGH; + } +#endif case KEY_DOWN: { if (k->get_alt()) { |