diff --git a/lib/external/pattern_language b/lib/external/pattern_language index f33fc83ce..661ecab43 160000 --- a/lib/external/pattern_language +++ b/lib/external/pattern_language @@ -1 +1 @@ -Subproject commit f33fc83cedb1e74bd4f583c90ff77b397e7b5c03 +Subproject commit 661ecab439922a923bb6ce1c01546044983d3bac diff --git a/main/source/init/splash_window.cpp b/main/source/init/splash_window.cpp index a113d6190..4926dd3a1 100644 --- a/main/source/init/splash_window.cpp +++ b/main/source/init/splash_window.cpp @@ -173,12 +173,12 @@ namespace hex::init { auto meanScale = std::midpoint(xScale, yScale); -// On Macs with a retina display (basically all modern ones we care about), the OS reports twice -// the actual monitor scale for some obscure reason. Get rid of this here so ImHex doesn't look -// extremely huge with native scaling on macOS. -#if defined(OS_MACOS) - meanScale /= 2; -#endif + // On Macs with a retina display (basically all modern ones we care about), the OS reports twice + // the actual monitor scale for some obscure reason. Get rid of this here so ImHex doesn't look + // extremely huge with native scaling on macOS. + #if defined(OS_MACOS) + meanScale /= 2; + #endif if (meanScale <= 0.0) { meanScale = 1.0; diff --git a/plugins/builtin/source/content/views/view_pattern_editor.cpp b/plugins/builtin/source/content/views/view_pattern_editor.cpp index 51fe0bd34..3361bf06f 100644 --- a/plugins/builtin/source/content/views/view_pattern_editor.cpp +++ b/plugins/builtin/source/content/views/view_pattern_editor.cpp @@ -230,43 +230,39 @@ namespace hex::plugin::builtin { }); - ImHexApi::HexEditor::addBackgroundHighlightingProvider([](u64 address, const u8 *data, size_t size) -> std::optional { + ImHexApi::HexEditor::addBackgroundHighlightingProvider([this](u64 address, const u8 *data, size_t size) -> std::optional { hex::unused(data, size); - const auto &patterns = ImHexApi::Provider::get()->getPatternLanguageRuntime().getPatterns(); - for (const auto &pattern : patterns) { - auto child = pattern->getPattern(address); - if (child != nullptr) { - return child->getColor(); - } - } + if (this->m_runningEvaluators != 0) + return std::nullopt; - return std::nullopt; + const auto pattern = ImHexApi::Provider::get()->getPatternLanguageRuntime().getPattern(address, size); + if (pattern != nullptr) + return pattern->getColor(); + else + return std::nullopt; }); ImHexApi::HexEditor::addTooltipProvider([this](u64 address, const u8 *data, size_t size) { hex::unused(data, size); - auto &patterns = ImHexApi::Provider::get()->getPatternLanguageRuntime().getPatterns(); - for (auto &pattern : patterns) { - auto child = pattern->getPattern(address); - if (child != nullptr) { - ImGui::BeginTooltip(); + auto pattern = ImHexApi::Provider::get()->getPatternLanguageRuntime().getPattern(address); + if (pattern != nullptr) { + ImGui::BeginTooltip(); - if (ImGui::BeginTable("##tooltips", 1, ImGuiTableFlags_NoHostExtendX | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoClip)) { - ImGui::TableNextRow(); - ImGui::TableNextColumn(); + if (ImGui::BeginTable("##tooltips", 1, ImGuiTableFlags_NoHostExtendX | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoClip)) { + ImGui::TableNextRow(); + ImGui::TableNextColumn(); - this->drawPatternTooltip(child); + this->drawPatternTooltip(pattern); - auto tooltipColor = (child->getColor() & 0x00FF'FFFF) | 0x7000'0000; - ImGui::PushStyleColor(ImGuiCol_TableRowBg, tooltipColor); - ImGui::PushStyleColor(ImGuiCol_TableRowBgAlt, tooltipColor); - ImGui::EndTable(); - ImGui::PopStyleColor(2); - } - ImGui::EndTooltip(); + auto tooltipColor = (pattern->getColor() & 0x00FF'FFFF) | 0x7000'0000; + ImGui::PushStyleColor(ImGuiCol_TableRowBg, tooltipColor); + ImGui::PushStyleColor(ImGuiCol_TableRowBgAlt, tooltipColor); + ImGui::EndTable(); + ImGui::PopStyleColor(2); } + ImGui::EndTooltip(); } }); } @@ -787,6 +783,8 @@ namespace hex::plugin::builtin { this->m_lastEvaluationError = runtime.getError(); } + runtime.flattenPatterns(); + this->m_lastEvaluationLog = runtime.getConsoleLog(); this->m_lastEvaluationOutVars = runtime.getOutVariables(); this->m_runningEvaluators--;