2022-07-30 22:01:49 +02:00
|
|
|
#include <hex/api/keybinding.hpp>
|
|
|
|
#include <hex/api/event.hpp>
|
|
|
|
|
2022-09-26 11:49:35 +02:00
|
|
|
#include <hex/providers/provider.hpp>
|
2022-11-25 10:47:11 +01:00
|
|
|
#include "content/global_actions.hpp"
|
2022-09-26 11:49:35 +02:00
|
|
|
|
2022-07-30 22:01:49 +02:00
|
|
|
namespace hex::plugin::builtin {
|
|
|
|
|
|
|
|
void registerShortcuts() {
|
2022-08-28 20:55:48 +02:00
|
|
|
// New file
|
2023-01-17 08:16:02 +01:00
|
|
|
ShortcutManager::addGlobalShortcut(CTRLCMD + Keys::N, [] {
|
2022-08-28 20:55:48 +02:00
|
|
|
EventManager::post<RequestOpenWindow>("Create File");
|
|
|
|
});
|
|
|
|
|
2022-07-30 22:01:49 +02:00
|
|
|
// Open file
|
2023-01-17 08:16:02 +01:00
|
|
|
ShortcutManager::addGlobalShortcut(CTRLCMD + Keys::O, [] {
|
2022-08-28 20:55:48 +02:00
|
|
|
EventManager::post<RequestOpenWindow>("Open File");
|
2022-07-30 22:01:49 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
// Close file
|
2023-01-17 08:16:02 +01:00
|
|
|
ShortcutManager::addGlobalShortcut(CTRLCMD + Keys::W, [] {
|
2022-09-26 11:49:35 +02:00
|
|
|
if (ImHexApi::Provider::isValid())
|
|
|
|
ImHexApi::Provider::remove(ImHexApi::Provider::get());
|
|
|
|
});
|
|
|
|
|
|
|
|
// Reload file
|
2023-01-17 08:16:02 +01:00
|
|
|
ShortcutManager::addGlobalShortcut(CTRLCMD + Keys::R, [] {
|
2022-09-26 11:49:35 +02:00
|
|
|
if (ImHexApi::Provider::isValid()) {
|
|
|
|
auto provider = ImHexApi::Provider::get();
|
|
|
|
|
|
|
|
provider->close();
|
|
|
|
if (!provider->open())
|
|
|
|
ImHexApi::Provider::remove(provider, true);
|
|
|
|
}
|
2022-07-30 22:01:49 +02:00
|
|
|
});
|
2022-11-25 10:47:11 +01:00
|
|
|
|
|
|
|
// Save project
|
|
|
|
ShortcutManager::addGlobalShortcut(ALT + Keys::S, [] {
|
|
|
|
saveProject();
|
|
|
|
});
|
|
|
|
|
|
|
|
// Save project as...
|
|
|
|
ShortcutManager::addGlobalShortcut(ALT + SHIFT + Keys::S, [] {
|
|
|
|
saveProjectAs();
|
|
|
|
});
|
2022-07-30 22:01:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|