mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-01-24 21:49:21 -06:00
fix: Some shortcuts triggering twice
This commit is contained in:
@@ -24,7 +24,6 @@ add_library(${PROJECT_NAME} SHARED
|
||||
source/content/data_visualizers.cpp
|
||||
source/content/events.cpp
|
||||
source/content/hashes.cpp
|
||||
source/content/shortcuts.cpp
|
||||
source/content/global_actions.cpp
|
||||
source/content/themes.cpp
|
||||
|
||||
|
||||
@@ -39,12 +39,10 @@ namespace hex::plugin::builtin {
|
||||
void FileProvider::read(u64 offset, void *buffer, size_t size, bool overlays) {
|
||||
this->readRaw(offset - this->getBaseAddress(), buffer, size);
|
||||
|
||||
if (overlays) {
|
||||
if (auto &patches = this->getPatches(); !patches.empty()) {
|
||||
for (const auto&[patchOffset, patchData] : patches) {
|
||||
if (patchOffset >= offset && patchOffset <= (offset + size))
|
||||
reinterpret_cast<u8 *>(buffer)[patchOffset] = patchData;
|
||||
}
|
||||
if (overlays) [[likely]] {
|
||||
for (const auto&[patchOffset, patchData] : getPatches()) {
|
||||
if (patchOffset >= offset && patchOffset <= (offset + size))
|
||||
reinterpret_cast<u8 *>(buffer)[patchOffset - offset] = patchData;
|
||||
}
|
||||
|
||||
this->applyOverlays(offset, buffer, size);
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
#include <hex/api/keybinding.hpp>
|
||||
#include <hex/api/event.hpp>
|
||||
|
||||
#include <hex/providers/provider.hpp>
|
||||
#include "content/global_actions.hpp"
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
void registerShortcuts() {
|
||||
// New file
|
||||
ShortcutManager::addGlobalShortcut(CTRLCMD + Keys::N, [] {
|
||||
EventManager::post<RequestOpenWindow>("Create File");
|
||||
});
|
||||
|
||||
// Open file
|
||||
ShortcutManager::addGlobalShortcut(CTRLCMD + Keys::O, [] {
|
||||
EventManager::post<RequestOpenWindow>("Open File");
|
||||
});
|
||||
|
||||
// Close file
|
||||
ShortcutManager::addGlobalShortcut(CTRLCMD + Keys::W, [] {
|
||||
if (ImHexApi::Provider::isValid())
|
||||
ImHexApi::Provider::remove(ImHexApi::Provider::get());
|
||||
});
|
||||
|
||||
// Reload file
|
||||
ShortcutManager::addGlobalShortcut(CTRLCMD + Keys::R, [] {
|
||||
if (ImHexApi::Provider::isValid()) {
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
|
||||
provider->close();
|
||||
if (!provider->open())
|
||||
ImHexApi::Provider::remove(provider, true);
|
||||
}
|
||||
});
|
||||
|
||||
// Save project
|
||||
ShortcutManager::addGlobalShortcut(ALT + Keys::S, [] {
|
||||
saveProject();
|
||||
});
|
||||
|
||||
// Save project as...
|
||||
ShortcutManager::addGlobalShortcut(ALT + SHIFT + Keys::S, [] {
|
||||
saveProjectAs();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -672,25 +672,6 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
void ViewHexEditor::registerShortcuts() {
|
||||
// Save operations
|
||||
ShortcutManager::addShortcut(this, CTRLCMD + Keys::S, [] {
|
||||
save();
|
||||
});
|
||||
ShortcutManager::addShortcut(this, CTRLCMD + SHIFT + Keys::S, [] {
|
||||
saveAs();
|
||||
});
|
||||
|
||||
// Select All
|
||||
ShortcutManager::addShortcut(this, CTRLCMD + Keys::A, [this] {
|
||||
if (ImHexApi::Provider::isValid())
|
||||
this->setSelection(size_t(0), ImHexApi::Provider::get()->getActualSize());
|
||||
});
|
||||
|
||||
// Select range
|
||||
ShortcutManager::addShortcut(this, CTRLCMD + SHIFT + Keys::A, [this] {
|
||||
if (ImHexApi::Provider::isValid())
|
||||
this->openPopup<PopupSelect>();
|
||||
});
|
||||
|
||||
// Remove selection
|
||||
ShortcutManager::addShortcut(this, Keys::Escape, [this] {
|
||||
@@ -856,48 +837,7 @@ namespace hex::plugin::builtin {
|
||||
this->m_hexEditor.jumpIfOffScreen();
|
||||
});
|
||||
|
||||
ShortcutManager::addShortcut(this, CTRLCMD + Keys::G, [this] {
|
||||
if (!ImHexApi::Provider::isValid()) return;
|
||||
|
||||
this->openPopup<PopupGoto>();
|
||||
});
|
||||
ShortcutManager::addShortcut(this, CTRLCMD + Keys::F, [this] {
|
||||
if (!ImHexApi::Provider::isValid()) return;
|
||||
|
||||
this->openPopup<PopupFind>();
|
||||
});
|
||||
|
||||
// Copy
|
||||
ShortcutManager::addShortcut(this, CTRLCMD + Keys::C, [this] {
|
||||
const auto selection = getSelection();
|
||||
copyBytes(selection);
|
||||
});
|
||||
ShortcutManager::addShortcut(this, CTRLCMD + SHIFT + Keys::C, [this] {
|
||||
const auto selection = getSelection();
|
||||
copyString(selection);
|
||||
});
|
||||
|
||||
// Paste
|
||||
ShortcutManager::addShortcut(this, CTRLCMD + Keys::V, [this] {
|
||||
const auto selection = getSelection();
|
||||
pasteBytes(selection, true);
|
||||
});
|
||||
|
||||
// Paste and resize
|
||||
ShortcutManager::addShortcut(this, CTRLCMD + SHIFT + Keys::V, [this] {
|
||||
const auto selection = getSelection();
|
||||
pasteBytes(selection, false);
|
||||
});
|
||||
|
||||
// Undo / Redo
|
||||
ShortcutManager::addShortcut(this, CTRLCMD + Keys::Z, [] {
|
||||
if (ImHexApi::Provider::isValid())
|
||||
ImHexApi::Provider::get()->undo();
|
||||
});
|
||||
ShortcutManager::addShortcut(this, CTRLCMD + Keys::Y, [] {
|
||||
if (ImHexApi::Provider::isValid())
|
||||
ImHexApi::Provider::get()->redo();
|
||||
});
|
||||
// Redo shortcut alternative
|
||||
ShortcutManager::addShortcut(this, CTRLCMD + SHIFT + Keys::Z, [] {
|
||||
if (ImHexApi::Provider::isValid())
|
||||
ImHexApi::Provider::get()->redo();
|
||||
@@ -959,7 +899,7 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
ProjectFile::registerPerProviderHandler({
|
||||
.basePath = "custom_encoding.json",
|
||||
.basePath = "custom_encoding.tbl",
|
||||
.required = false,
|
||||
.load = [this](prv::Provider *, const std::fs::path &basePath, Tar &tar) {
|
||||
this->m_hexEditor.setCustomEncoding(EncodingFile(hex::EncodingFile::Type::Thingy, tar.readString(basePath)));
|
||||
|
||||
@@ -26,7 +26,6 @@ namespace hex::plugin::builtin {
|
||||
void registerMainMenuEntries();
|
||||
void createWelcomeScreen();
|
||||
void registerViews();
|
||||
void registerShortcuts();
|
||||
void registerThemeHandlers();
|
||||
void registerStyleHandlers();
|
||||
void registerThemes();
|
||||
@@ -63,7 +62,6 @@ IMHEX_PLUGIN_SETUP("Built-in", "WerWolv", "Default ImHex functionality") {
|
||||
registerDataFormatters();
|
||||
createWelcomeScreen();
|
||||
registerViews();
|
||||
registerShortcuts();
|
||||
registerThemeHandlers();
|
||||
registerStyleHandlers();
|
||||
registerThemes();
|
||||
|
||||
Reference in New Issue
Block a user