diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-03-07 17:11:17 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-03-07 17:11:17 +0100 |
commit | f8b72ab3ab1616242b56b8ac42c11f4d8217aca1 (patch) | |
tree | 5dfc04aa62f177748a2917dfec841d4defca074b /LibGUI | |
parent | 187d7cb4001fd0820d5eef53aeb593fb0db25802 (diff) | |
download | serenity-f8b72ab3ab1616242b56b8ac42c11f4d8217aca1.zip |
GTextEditor: Add basic PageUp/PageDown navigation support.
Diffstat (limited to 'LibGUI')
-rw-r--r-- | LibGUI/GTextEditor.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/LibGUI/GTextEditor.cpp b/LibGUI/GTextEditor.cpp index 1cf4dcc5b7..1cba125043 100644 --- a/LibGUI/GTextEditor.cpp +++ b/LibGUI/GTextEditor.cpp @@ -160,6 +160,22 @@ void GTextEditor::keydown_event(GKeyEvent& event) } return; } + if (!event.modifiers() && event.key() == KeyCode::Key_PageUp) { + if (m_cursor.line() > 0) { + int new_line = max(0, m_cursor.line() - visible_content_rect().height() / line_height()); + int new_column = min(m_cursor.column(), m_lines[new_line]->length()); + set_cursor(new_line, new_column); + } + return; + } + if (!event.modifiers() && event.key() == KeyCode::Key_PageDown) { + if (m_cursor.line() < (m_lines.size() - 1)) { + int new_line = min(line_count() - 1, m_cursor.line() + visible_content_rect().height() / line_height()); + int new_column = min(m_cursor.column(), m_lines[new_line]->length()); + set_cursor(new_line, new_column); + } + return; + } if (!event.modifiers() && event.key() == KeyCode::Key_Left) { if (m_cursor.column() > 0) { int new_column = m_cursor.column() - 1; |