feat: Allow switching to other providers through command palette
This commit is contained in:
parent
f666751f5f
commit
2d92858193
@ -1,12 +1,15 @@
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/imhex_api.hpp>
|
||||
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/api/shortcut_manager.hpp>
|
||||
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
#include <hex/providers/provider.hpp>
|
||||
|
||||
#include <wolv/math_eval/math_evaluator.hpp>
|
||||
#include <wolv/utils/guards.hpp>
|
||||
#include <wolv/utils/string.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
@ -312,6 +315,32 @@ namespace hex::plugin::builtin {
|
||||
return hex::format("Menu Item: {}", input.data());
|
||||
});
|
||||
|
||||
ContentRegistry::CommandPaletteCommands::addHandler(
|
||||
ContentRegistry::CommandPaletteCommands::Type::SymbolCommand,
|
||||
".",
|
||||
[](const auto &input) {
|
||||
std::vector<ContentRegistry::CommandPaletteCommands::impl::QueryResult> result;
|
||||
|
||||
u32 index = 0;
|
||||
for (const auto &provider : ImHexApi::Provider::getProviders()) {
|
||||
ON_SCOPE_EXIT { index += 1; };
|
||||
|
||||
auto name = provider->getName();
|
||||
if (!hex::containsIgnoreCase(name, input))
|
||||
continue;
|
||||
|
||||
result.emplace_back(ContentRegistry::CommandPaletteCommands::impl::QueryResult {
|
||||
provider->getName(),
|
||||
[&provider, index](const auto&) { ImHexApi::Provider::setCurrentProvider(index); }
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
[](auto input) {
|
||||
return hex::format("Provider: {}", input.data());
|
||||
});
|
||||
|
||||
ContentRegistry::CommandPaletteCommands::add(
|
||||
ContentRegistry::CommandPaletteCommands::Type::SymbolCommand,
|
||||
"%",
|
||||
|
Loading…
x
Reference in New Issue
Block a user