@@ -1741,6 +1741,8 @@ namespace hex::plugin::builtin {
1741
1741
void ViewPatternEditor::loadPatternFile (const std::fs::path &path, prv::Provider *provider) {
1742
1742
wolv::io::File file (path, wolv::io::File::Mode::Read);
1743
1743
if (file.isValid ()) {
1744
+ auto code = wolv::util::preprocessText (file.readString ());
1745
+
1744
1746
this ->evaluatePattern (code, provider);
1745
1747
m_textEditor.get (provider).SetText (code, true );
1746
1748
m_sourceCode.get (provider) = code;
@@ -1922,17 +1924,6 @@ namespace hex::plugin::builtin {
1922
1924
m_textEditor.get (provider).SetCursorPosition (coords);
1923
1925
});
1924
1926
1925
- RequestPatternEditorSetSelection::subscribe (this , [this ](u32 startLine, u32 startcolumn, u32 endLine, u32 endcolumn) {
1926
- auto provider = ImHexApi::Provider::get ();
1927
- if (startLine == 0 || endLine == 0 )
1928
- return ;
1929
-
1930
- const TextEditor::Coordinates start = { int (startLine)- 1 , int (startcolumn)-1 };
1931
- const TextEditor::Coordinates end = { int (endLine)- 1 , int (endcolumn)-1 };
1932
- m_textEditor.get (provider).SetSelection (start, end);
1933
- m_textEditor.get (provider).SetCursorPosition (end);
1934
- });
1935
-
1936
1927
RequestLoadPatternLanguageFile::subscribe (this , [this ](const std::fs::path &path) {
1937
1928
this ->loadPatternFile (path, ImHexApi::Provider::get ());
1938
1929
});
@@ -2202,38 +2193,31 @@ namespace hex::plugin::builtin {
2202
2193
if (TRY_LOCK (ContentRegistry::PatternLanguage::getRuntimeLock ())) {
2203
2194
const auto &runtime = ContentRegistry::PatternLanguage::getRuntime ();
2204
2195
2205
- std::set<pl::ptrn::Pattern*> drawnPatterns;
2206
- for (u64 offset = 0 ; offset < size; offset += 1 ) {
2207
- auto patterns = runtime.getPatternsAtAddress (address + offset);
2208
- if (!patterns.empty () && !std::ranges::all_of (patterns, [](const auto &pattern) { return pattern->getVisibility () == pl::ptrn::Visibility::Hidden || pattern->getVisibility () == pl::ptrn::Visibility::HighlightHidden; })) {
2209
- ImGui::BeginTooltip ();
2210
-
2211
- for (const auto &pattern : patterns) {
2212
- // Avoid drawing the same pattern multiple times
2213
- if (!drawnPatterns.insert (pattern).second )
2214
- continue ;
2215
-
2216
- auto visibility = pattern->getVisibility ();
2217
- if (visibility == pl::ptrn::Visibility::Hidden || visibility == pl::ptrn::Visibility::HighlightHidden)
2218
- continue ;
2219
-
2220
- const auto tooltipColor = (pattern->getColor () & 0x00FF'FFFF ) | 0x7000'0000 ;
2221
- ImGui::PushID (pattern);
2222
- if (ImGui::BeginTable (" ##tooltips" , 1 , ImGuiTableFlags_RowBg | ImGuiTableFlags_NoClip)) {
2223
- ImGui::TableNextRow ();
2224
- ImGui::TableNextColumn ();
2225
-
2226
- this ->drawPatternTooltip (pattern);
2227
-
2228
- ImGui::PushStyleColor (ImGuiCol_TableRowBg, tooltipColor);
2229
- ImGui::PushStyleColor (ImGuiCol_TableRowBgAlt, tooltipColor);
2230
- ImGui::EndTable ();
2231
- ImGui::PopStyleColor (2 );
2232
- }
2233
- ImGui::PopID ();
2196
+ auto patterns = runtime.getPatternsAtAddress (address);
2197
+ if (!patterns.empty () && !std::ranges::all_of (patterns, [](const auto &pattern) { return pattern->getVisibility () == pl::ptrn::Visibility::Hidden || pattern->getVisibility () == pl::ptrn::Visibility::HighlightHidden; })) {
2198
+ ImGui::BeginTooltip ();
2199
+
2200
+ for (const auto &pattern : patterns) {
2201
+ auto visibility = pattern->getVisibility ();
2202
+ if (visibility == pl::ptrn::Visibility::Hidden || visibility == pl::ptrn::Visibility::HighlightHidden)
2203
+ continue ;
2204
+
2205
+ const auto tooltipColor = (pattern->getColor () & 0x00FF'FFFF ) | 0x7000'0000 ;
2206
+ ImGui::PushID (pattern);
2207
+ if (ImGui::BeginTable (" ##tooltips" , 1 , ImGuiTableFlags_RowBg | ImGuiTableFlags_NoClip)) {
2208
+ ImGui::TableNextRow ();
2209
+ ImGui::TableNextColumn ();
2210
+
2211
+ this ->drawPatternTooltip (pattern);
2212
+
2213
+ ImGui::PushStyleColor (ImGuiCol_TableRowBg, tooltipColor);
2214
+ ImGui::PushStyleColor (ImGuiCol_TableRowBgAlt, tooltipColor);
2215
+ ImGui::EndTable ();
2216
+ ImGui::PopStyleColor (2 );
2234
2217
}
2235
- ImGui::EndTooltip ();
2218
+ ImGui::PopID ();
2236
2219
}
2220
+ ImGui::EndTooltip ();
2237
2221
}
2238
2222
}
2239
2223
});
0 commit comments