From ec2a01dfaef00c3cc1ba982777a51a82d046968b Mon Sep 17 00:00:00 2001 From: WerWolv Date: Fri, 15 Aug 2025 17:30:48 +0200 Subject: [PATCH] feat: Expose tools through the command palette --- .../content/command_palette_commands.cpp | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/plugins/builtin/source/content/command_palette_commands.cpp b/plugins/builtin/source/content/command_palette_commands.cpp index 0f8668836..39a6b75f1 100644 --- a/plugins/builtin/source/content/command_palette_commands.cpp +++ b/plugins/builtin/source/content/command_palette_commands.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -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 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; }); } } \ No newline at end of file