1
0
mirror of synced 2024-11-28 17:40:51 +01:00

feat: Allow hex editor editing mode to be entered when pressing Enter

This commit is contained in:
WerWolv 2023-07-16 18:14:48 +02:00
parent 709f4b7e80
commit 893b06c78b
2 changed files with 19 additions and 0 deletions

View File

@ -183,6 +183,20 @@ namespace hex::plugin::builtin::ui {
this->m_scrollPosition = scrollPosition; this->m_scrollPosition = scrollPosition;
} }
void setEditingAddress(u64 address) {
this->m_editingAddress = address;
this->m_shouldModifyValue = false;
this->m_enteredEditingMode = true;
this->m_editingBytes.resize(this->m_currDataVisualizer->getBytesPerCell());
this->m_provider->read(address + this->m_provider->getBaseAddress(), this->m_editingBytes.data(), this->m_editingBytes.size());
this->m_editingCellType = CellType::Hex;
}
void clearEditingAddress() {
this->m_editingAddress = std::nullopt;
}
private: private:
prv::Provider *m_provider; prv::Provider *m_provider;

View File

@ -708,6 +708,11 @@ namespace hex::plugin::builtin {
EventManager::post<EventRegionSelected>(ImHexApi::HexEditor::ProviderRegion{ this->getSelection(), provider }); EventManager::post<EventRegionSelected>(ImHexApi::HexEditor::ProviderRegion{ this->getSelection(), provider });
}); });
ShortcutManager::addShortcut(this, Keys::Enter, [this] {
if (auto cursor = this->m_hexEditor.getCursorPosition(); cursor.has_value())
this->m_hexEditor.setEditingAddress(cursor.value());
});
// Move cursor around // Move cursor around
ShortcutManager::addShortcut(this, Keys::Up, [this] { ShortcutManager::addShortcut(this, Keys::Up, [this] {
auto selection = getSelection(); auto selection = getSelection();