From 4a916ebb890e22e0201069d1915ef5af4cef6d50 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Tue, 14 Jan 2025 17:49:48 +0100 Subject: [PATCH] feat: Added New File option to the GNOME launcher and a --new cli option --- dist/imhex.desktop | 6 ++++++ .../builtin/include/content/command_line_interface.hpp | 1 + plugins/builtin/source/content/command_line_interface.cpp | 8 ++++++++ plugins/builtin/source/plugin_builtin.cpp | 1 + 4 files changed, 16 insertions(+) diff --git a/dist/imhex.desktop b/dist/imhex.desktop index d02f96f11..a6d4b816d 100644 --- a/dist/imhex.desktop +++ b/dist/imhex.desktop @@ -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 \ No newline at end of file diff --git a/plugins/builtin/include/content/command_line_interface.hpp b/plugins/builtin/include/content/command_line_interface.hpp index c29c063fd..579bb8e4e 100644 --- a/plugins/builtin/include/content/command_line_interface.hpp +++ b/plugins/builtin/include/content/command_line_interface.hpp @@ -12,6 +12,7 @@ namespace hex::plugin::builtin { void handleVerboseCommand(const std::vector &args); void handleOpenCommand(const std::vector &args); + void handleNewCommand(const std::vector &args); void handleCalcCommand(const std::vector &args); void handleHashCommand(const std::vector &args); diff --git a/plugins/builtin/source/content/command_line_interface.cpp b/plugins/builtin/source/content/command_line_interface.cpp index 94575f1d2..2688d035a 100644 --- a/plugins/builtin/source/content/command_line_interface.cpp +++ b/plugins/builtin/source/content/command_line_interface.cpp @@ -116,6 +116,10 @@ namespace hex::plugin::builtin { hex::subcommands::forwardSubCommand("open", fullPaths); } + void handleNewCommand(const std::vector &) { + hex::subcommands::forwardSubCommand("new", {}); + } + void handleCalcCommand(const std::vector &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 &){ + RequestOpenWindow::post("Create File"); + }); } } \ No newline at end of file diff --git a/plugins/builtin/source/plugin_builtin.cpp b/plugins/builtin/source/plugin_builtin.cpp index 84ab23253..040881d46 100644 --- a/plugins/builtin/source/plugin_builtin.cpp +++ b/plugins/builtin/source/plugin_builtin.cpp @@ -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 },