summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2022-02-19 16:55:15 +0200
committerAndreas Kling <kling@serenityos.org>2022-02-20 15:44:36 +0100
commit6a998c1a8b3f093d67f313e3eb129a58b3343885 (patch)
tree7f3378095ea35ca8ab1225062ea6e763c48097fd /Userland
parentc8e691f917d396dea43d5a62bd94ac5a76442518 (diff)
downloadserenity-6a998c1a8b3f093d67f313e3eb129a58b3343885.zip
HexEditor: Add support for handling PageUp and PageDown key events
In such case, move the cursor up or down the amount of bytes per row, multiplied by the visible content rectangle height, if possible.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/HexEditor/HexEditor.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/Userland/Applications/HexEditor/HexEditor.cpp b/Userland/Applications/HexEditor/HexEditor.cpp
index 7d9b7f60d3..62d292c485 100644
--- a/Userland/Applications/HexEditor/HexEditor.cpp
+++ b/Userland/Applications/HexEditor/HexEditor.cpp
@@ -432,6 +432,22 @@ void HexEditor::keydown_event(GUI::KeyEvent& event)
return;
}
+ if (event.key() == KeyCode::Key_PageUp) {
+ auto cursor_location_change = min(bytes_per_row() * visible_content_rect().height(), m_position);
+ if (cursor_location_change > 0) {
+ advance_cursor_backwards(cursor_location_change);
+ }
+ return;
+ }
+
+ if (event.key() == KeyCode::Key_PageDown) {
+ auto cursor_location_change = min(bytes_per_row() * visible_content_rect().height(), m_document->size() - m_position);
+ if (cursor_location_change > 0) {
+ advance_cursor_forward(cursor_location_change);
+ }
+ return;
+ }
+
if (!is_readonly() && !event.ctrl() && !event.alt() && !event.text().is_empty()) {
if (m_edit_mode == EditMode::Hex) {
hex_mode_keydown_event(event);