mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
feat: Added all menu items to command palette
This commit is contained in:
@@ -95,8 +95,14 @@ namespace hex {
|
||||
KeywordCommand
|
||||
};
|
||||
|
||||
struct QueryResult {
|
||||
std::string name;
|
||||
std::function<void(std::string)> callback;
|
||||
};
|
||||
|
||||
using DisplayCallback = std::function<std::string(std::string)>;
|
||||
using ExecuteCallback = std::function<void(std::string)>;
|
||||
using QueryCallback = std::function<std::vector<QueryResult>(std::string)>;
|
||||
|
||||
struct Entry {
|
||||
Type type;
|
||||
@@ -106,13 +112,28 @@ namespace hex {
|
||||
ExecuteCallback executeCallback;
|
||||
};
|
||||
|
||||
struct Handler {
|
||||
Type type;
|
||||
std::string command;
|
||||
QueryCallback queryCallback;
|
||||
DisplayCallback displayCallback;
|
||||
};
|
||||
|
||||
void add(
|
||||
Type type,
|
||||
const std::string &command,
|
||||
const std::string &unlocalizedDescription,
|
||||
const DisplayCallback &displayCallback,
|
||||
const ExecuteCallback &executeCallback = [](auto) {});
|
||||
|
||||
void addHandler(
|
||||
Type type,
|
||||
const std::string &command,
|
||||
const QueryCallback &queryCallback,
|
||||
const DisplayCallback &displayCallback);
|
||||
|
||||
std::vector<Entry> &getEntries();
|
||||
std::vector<Handler> &getHandlers();
|
||||
}
|
||||
|
||||
/* Pattern Language Function Registry. Allows adding of new functions that may be used inside the pattern language */
|
||||
|
||||
@@ -220,12 +220,24 @@ namespace hex {
|
||||
getEntries().push_back(ContentRegistry::CommandPaletteCommands::Entry { type, command, unlocalizedDescription, displayCallback, executeCallback });
|
||||
}
|
||||
|
||||
void addHandler(Type type, const std::string &command, const QueryCallback &queryCallback, const DisplayCallback &displayCallback) {
|
||||
log::debug("Registered new command palette command handler: {}", command);
|
||||
|
||||
getHandlers().push_back(ContentRegistry::CommandPaletteCommands::Handler { type, command, queryCallback, displayCallback });
|
||||
}
|
||||
|
||||
std::vector<Entry> &getEntries() {
|
||||
static std::vector<Entry> commands;
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
std::vector<Handler> &getHandlers() {
|
||||
static std::vector<Handler> commands;
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user