mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 05:05:19 -05:00
feat: Expose tools through the command palette
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include <hex/api/imhex_api/hex_editor.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/api/content_registry/command_palette.hpp>
|
||||
#include <hex/api/content_registry/tools.hpp>
|
||||
#include <hex/api/content_registry/settings.hpp>
|
||||
#include <hex/api/content_registry/user_interface.hpp>
|
||||
#include <hex/api/content_registry/views.hpp>
|
||||
@@ -441,6 +442,27 @@ namespace hex::plugin::builtin {
|
||||
return fmt::format("Focus {} View", input.data());
|
||||
});
|
||||
|
||||
ContentRegistry::CommandPalette::addHandler(
|
||||
ContentRegistry::CommandPalette::Type::KeywordCommand,
|
||||
"/tool",
|
||||
[](const auto &input) {
|
||||
std::vector<ContentRegistry::CommandPalette::impl::QueryResult> result;
|
||||
|
||||
for (const auto &toolEntry : ContentRegistry::Tools::impl::getEntries()) {
|
||||
const auto name = Lang(toolEntry.unlocalizedName);
|
||||
if (!hex::containsIgnoreCase(name, input) && !std::string("/tool").contains(input))
|
||||
continue;
|
||||
|
||||
result.emplace_back(name, [&toolEntry](const auto &) {
|
||||
ContentRegistry::CommandPalette::setDisplayedContent([&toolEntry](const auto) {
|
||||
toolEntry.function();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
[](const auto &input) { return input; });
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user