mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
feat: Allow any custom content to be displayed in the command palette
This commit is contained in:
@@ -21,12 +21,14 @@ EXPORT_MODULE namespace hex {
|
||||
|
||||
namespace impl {
|
||||
|
||||
using QueryResultCallback = std::function<void(std::string)>;
|
||||
|
||||
struct QueryResult {
|
||||
std::string name;
|
||||
std::function<void(std::string)> callback;
|
||||
QueryResultCallback callback;
|
||||
};
|
||||
|
||||
using ContentDisplayCallback = std::function<void(std::string)>;
|
||||
using ContentDisplayCallback = std::function<void()>;
|
||||
using DisplayCallback = std::function<std::string(std::string)>;
|
||||
using ExecuteCallback = std::function<std::optional<std::string>(std::string)>;
|
||||
using QueryCallback = std::function<std::vector<QueryResult>(std::string)>;
|
||||
@@ -46,10 +48,15 @@ EXPORT_MODULE namespace hex {
|
||||
DisplayCallback displayCallback;
|
||||
};
|
||||
|
||||
struct ContentDisplay {
|
||||
bool showSearchBox;
|
||||
ContentDisplayCallback callback;
|
||||
};
|
||||
|
||||
const std::vector<Entry>& getEntries();
|
||||
const std::vector<Handler>& getHandlers();
|
||||
|
||||
std::optional<ContentDisplayCallback>& getDisplayedContent();
|
||||
std::optional<ContentDisplay>& getDisplayedContent();
|
||||
|
||||
}
|
||||
|
||||
@@ -86,6 +93,12 @@ EXPORT_MODULE namespace hex {
|
||||
* @param displayCallback Display callback that will be called to display the content
|
||||
*/
|
||||
void setDisplayedContent(const impl::ContentDisplayCallback &displayCallback);
|
||||
|
||||
/**
|
||||
* @brief Opens the command palette window, displaying a user defined interface
|
||||
* @param displayCallback Display callback that will be called to display the content
|
||||
*/
|
||||
void openWithContent(const impl::ContentDisplayCallback &displayCallback);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -71,34 +71,8 @@ namespace hex {
|
||||
/**
|
||||
* @brief Requests the Pattern editor to run the current code
|
||||
*
|
||||
* This is only ever used in the introduction tutorial.
|
||||
*
|
||||
* FIXME: the name is misleading, as for now this activates the pattern's auto-evaluation rather than a
|
||||
* one-off execution
|
||||
*/
|
||||
EVENT_DEF(RequestRunPatternCode);
|
||||
|
||||
/**
|
||||
* @brief Request to load a pattern language file
|
||||
*
|
||||
* FIXME: this request is unused, as now another component is responsible for pattern file loading.
|
||||
* This request should be scrapped.
|
||||
*
|
||||
* @param path the pattern file's path
|
||||
* @param bool track changes to the file on disk
|
||||
*
|
||||
*/
|
||||
EVENT_DEF(RequestLoadPatternLanguageFile, std::fs::path, bool);
|
||||
|
||||
/**
|
||||
* @brief Request to save a pattern language file
|
||||
*
|
||||
* FIXME: this request is unused, as now another component is responsible for pattern file saving.
|
||||
* This request should be scrapped.
|
||||
*
|
||||
* @param path the pattern file's path
|
||||
*/
|
||||
EVENT_DEF(RequestSavePatternLanguageFile, std::fs::path);
|
||||
EVENT_DEF(RequestTriggerPatternEvaluation);
|
||||
|
||||
/**
|
||||
* @brief Requests ImHex to open and process a file
|
||||
@@ -116,4 +90,9 @@ namespace hex {
|
||||
*/
|
||||
EVENT_DEF(RequestAddVirtualFile, std::fs::path, std::vector<u8>, Region);
|
||||
|
||||
/**
|
||||
* @brief Requests the command palette to be opened
|
||||
*/
|
||||
EVENT_DEF(RequestOpenCommandPalette);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user