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-07-30 22:01:49 +02:00
|
|
|
namespace hex::plugin::builtin {
|
|
|
|
|
|
|
|
void registerShortcuts() {
|
2022-08-28 20:55:48 +02:00
|
|
|
// New file
|
|
|
|
ShortcutManager::addGlobalShortcut(CTRL + Keys::N, [] {
|
|
|
|
EventManager::post<RequestOpenWindow>("Create File");
|
|
|
|
});
|
|
|
|
|
2022-07-30 22:01:49 +02:00
|
|
|
// Open file
|
|
|
|
ShortcutManager::addGlobalShortcut(CTRL + 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
|
|
|
|
ShortcutManager::addGlobalShortcut(CTRL + Keys::W, [] {
|
2022-09-26 11:49:35 +02:00
|
|
|
if (ImHexApi::Provider::isValid())
|
|
|
|
ImHexApi::Provider::remove(ImHexApi::Provider::get());
|
|
|
|
});
|
|
|
|
|
|
|
|
// Reload file
|
|
|
|
ShortcutManager::addGlobalShortcut(CTRL + Keys::R, [] {
|
|
|
|
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
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|