mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
feat: Added goto command palette command
This commit is contained in:
@@ -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...",
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user