Skip to content

Commit

Permalink
feat: Added Disassemble selection option to the Edit menu
Browse files Browse the repository at this point in the history
  • Loading branch information
WerWolv committed Dec 9, 2024
1 parent cb6b74b commit 1e71d8a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/builtin/romfs/lang/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"hex.builtin.menu.file.clear_recent": "Clear",
"hex.builtin.menu.file.close": "Close",
"hex.builtin.menu.file.create_file": "New File...",
"hex.builtin.menu.edit.disassemble_range": "Disassemble selection",
"hex.builtin.menu.file.export": "Export...",
"hex.builtin.menu.file.export.as_language": "Text Formatted Bytes",
"hex.builtin.menu.file.export.as_language.popup.export_error": "Failed to export bytes to the file!",
Expand Down
13 changes: 13 additions & 0 deletions plugins/disassembler/source/content/views/view_disassembler.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "content/views/view_disassembler.hpp"
#include "hex/api/content_registry.hpp"

#include <hex/providers/provider.hpp>
#include <hex/helpers/fmt.hpp>
Expand All @@ -16,6 +17,18 @@ namespace hex::plugin::disasm {
EventProviderDeleted::subscribe(this, [this](const auto*) {
m_disassembly.clear();
});

ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.menu.edit.disassemble_range" }, ICON_VS_DEBUG_LINE_BY_LINE, 3100, CTRLCMD + SHIFT + Keys::D, [this] {
ImGui::SetWindowFocus(this->getName().c_str());
this->getWindowOpenState() = true;

m_range = ui::RegionType::Region;
m_codeRegion = ImHexApi::HexEditor::getSelection()->getRegion();

this->disassemble();
}, [this]{
return ImHexApi::HexEditor::isSelectionValid() && !this->m_disassemblerTask.isRunning();
});
}

ViewDisassembler::~ViewDisassembler() {
Expand Down

0 comments on commit 1e71d8a

Please sign in to comment.