impr: If there's multiple foreground highlighting providers, only evaluate until a color is found

(cherry picked from commit 790487eea6)
This commit is contained in:
WerWolv 2025-12-07 20:48:16 +01:00
parent 358f961f50
commit 59afa06bf4
2 changed files with 7 additions and 2 deletions

View File

@ -60,8 +60,10 @@ namespace hex::plugin::builtin {
std::optional<color_t> result;
for (const auto &[id, callback] : ImHexApi::HexEditor::impl::getForegroundHighlightingFunctions()) {
if (auto color = callback(address, data, size, result.has_value()); color.has_value())
if (auto color = callback(address, data, size, result.has_value()); color.has_value()) {
result = color;
break;
}
}
if (!result.has_value()) {

View File

@ -181,7 +181,7 @@ namespace hex::plugin::builtin {
// Draw a table containing all the existing highlighting rules
if (ImGui::BeginTable("RulesList", 2, ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersInnerH | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_ScrollY, ImGui::GetContentRegionAvail() - ImVec2(0, ImGui::GetTextLineHeightWithSpacing() + ImGui::GetStyle().WindowPadding.y))) {
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthStretch, 1);
ImGui::TableSetupColumn("Enabled", ImGuiTableColumnFlags_WidthFixed, 10_scaled);
ImGui::TableSetupColumn("Enabled", ImGuiTableColumnFlags_WidthFixed, 15_scaled);
for (auto it = m_rules->begin(); it != m_rules->end(); ++it) {
auto &rule = *it;
@ -197,6 +197,9 @@ namespace hex::plugin::builtin {
}
ImGui::EndDisabled();
if (m_selectedRule == it && !rule.enabled)
m_selectedRule = m_rules->end();
// Draw enabled checkbox
ImGui::TableNextColumn();
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2());