Add additional macos shortcuts for going to start/end of line

(cherry picked from commit 166c7fdc9d)
This commit is contained in:
Sherjil Ozair 2018-04-05 12:58:15 -04:00 committed by Hein-Pieter van Braam
parent 6224f02c56
commit 00bf66d7f2
1 changed files with 52 additions and 1 deletions

View File

@ -3005,13 +3005,64 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
} break; } break;
case KEY_A: { case KEY_A: {
#ifndef APPLE_STYLE_KEYS
if (!k->get_command() || k->get_shift() || k->get_alt()) { if (!k->get_command() || k->get_shift() || k->get_alt()) {
scancode_handled = false; scancode_handled = false;
break; break;
} }
select_all(); select_all();
#else
if (k->get_alt()) {
scancode_handled = false;
break;
}
if (!k->get_shift() && k->get_command())
select_all();
else if (k->get_control()) {
if (k->get_shift())
_pre_shift_selection();
int current_line_whitespace_len = 0;
while (current_line_whitespace_len < text[cursor.line].length()) {
CharType c = text[cursor.line][current_line_whitespace_len];
if (c != '\t' && c != ' ')
break;
current_line_whitespace_len++;
}
if (cursor_get_column() == current_line_whitespace_len)
cursor_set_column(0);
else
cursor_set_column(current_line_whitespace_len);
if (k->get_shift())
_post_shift_selection();
else if (k->get_command() || k->get_control())
deselect();
}
} break;
case KEY_E: {
if (!k->get_control() || k->get_command() || k->get_alt()) {
scancode_handled = false;
break;
}
if (k->get_shift())
_pre_shift_selection();
if (k->get_command())
cursor_set_line(text.size() - 1, true, false);
cursor_set_column(text[cursor.line].length());
if (k->get_shift())
_post_shift_selection();
else if (k->get_command() || k->get_control())
deselect();
_cancel_completion();
completion_hint = "";
#endif
} break; } break;
case KEY_X: { case KEY_X: {
if (readonly) { if (readonly) {