impr: Allow Home/End to work in hex editor view

This commit is contained in:
WerWolv
2023-12-29 11:30:23 +01:00
parent 4cbd84671c
commit 3592d17c93
3 changed files with 23 additions and 0 deletions

View File

@@ -851,6 +851,26 @@ namespace hex::plugin::builtin {
m_hexEditor.jumpIfOffScreen();
});
ShortcutManager::addShortcut(this, Keys::Home, "hex.builtin.view.hex_editor.shortcut.cursor_start", [this] {
auto selection = getSelection();
auto cursor = m_hexEditor.getCursorPosition().value_or(selection.getEndAddress());
auto pos = cursor - cursor % m_hexEditor.getBytesPerRow();
this->setSelection(pos, (pos + m_hexEditor.getBytesPerCell()) - 1);
m_hexEditor.scrollToSelection();
m_hexEditor.jumpIfOffScreen();
});
ShortcutManager::addShortcut(this, Keys::End, "hex.builtin.view.hex_editor.shortcut.cursor_end", [this] {
auto selection = getSelection();
auto cursor = m_hexEditor.getCursorPosition().value_or(selection.getEndAddress());
auto pos = cursor - cursor % m_hexEditor.getBytesPerRow() + m_hexEditor.getBytesPerRow() - m_hexEditor.getBytesPerCell();
this->setSelection(pos, (pos + m_hexEditor.getBytesPerCell()) - 1);
m_hexEditor.scrollToSelection();
m_hexEditor.jumpIfOffScreen();
});
// Move selection around
ShortcutManager::addShortcut(this, SHIFT + Keys::Up, "hex.builtin.view.hex_editor.shortcut.selection_up", [this] {
auto selection = getSelection();