diff --git a/lib/libimhex/include/hex/api/shortcut_manager.hpp b/lib/libimhex/include/hex/api/shortcut_manager.hpp index 3d92c0579..ddb0d975e 100644 --- a/lib/libimhex/include/hex/api/shortcut_manager.hpp +++ b/lib/libimhex/include/hex/api/shortcut_manager.hpp @@ -151,6 +151,8 @@ EXPORT_MODULE namespace hex { */ static void clearShortcuts(); + static Shortcut getShortcutByName(const std::vector &unlocalizedName, const View *view = nullptr); + static void resumeShortcuts(); static void pauseShortcuts(); diff --git a/lib/libimhex/source/api/shortcut_manager.cpp b/lib/libimhex/source/api/shortcut_manager.cpp index 8d0ff6b8f..7f0a8e9dd 100644 --- a/lib/libimhex/source/api/shortcut_manager.cpp +++ b/lib/libimhex/source/api/shortcut_manager.cpp @@ -387,6 +387,24 @@ namespace hex { s_globalShortcuts->clear(); } + Shortcut ShortcutManager::getShortcutByName(const std::vector &unlocalizedName, const View *view) { + if (view != nullptr) { + for (const auto &[shortcut, entry] : view->m_shortcuts) { + if (entry.unlocalizedName == unlocalizedName) { + return entry.shortcut; + } + } + } else { + for (const auto &[shortcut, entry] : *s_globalShortcuts) { + if (entry.unlocalizedName == unlocalizedName) { + return entry.shortcut; + } + } + } + + return Shortcut::None; + } + void ShortcutManager::resumeShortcuts() { s_paused = false; }