diff --git a/plugins/builtin/romfs/lang/en_US.json b/plugins/builtin/romfs/lang/en_US.json index 54a5f9cb4..790e46252 100644 --- a/plugins/builtin/romfs/lang/en_US.json +++ b/plugins/builtin/romfs/lang/en_US.json @@ -782,6 +782,8 @@ "hex.builtin.view.hex_editor.shortcut.cursor_left": "Move cursor to the left", "hex.builtin.view.hex_editor.shortcut.selection_up": "Move selection up", "hex.builtin.view.hex_editor.shortcut.cursor_up": "Move cursor up", + "hex.builtin.view.hex_editor.shortcut.cursor_start": "Move cursor to line start", + "hex.builtin.view.hex_editor.shortcut.cursor_end": "Move cursor to line end", "hex.builtin.view.hex_editor.shortcut.selection_down": "Move selection down", "hex.builtin.view.hex_editor.shortcut.cursor_down": "Move cursor down", "hex.builtin.view.hex_editor.shortcut.selection_page_up": "Move selection up one page", diff --git a/plugins/builtin/source/content/views/view_hex_editor.cpp b/plugins/builtin/source/content/views/view_hex_editor.cpp index e45832bc7..5032eb078 100644 --- a/plugins/builtin/source/content/views/view_hex_editor.cpp +++ b/plugins/builtin/source/content/views/view_hex_editor.cpp @@ -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(); diff --git a/plugins/ui/source/ui/hex_editor.cpp b/plugins/ui/source/ui/hex_editor.cpp index 7a5013194..71bef3db0 100644 --- a/plugins/ui/source/ui/hex_editor.cpp +++ b/plugins/ui/source/ui/hex_editor.cpp @@ -407,6 +407,7 @@ namespace hex::ui { m_visibleRowCount = ImGui::GetWindowSize().y / CharacterSize.y; + m_visibleRowCount = std::clamp(m_visibleRowCount, 1, numRows - m_scrollPosition); // Loop over rows for (ImS64 y = m_scrollPosition; y < (m_scrollPosition + m_visibleRowCount + 5) && y < numRows && numRows != 0; y++) {