1
0
mirror of synced 2025-01-22 11:33:46 +01:00

feat: Added New File option to the GNOME launcher and a --new cli option

This commit is contained in:
WerWolv 2025-01-14 17:49:48 +01:00
parent 1c305ca762
commit 4a916ebb89
4 changed files with 16 additions and 0 deletions

6
dist/imhex.desktop vendored
View File

@ -1,4 +1,5 @@
[Desktop Entry]
Version=1.0
Name=ImHex
Comment=ImHex Hex Editor
GenericName=Hex Editor
@ -10,3 +11,8 @@ Categories=Development;IDE;
StartupWMClass=imhex
Keywords=static-analysis;reverse-engineering;disassembler;disassembly;hacking;forensics;hex-editor;cybersecurity;security;binary-analysis;
MimeType=application/vnd.imhex.proj;
Actions=NewFile;
[Desktop Action NewFile]
Exec=imhex --new
Name=Create New File

View File

@ -12,6 +12,7 @@ namespace hex::plugin::builtin {
void handleVerboseCommand(const std::vector<std::string> &args);
void handleOpenCommand(const std::vector<std::string> &args);
void handleNewCommand(const std::vector<std::string> &args);
void handleCalcCommand(const std::vector<std::string> &args);
void handleHashCommand(const std::vector<std::string> &args);

View File

@ -116,6 +116,10 @@ namespace hex::plugin::builtin {
hex::subcommands::forwardSubCommand("open", fullPaths);
}
void handleNewCommand(const std::vector<std::string> &) {
hex::subcommands::forwardSubCommand("new", {});
}
void handleCalcCommand(const std::vector<std::string> &args) {
if (args.empty()) {
hex::log::println("No expression provided!");
@ -386,6 +390,10 @@ namespace hex::plugin::builtin {
RequestOpenFile::post(arg);
}
});
hex::subcommands::registerSubCommand("new", [](const std::vector<std::string> &){
RequestOpenWindow::post("Create File");
});
}
}

View File

@ -66,6 +66,7 @@ IMHEX_PLUGIN_SUBCOMMANDS() {
{ "verbose", "v", "Enables verbose debug logging", hex::plugin::builtin::handleVerboseCommand },
{ "open", "o", "Open files passed as argument. [default]", hex::plugin::builtin::handleOpenCommand },
{ "new", "n", "Create a new empty file", hex::plugin::builtin::handleNewCommand },
{ "calc", "", "Evaluate a mathematical expression", hex::plugin::builtin::handleCalcCommand },
{ "hash", "", "Calculate the hash of a file", hex::plugin::builtin::handleHashCommand },