1
0
mirror of synced 2024-11-12 02:00:52 +01:00

impr: Make PageUp and PageDown not move the selection anymore

This commit is contained in:
WerWolv 2024-06-26 19:14:01 +02:00
parent 682aab8b23
commit d241a3ed5f

View File

@ -794,23 +794,12 @@ namespace hex::plugin::builtin {
});
ShortcutManager::addShortcut(this, Keys::PageUp, "hex.builtin.view.hex_editor.shortcut.cursor_page_up", [this] {
auto selection = getSelection();
auto cursor = m_hexEditor.getCursorPosition().value_or(selection.getEndAddress());
u64 visibleByteCount = m_hexEditor.getBytesPerRow() * m_hexEditor.getVisibleRowCount();
if (cursor >= visibleByteCount) {
auto pos = cursor - visibleByteCount;
this->setSelection(pos, (pos + m_hexEditor.getBytesPerCell()) - 1);
m_hexEditor.jumpIfOffScreen();
}
const i64 visibleRowCount = m_hexEditor.getVisibleRowCount();
m_hexEditor.setScrollPosition(m_hexEditor.getScrollPosition() - visibleRowCount);
});
ShortcutManager::addShortcut(this, Keys::PageDown, "hex.builtin.view.hex_editor.shortcut.cursor_page_down", [this] {
auto selection = getSelection();
auto cursor = m_hexEditor.getCursorPosition().value_or(selection.getEndAddress());
auto pos = cursor + (m_hexEditor.getBytesPerRow() * m_hexEditor.getVisibleRowCount());
this->setSelection(pos, (pos + m_hexEditor.getBytesPerCell()) - 1);
m_hexEditor.jumpIfOffScreen();
const i64 visibleRowCount = m_hexEditor.getVisibleRowCount();
m_hexEditor.setScrollPosition(m_hexEditor.getScrollPosition() + visibleRowCount);
});
ShortcutManager::addShortcut(this, Keys::Home, "hex.builtin.view.hex_editor.shortcut.cursor_start", [this] {