mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:27:42 +00:00
GTextEditor: Add basic PageUp/PageDown navigation support.
This commit is contained in:
parent
187d7cb400
commit
f8b72ab3ab
1 changed files with 16 additions and 0 deletions
|
@ -160,6 +160,22 @@ void GTextEditor::keydown_event(GKeyEvent& event)
|
||||||
}
|
}
|
||||||
return;
|
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 (!event.modifiers() && event.key() == KeyCode::Key_Left) {
|
||||||
if (m_cursor.column() > 0) {
|
if (m_cursor.column() > 0) {
|
||||||
int new_column = m_cursor.column() - 1;
|
int new_column = m_cursor.column() - 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue