Skip to content

Commit 790487e

Browse files
committed
impr: If there's multiple foreground highlighting providers, only evaluate until a color is found
1 parent eb83354 commit 790487e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

plugins/builtin/source/content/views/view_hex_editor.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ namespace hex::plugin::builtin {
6060

6161
std::optional<color_t> result;
6262
for (const auto &[id, callback] : ImHexApi::HexEditor::impl::getForegroundHighlightingFunctions()) {
63-
if (auto color = callback(address, data, size, result.has_value()); color.has_value())
63+
if (auto color = callback(address, data, size, result.has_value()); color.has_value()) {
6464
result = color;
65+
break;
66+
}
6567
}
6668

6769
if (!result.has_value()) {

plugins/builtin/source/content/views/view_highlight_rules.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ namespace hex::plugin::builtin {
181181
// Draw a table containing all the existing highlighting rules
182182
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))) {
183183
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthStretch, 1);
184-
ImGui::TableSetupColumn("Enabled", ImGuiTableColumnFlags_WidthFixed, 10_scaled);
184+
ImGui::TableSetupColumn("Enabled", ImGuiTableColumnFlags_WidthFixed, 15_scaled);
185185

186186
for (auto it = m_rules->begin(); it != m_rules->end(); ++it) {
187187
auto &rule = *it;
@@ -197,6 +197,9 @@ namespace hex::plugin::builtin {
197197
}
198198
ImGui::EndDisabled();
199199

200+
if (m_selectedRule == it && !rule.enabled)
201+
m_selectedRule = m_rules->end();
202+
200203
// Draw enabled checkbox
201204
ImGui::TableNextColumn();
202205
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2());

0 commit comments

Comments
 (0)