mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
ux: Added undo and redo option
This commit is contained in:
@@ -131,8 +131,8 @@ namespace hex::prv {
|
||||
std::memcpy(buffer, reinterpret_cast<u8*>(this->m_mappedFile) + PageSize * this->m_currPage + offset, size);
|
||||
|
||||
for (u64 i = 0; i < size; i++)
|
||||
if (this->m_patches.back().contains(offset + i))
|
||||
reinterpret_cast<u8*>(buffer)[i] = this->m_patches.back()[offset + PageSize * this->m_currPage + i];
|
||||
if (getPatches().contains(offset + i))
|
||||
reinterpret_cast<u8*>(buffer)[i] = getPatches()[offset + PageSize * this->m_currPage + i];
|
||||
|
||||
if (overlays)
|
||||
this->applyOverlays(offset, buffer, size);
|
||||
@@ -142,10 +142,7 @@ namespace hex::prv {
|
||||
if ((offset + size) > this->getSize() || buffer == nullptr || size == 0)
|
||||
return;
|
||||
|
||||
this->m_patches.push_back(this->m_patches.back());
|
||||
|
||||
for (u64 i = 0; i < size; i++)
|
||||
this->m_patches.back()[offset + this->getBaseAddress() + i] = reinterpret_cast<const u8*>(buffer)[i];
|
||||
addPatch(offset, buffer, size);
|
||||
}
|
||||
|
||||
void FileProvider::readRaw(u64 offset, void *buffer, size_t size) {
|
||||
|
||||
@@ -508,6 +508,12 @@ namespace hex {
|
||||
saveAs();
|
||||
return true;
|
||||
} else if (mods == GLFW_MOD_CONTROL && key == 'Z') {
|
||||
if (SharedData::currentProvider != nullptr)
|
||||
SharedData::currentProvider->undo();
|
||||
} else if (mods == GLFW_MOD_CONTROL && key == 'Y') {
|
||||
if (SharedData::currentProvider != nullptr)
|
||||
SharedData::currentProvider->redo();
|
||||
} else if (mods == GLFW_MOD_CONTROL && key == 'F') {
|
||||
View::doLater([]{ ImGui::OpenPopup("hex.view.hexeditor.menu.file.search"_lang); });
|
||||
return true;
|
||||
} else if (mods == GLFW_MOD_CONTROL && key == 'G') {
|
||||
@@ -1060,6 +1066,11 @@ R"(
|
||||
}
|
||||
|
||||
void ViewHexEditor::drawEditPopup() {
|
||||
if (ImGui::MenuItem("hex.view.hexeditor.menu.edit.undo", "CTRL + Z", false, SharedData::currentProvider != nullptr))
|
||||
SharedData::currentProvider->undo();
|
||||
if (ImGui::MenuItem("hex.view.hexeditor.menu.edit.redo", "CTRL + Y", false, SharedData::currentProvider != nullptr))
|
||||
SharedData::currentProvider->redo();
|
||||
|
||||
if (ImGui::BeginMenu("hex.view.hexeditor.menu.edit.copy"_lang, this->m_memoryEditor.DataPreviewAddr != -1 && this->m_memoryEditor.DataPreviewAddrEnd != -1)) {
|
||||
if (ImGui::MenuItem("hex.view.hexeditor.copy.bytes"_lang, "CTRL + ALT + C"))
|
||||
this->copyBytes();
|
||||
|
||||
Reference in New Issue
Block a user