feat: Added goto command palette command

This commit is contained in:
WerWolv
2025-07-30 20:21:26 +02:00
parent 896e05331c
commit ec9461741c
2 changed files with 30 additions and 0 deletions

View File

@@ -73,6 +73,8 @@
"hex.builtin.command.convert.as": "as",
"hex.builtin.command.cmd.desc": "Command",
"hex.builtin.command.cmd.result": "Run command '{0}'",
"hex.builtin.command.goto.desc": "Goto specific address",
"hex.builtin.command.goto.result": "Goto address 0x{0:08X}",
"hex.builtin.command.web.desc": "Website lookup",
"hex.builtin.command.web.result": "Navigate to '{0}'",
"hex.builtin.drag_drop.text": "Drop files here to open them...",

View File

@@ -278,6 +278,34 @@ namespace hex::plugin::builtin {
}
});
ContentRegistry::CommandPaletteCommands::add(
ContentRegistry::CommandPaletteCommands::Type::SymbolCommand,
"@",
"hex.builtin.command.goto.desc",
[](auto input) {
wolv::math_eval::MathEvaluator<long double> evaluator;
evaluator.registerStandardVariables();
evaluator.registerStandardFunctions();
std::optional<long double> result = evaluator.evaluate(input);
if (result.has_value())
return hex::format("hex.builtin.command.goto.result"_lang, result.value());
else if (evaluator.hasError())
return hex::format("Error: {}", *evaluator.getLastError());
else
return std::string("???");
}, [](auto input) -> std::optional<std::string> {
wolv::math_eval::MathEvaluator<long double> evaluator;
evaluator.registerStandardVariables();
evaluator.registerStandardFunctions();
std::optional<long double> result = evaluator.evaluate(input);
if (result.has_value()) {
ImHexApi::HexEditor::setSelection(result.value(), 1);
}
return std::nullopt;
});
ContentRegistry::CommandPaletteCommands::add(
ContentRegistry::CommandPaletteCommands::Type::KeywordCommand,
"/web",