1
0
mirror of synced 2024-09-24 19:48:25 +02:00

impr: Added various new events

This commit is contained in:
WerWolv 2023-04-06 17:36:28 +02:00
parent 7c18ad49ae
commit c73f33aac2
8 changed files with 28 additions and 4 deletions

View File

@ -156,10 +156,17 @@ namespace hex {
EVENT_DEF(EventProviderClosing, prv::Provider *, bool *);
EVENT_DEF(EventProviderClosed, prv::Provider *);
EVENT_DEF(EventProviderDeleted, prv::Provider *);
EVENT_DEF(EventProviderSaved, prv::Provider *);
EVENT_DEF(EventFrameBegin);
EVENT_DEF(EventFrameEnd);
EVENT_DEF(EventWindowInitialized);
EVENT_DEF(EventSetTaskBarIconState, u32, u32, u32);
EVENT_DEF(EventBookmarkCreated, ImHexApi::Bookmarks::Entry&);
EVENT_DEF(EventPatchCreated, u64, u8, u8);
EVENT_DEF(EventPatternExecuted, const std::string&);
EVENT_DEF(EventPatternEditorChanged, const std::string&);
EVENT_DEF(EventStoreContentDownloaded, const std::fs::path&);
EVENT_DEF(EventStoreContentRemoved, const std::fs::path&);
EVENT_DEF(RequestOpenWindow, std::string);
EVENT_DEF(RequestSelectionChange, Region);

View File

@ -35,7 +35,9 @@ namespace hex::prv {
this->markDirty();
}
void Provider::save() { }
void Provider::save() {
EventManager::post<EventProviderSaved>(this);
}
void Provider::saveAs(const std::fs::path &path) {
wolv::io::File file(path, wolv::io::File::Mode::Create);
@ -56,8 +58,9 @@ namespace hex::prv {
this->read(offset + this->getBaseAddress(), buffer.data(), bufferSize, true);
file.writeBuffer(buffer.data(), bufferSize);
}
EventManager::post<EventProviderSaved>(this);
}
}
@ -222,9 +225,12 @@ namespace hex::prv {
getPatches().erase(offset + i);
else
getPatches()[offset + i] = patch;
EventManager::post<EventPatchCreated>(offset, originalValue, patch);
}
this->markDirty();
}
void Provider::createUndoPoint() {

View File

@ -52,7 +52,7 @@ namespace hex::plugin::builtin {
});
}
};
if (provider == nullptr) {
success = false;
continue;

View File

@ -83,6 +83,7 @@ namespace hex::plugin::builtin {
void FileProvider::save() {
this->applyPatches();
Provider::save();
}
void FileProvider::saveAs(const std::fs::path &path) {

View File

@ -219,6 +219,7 @@ namespace hex::plugin::builtin {
void GDBProvider::save() {
this->applyPatches();
Provider::save();
}
size_t GDBProvider::getActualSize() const {

View File

@ -36,6 +36,8 @@ namespace hex::plugin::builtin {
});
ImHexApi::Provider::markDirty();
EventManager::post<EventBookmarkCreated>(ProviderExtraData::getCurrent().bookmarks.back());
});
ImHexApi::HexEditor::addBackgroundHighlightingProvider([](u64 address, const u8* data, size_t size, bool) -> std::optional<color_t> {

View File

@ -181,8 +181,10 @@ namespace hex::plugin::builtin {
if (this->m_hasUnevaluatedChanges && this->m_runningEvaluators == 0 && this->m_runningParsers == 0) {
this->m_hasUnevaluatedChanges = false;
auto code = this->m_textEditor.GetText();
EventManager::post<EventPatternEditorChanged>(code);
TaskManager::createBackgroundTask("Pattern Parsing", [this, code = this->m_textEditor.GetText(), provider](auto &){
TaskManager::createBackgroundTask("Pattern Parsing", [this, code, provider](auto &){
this->parsePattern(code, provider);
if (this->m_runAutomatically)
@ -697,6 +699,7 @@ namespace hex::plugin::builtin {
ContentRegistry::PatternLanguage::configureRuntime(*patternLanguage.runtime, provider);
EventManager::post<EventHighlightingChanged>();
EventManager::post<EventPatternExecuted>(code);
TaskManager::createTask("hex.builtin.view.pattern_editor.evaluating", TaskManager::NoProgress, [this, &patternLanguage, code](auto &task) {
std::scoped_lock lock(patternLanguage.runtimeMutex);

View File

@ -99,6 +99,9 @@ namespace hex::plugin::builtin {
if (entry.isFolder) {
Tar tar(this->m_downloadPath, Tar::Mode::Read);
tar.extractAll(this->m_downloadPath.parent_path() / this->m_downloadPath.stem());
EventManager::post<EventStoreContentDownloaded>(this->m_downloadPath.parent_path() / this->m_downloadPath.stem());
} else {
EventManager::post<EventStoreContentDownloaded>(this->m_downloadPath);
}
downloadDoneCallback();
@ -286,6 +289,7 @@ namespace hex::plugin::builtin {
wolv::io::fs::removeAll(folderPath);
removed = removed && !wolv::io::fs::exists(filePath) && !wolv::io::fs::exists(folderPath);
EventManager::post<EventStoreContentRemoved>(filePath);
}
return removed;