mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
sys: Added select region command
This commit is contained in:
@@ -181,8 +181,8 @@ namespace hex {
|
||||
|
||||
static constexpr auto CTRL = Key(static_cast<Keys>(0x1000'0000));
|
||||
static constexpr auto ALT = Key(static_cast<Keys>(0x2000'0000));
|
||||
static constexpr auto SHIFT = Key(static_cast<Keys>(0x3000'0000));
|
||||
static constexpr auto SUPER = Key(static_cast<Keys>(0x4000'0000));
|
||||
static constexpr auto SHIFT = Key(static_cast<Keys>(0x4000'0000));
|
||||
static constexpr auto SUPER = Key(static_cast<Keys>(0x8000'0000));
|
||||
|
||||
class ShortcutManager {
|
||||
public:
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "math_evaluator.hpp"
|
||||
|
||||
#include <imgui_internal.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <thread>
|
||||
|
||||
@@ -20,8 +19,8 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void draw(ViewHexEditor *editor) override {
|
||||
ImGui::TextUnformatted("hex.builtin.view.hex_editor.menu.file.goto"_lang);
|
||||
if (ImGui::BeginTabBar("hex.builtin.view.hex_editor.goto.offset.absolute"_lang)) {
|
||||
if (ImGui::BeginTabItem("Absolute")) {
|
||||
if (ImGui::BeginTabBar("goto_tabs")) {
|
||||
if (ImGui::BeginTabItem("hex.builtin.view.hex_editor.goto.offset.absolute"_lang)) {
|
||||
this->m_mode = Mode::Absolute;
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
@@ -95,6 +94,53 @@ namespace hex::plugin::builtin {
|
||||
MathEvaluator<i128> m_evaluator;
|
||||
};
|
||||
|
||||
class PopupSelect : public ViewHexEditor::Popup {
|
||||
public:
|
||||
|
||||
void draw(ViewHexEditor *editor) override {
|
||||
ImGui::TextUnformatted("hex.builtin.view.hex_editor.menu.file.select"_lang);
|
||||
if (ImGui::BeginTabBar("select_tabs")) {
|
||||
|
||||
if (ImGui::BeginTabItem("hex.builtin.view.hex_editor.select.offset.region"_lang)) {
|
||||
u64 inputA = this->m_region.getStartAddress();
|
||||
u64 inputB = this->m_region.getEndAddress();
|
||||
ImGui::InputHexadecimal("hex.builtin.view.hex_editor.select.offset.begin"_lang, &inputA, ImGuiInputTextFlags_AutoSelectAll);
|
||||
ImGui::InputHexadecimal("hex.builtin.view.hex_editor.select.offset.end"_lang, &inputB, ImGuiInputTextFlags_AutoSelectAll);
|
||||
|
||||
if (inputB < inputA)
|
||||
inputB = inputA;
|
||||
|
||||
this->m_region = { inputA, (inputB - inputA) + 1 };
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui::BeginTabItem("hex.builtin.view.hex_editor.select.offset.size"_lang)) {
|
||||
u64 inputA = this->m_region.getStartAddress();
|
||||
u64 inputB = this->m_region.getSize();
|
||||
ImGui::InputHexadecimal("hex.builtin.view.hex_editor.select.offset.begin"_lang, &inputA, ImGuiInputTextFlags_AutoSelectAll);
|
||||
ImGui::InputHexadecimal("hex.builtin.view.hex_editor.select.offset.size"_lang, &inputB, ImGuiInputTextFlags_AutoSelectAll);
|
||||
|
||||
if (inputB <= 0)
|
||||
inputB = 1;
|
||||
|
||||
this->m_region = { inputA, inputB };
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui::Button("hex.builtin.view.hex_editor.select.select"_lang) || (ImGui::IsItemFocused() && (ImGui::IsKeyPressed(ImGuiKey_Enter) || ImGui::IsKeyPressed(ImGuiKey_Enter)))) {
|
||||
editor->setSelection(this->m_region.getStartAddress(), this->m_region.getEndAddress());
|
||||
editor->jumpToSelection();
|
||||
}
|
||||
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Region m_region = { 0, 1 };
|
||||
};
|
||||
|
||||
class PopupFind : public ViewHexEditor::Popup {
|
||||
public:
|
||||
void draw(ViewHexEditor *editor) override {
|
||||
@@ -252,7 +298,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::TextUnformatted("hex.builtin.view.hex_editor.menu.edit.set_base"_lang);
|
||||
|
||||
ImGui::InputHexadecimal("##base_address", &this->m_baseAddress);
|
||||
if (ImGui::IsItemFocused() && ImGui::IsKeyPressed(ImGuiKey_Enter)) {
|
||||
if (ImGui::IsItemFocused() && (ImGui::IsKeyPressed(ImGuiKey_Enter) || ImGui::IsKeyPressed(ImGuiKey_Enter))) {
|
||||
setBaseAddress(this->m_baseAddress);
|
||||
editor->closePopup();
|
||||
}
|
||||
@@ -285,7 +331,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::TextUnformatted("hex.builtin.view.hex_editor.menu.edit.resize"_lang);
|
||||
|
||||
ImGui::InputHexadecimal("##resize", &this->m_size);
|
||||
if (ImGui::IsItemFocused() && ImGui::IsKeyPressed(ImGuiKey_Enter)) {
|
||||
if (ImGui::IsItemFocused() && (ImGui::IsKeyPressed(ImGuiKey_Enter) || ImGui::IsKeyPressed(ImGuiKey_Enter))) {
|
||||
resize(static_cast<size_t>(this->m_size));
|
||||
editor->closePopup();
|
||||
}
|
||||
@@ -1137,6 +1183,12 @@ namespace hex::plugin::builtin {
|
||||
this->setSelection(size_t(0), ImHexApi::Provider::get()->getActualSize());
|
||||
});
|
||||
|
||||
// Select range
|
||||
ShortcutManager::addShortcut(this, CTRL + SHIFT + Keys::A, [this] {
|
||||
if (ImHexApi::Provider::isValid())
|
||||
this->openPopup<PopupSelect>();
|
||||
});
|
||||
|
||||
// Remove selection
|
||||
ShortcutManager::addShortcut(this, Keys::Escape, [this] {
|
||||
this->m_selectionStart = InvalidSelection;
|
||||
@@ -1393,6 +1445,10 @@ namespace hex::plugin::builtin {
|
||||
if (ImGui::MenuItem("hex.builtin.view.hex_editor.menu.file.goto"_lang, "CTRL + G", false, providerValid)) {
|
||||
this->openPopup<PopupGoto>();
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hex_editor.menu.file.select"_lang, "CTRL + SHIFT + A", false, providerValid)) {
|
||||
this->openPopup<PopupSelect>();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -269,6 +269,12 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.view.hex_editor.goto.offset.current", "Momentan" },
|
||||
{ "hex.builtin.view.hex_editor.goto.offset.begin", "Beginn" },
|
||||
{ "hex.builtin.view.hex_editor.goto.offset.end", "Ende" },
|
||||
{ "hex.builtin.view.hex_editor.menu.file.select", "Auswählen" },
|
||||
{ "hex.builtin.view.hex_editor.select.offset.region", "Region" },
|
||||
{ "hex.builtin.view.hex_editor.select.offset.begin", "Beginn" },
|
||||
{ "hex.builtin.view.hex_editor.select.offset.end", "Ende" },
|
||||
{ "hex.builtin.view.hex_editor.select.offset.size", "Grösse" },
|
||||
{ "hex.builtin.view.hex_editor.select.select", "Select" },
|
||||
{ "hex.builtin.view.hex_editor.file.save", "Speichern" },
|
||||
{ "hex.builtin.view.hex_editor.file.save_as", "Speichern unter..." },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.copy", "Kopieren" },
|
||||
|
||||
@@ -271,6 +271,12 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.view.hex_editor.goto.offset.relative", "Relative" },
|
||||
{ "hex.builtin.view.hex_editor.goto.offset.begin", "Begin" },
|
||||
{ "hex.builtin.view.hex_editor.goto.offset.end", "End" },
|
||||
{ "hex.builtin.view.hex_editor.menu.file.select", "Select" },
|
||||
{ "hex.builtin.view.hex_editor.select.offset.region", "Region" },
|
||||
{ "hex.builtin.view.hex_editor.select.offset.begin", "Begin" },
|
||||
{ "hex.builtin.view.hex_editor.select.offset.end", "End" },
|
||||
{ "hex.builtin.view.hex_editor.select.offset.size", "Size" },
|
||||
{ "hex.builtin.view.hex_editor.select.select", "Select" },
|
||||
{ "hex.builtin.view.hex_editor.menu.file.save", "Save" },
|
||||
{ "hex.builtin.view.hex_editor.menu.file.save_as", "Save As..." },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.copy", "Copy" },
|
||||
|
||||
@@ -272,6 +272,12 @@ namespace hex::plugin::builtin {
|
||||
//{ "hex.builtin.view.hex_editor.goto.offset.current", "Relative" },
|
||||
{ "hex.builtin.view.hex_editor.goto.offset.begin", "Inizo" },
|
||||
{ "hex.builtin.view.hex_editor.goto.offset.end", "Fine" },
|
||||
//{ "hex.builtin.view.hex_editor.menu.file.select", "Select" },
|
||||
// { "hex.builtin.view.hex_editor.select.offset.region", "Region" },
|
||||
// { "hex.builtin.view.hex_editor.select.offset.begin", "Begin" },
|
||||
// { "hex.builtin.view.hex_editor.select.offset.end", "End" },
|
||||
// { "hex.builtin.view.hex_editor.select.offset.size", "Size" },
|
||||
// { "hex.builtin.view.hex_editor.select.select", "Select" },
|
||||
{ "hex.builtin.view.hex_editor.menu.file.save", "Salva" },
|
||||
{ "hex.builtin.view.hex_editor.menu.file.save_as", "Salva come..." },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.copy", "Copia" },
|
||||
|
||||
@@ -271,6 +271,12 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.view.hex_editor.goto.offset.relative", "相対アドレス" },
|
||||
{ "hex.builtin.view.hex_editor.goto.offset.begin", "開始" }, //?
|
||||
{ "hex.builtin.view.hex_editor.goto.offset.end", "終了" }, //?
|
||||
//{ "hex.builtin.view.hex_editor.menu.file.select", "Select" },
|
||||
// { "hex.builtin.view.hex_editor.select.offset.region", "Region" },
|
||||
// { "hex.builtin.view.hex_editor.select.offset.begin", "Begin" },
|
||||
// { "hex.builtin.view.hex_editor.select.offset.end", "End" },
|
||||
// { "hex.builtin.view.hex_editor.select.offset.size", "Size" },
|
||||
// { "hex.builtin.view.hex_editor.select.select", "Select" },
|
||||
{ "hex.builtin.view.hex_editor.menu.file.save", "保存" },
|
||||
{ "hex.builtin.view.hex_editor.menu.file.save_as", "名前をつけて保存…" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.copy", "コピー" },
|
||||
|
||||
@@ -269,6 +269,12 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.view.hex_editor.goto.offset.relative", "Relativo" },
|
||||
{ "hex.builtin.view.hex_editor.goto.offset.begin", "Começo" },
|
||||
{ "hex.builtin.view.hex_editor.goto.offset.end", "Fim" },
|
||||
//{ "hex.builtin.view.hex_editor.menu.file.select", "Select" },
|
||||
// { "hex.builtin.view.hex_editor.select.offset.region", "Region" },
|
||||
// { "hex.builtin.view.hex_editor.select.offset.begin", "Begin" },
|
||||
// { "hex.builtin.view.hex_editor.select.offset.end", "End" },
|
||||
// { "hex.builtin.view.hex_editor.select.offset.size", "Size" },
|
||||
// { "hex.builtin.view.hex_editor.select.select", "Select" },
|
||||
{ "hex.builtin.view.hex_editor.menu.file.save", "Salvar" },
|
||||
{ "hex.builtin.view.hex_editor.menu.file.save_as", "Salvar como..." },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.copy", "Copiar" },
|
||||
|
||||
@@ -272,6 +272,12 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.view.hex_editor.goto.offset.relative", "相对" },
|
||||
{ "hex.builtin.view.hex_editor.goto.offset.begin", "起始" },
|
||||
{ "hex.builtin.view.hex_editor.goto.offset.end", "末尾" },
|
||||
//{ "hex.builtin.view.hex_editor.menu.file.select", "Select" },
|
||||
// { "hex.builtin.view.hex_editor.select.offset.region", "Region" },
|
||||
// { "hex.builtin.view.hex_editor.select.offset.begin", "Begin" },
|
||||
// { "hex.builtin.view.hex_editor.select.offset.end", "End" },
|
||||
// { "hex.builtin.view.hex_editor.select.offset.size", "Size" },
|
||||
// { "hex.builtin.view.hex_editor.select.select", "Select" },
|
||||
{ "hex.builtin.view.hex_editor.menu.file.save", "保存" },
|
||||
{ "hex.builtin.view.hex_editor.menu.file.save_as", "另存为..." },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.copy", "复制" },
|
||||
|
||||
@@ -269,6 +269,12 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.view.hex_editor.goto.offset.relative", "相對" },
|
||||
{ "hex.builtin.view.hex_editor.goto.offset.begin", "開始" },
|
||||
{ "hex.builtin.view.hex_editor.goto.offset.end", "結束" },
|
||||
//{ "hex.builtin.view.hex_editor.menu.file.select", "Select" },
|
||||
// { "hex.builtin.view.hex_editor.select.offset.region", "Region" },
|
||||
// { "hex.builtin.view.hex_editor.select.offset.begin", "Begin" },
|
||||
// { "hex.builtin.view.hex_editor.select.offset.end", "End" },
|
||||
// { "hex.builtin.view.hex_editor.select.offset.size", "Size" },
|
||||
// { "hex.builtin.view.hex_editor.select.select", "Select" },
|
||||
{ "hex.builtin.view.hex_editor.menu.file.save", "儲存" },
|
||||
{ "hex.builtin.view.hex_editor.menu.file.save_as", "另存為..." },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.copy", "複製" },
|
||||
|
||||
Reference in New Issue
Block a user