mirror of https://github.com/WerWolv/ImHex.git
fix: Hex editor selection moving with shift + arrow keys not working correctly
This commit is contained in:
parent
116aeede2d
commit
c238767750
|
@ -30,7 +30,7 @@ namespace hex::plugin::builtin {
|
|||
|
||||
public:
|
||||
void setSelection(const Region ®ion) { this->setSelection(region.getStartAddress(), region.getEndAddress()); }
|
||||
void setSelection(i128 start, i128 end) {
|
||||
void setSelection(u128 start, u128 end) {
|
||||
if (!ImHexApi::Provider::isValid())
|
||||
return;
|
||||
if (start == InvalidSelection && end == InvalidSelection)
|
||||
|
@ -45,8 +45,8 @@ namespace hex::plugin::builtin {
|
|||
|
||||
this->m_selectionChanged = this->m_selectionStart != start || this->m_selectionEnd != end;
|
||||
|
||||
this->m_selectionStart = std::clamp<decltype(start)>(start, 0, maxAddress);
|
||||
this->m_selectionEnd = std::clamp<decltype(end)>(end, 0, maxAddress);
|
||||
this->m_selectionStart = std::clamp<u128>(start, 0, maxAddress);
|
||||
this->m_selectionEnd = std::clamp<u128>(end, 0, maxAddress);
|
||||
|
||||
if (this->m_selectionChanged) {
|
||||
EventManager::post<EventRegionSelected>(this->getSelection());
|
||||
|
|
|
@ -1158,23 +1158,42 @@ namespace hex::plugin::builtin {
|
|||
|
||||
// Move selection around
|
||||
ShortcutManager::addShortcut(this, SHIFT + Keys::Up, [this] {
|
||||
this->setSelection(this->m_selectionEnd - this->m_bytesPerRow, this->m_selectionEnd);
|
||||
this->m_selectionStart = std::max<u64>(this->m_selectionStart, this->m_bytesPerRow);
|
||||
|
||||
this->setSelection(this->m_selectionStart - this->m_bytesPerRow, this->m_selectionEnd);
|
||||
this->scrollToSelection();
|
||||
this->jumpIfOffScreen();
|
||||
});
|
||||
ShortcutManager::addShortcut(this, SHIFT + Keys::Down, [this] {
|
||||
this->setSelection(this->m_selectionEnd + this->m_bytesPerRow, this->m_selectionEnd);
|
||||
this->setSelection(this->m_selectionStart + this->m_bytesPerRow, this->m_selectionEnd);
|
||||
this->scrollToSelection();
|
||||
this->jumpIfOffScreen();
|
||||
|
||||
});
|
||||
ShortcutManager::addShortcut(this, SHIFT + Keys::Left, [this] {
|
||||
this->setSelection(this->m_selectionEnd - 1, this->m_selectionEnd);
|
||||
this->m_selectionStart = std::max<u64>(this->m_selectionStart, 1);
|
||||
|
||||
this->setSelection(this->m_selectionStart - 1, this->m_selectionEnd);
|
||||
this->scrollToSelection();
|
||||
this->jumpIfOffScreen();
|
||||
});
|
||||
ShortcutManager::addShortcut(this, SHIFT + Keys::Right, [this] {
|
||||
this->setSelection(this->m_selectionEnd + 1, this->m_selectionEnd);
|
||||
this->setSelection(this->m_selectionStart + 1, this->m_selectionEnd);
|
||||
this->scrollToSelection();
|
||||
this->jumpIfOffScreen();
|
||||
});
|
||||
ShortcutManager::addShortcut(this, Keys::PageUp, [this] {
|
||||
u64 visibleByteCount = this->m_bytesPerRow * this->m_visibleRowCount;
|
||||
if (this->m_selectionEnd >= visibleByteCount) {
|
||||
auto pos = this->m_selectionEnd - visibleByteCount;
|
||||
this->setSelection(pos, this->m_selectionEnd);
|
||||
this->scrollToSelection();
|
||||
this->jumpIfOffScreen();
|
||||
}
|
||||
});
|
||||
ShortcutManager::addShortcut(this, Keys::PageDown, [this] {
|
||||
auto pos = this->m_selectionEnd + (this->m_bytesPerRow * this->m_visibleRowCount);
|
||||
this->setSelection(pos, this->m_selectionEnd);
|
||||
this->scrollToSelection();
|
||||
this->jumpIfOffScreen();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue