From b4a099d21277d39bd51840b0d8f4622495804ecc Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 9 Mar 2019 22:02:35 +0100 Subject: [PATCH] GTextEditor: Allow jumping lines by hitting Left/Right at start/end of line. --- LibGUI/GTextEditor.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/LibGUI/GTextEditor.cpp b/LibGUI/GTextEditor.cpp index 83c5eb1cf0..8443c2c594 100644 --- a/LibGUI/GTextEditor.cpp +++ b/LibGUI/GTextEditor.cpp @@ -307,6 +307,13 @@ void GTextEditor::keydown_event(GKeyEvent& event) set_cursor(m_cursor.line(), new_column); if (m_selection.start().is_valid()) m_selection.set_end(m_cursor); + } else if (m_cursor.line() > 0) { + int new_line = m_cursor.line() - 1; + int new_column = m_lines[new_line]->length(); + toggle_selection_if_needed_for_event(event); + set_cursor(new_line, new_column); + if (m_selection.start().is_valid()) + m_selection.set_end(m_cursor); } return; } @@ -317,6 +324,13 @@ void GTextEditor::keydown_event(GKeyEvent& event) set_cursor(m_cursor.line(), new_column); if (m_selection.start().is_valid()) m_selection.set_end(m_cursor); + } else if (m_cursor.line() != line_count() - 1) { + int new_line = m_cursor.line() + 1; + int new_column = 0; + toggle_selection_if_needed_for_event(event); + set_cursor(new_line, new_column); + if (m_selection.start().is_valid()) + m_selection.set_end(m_cursor); } return; }