ui: Add result count to string view (#353)
* Add result count to string view * Localization * formating and logic fix
This commit is contained in:
parent
e8bc94a25a
commit
0da31b6bbb
@ -285,6 +285,7 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.view.strings.filter", "Filter" },
|
||||
{ "hex.view.strings.extract", "Extrahieren" },
|
||||
{ "hex.view.strings.regex_error", "Ungültiges Regex" },
|
||||
{ "hex.view.strings.results", "{0} Ergebnisse" },
|
||||
{ "hex.view.strings.searching", "Suchen..." },
|
||||
{ "hex.view.strings.offset", "Offset" },
|
||||
{ "hex.view.strings.size", "Grösse" },
|
||||
|
@ -288,6 +288,7 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.view.strings.filter", "Filter" },
|
||||
{ "hex.view.strings.extract", "Extract" },
|
||||
{ "hex.view.strings.regex_error", "Invalid regex" },
|
||||
{ "hex.view.strings.results", "Found {0} occurrences" },
|
||||
{ "hex.view.strings.searching", "Searching..." },
|
||||
{ "hex.view.strings.offset", "Offset" },
|
||||
{ "hex.view.strings.size", "Size" },
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "views/view_strings.hpp"
|
||||
|
||||
#include <hex/providers/provider.hpp>
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
|
||||
#include <cstring>
|
||||
#include <thread>
|
||||
@ -116,17 +117,17 @@ namespace hex {
|
||||
}
|
||||
}
|
||||
for (u64 i = 0; i < view.m_foundStrings.size(); i++) {
|
||||
if(view.m_regex){
|
||||
if (view.m_regex) {
|
||||
if(view.m_pattern_parsed && std::regex_search(readString(view.m_foundStrings[i]), pattern))
|
||||
view.m_filterIndices.push_back(i);
|
||||
}
|
||||
else if(readString(view.m_foundStrings[i]).find(data->Buf) != std::string::npos) {
|
||||
else if (readString(view.m_foundStrings[i]).find(data->Buf) != std::string::npos) {
|
||||
view.m_filterIndices.push_back(i);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}, this);
|
||||
if(this->m_regex && !this->m_pattern_parsed){
|
||||
if (this->m_regex && !this->m_pattern_parsed) {
|
||||
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "hex.view.strings.regex_error"_lang);
|
||||
}
|
||||
|
||||
@ -138,6 +139,10 @@ namespace hex {
|
||||
ImGui::SameLine();
|
||||
ImGui::TextSpinner("hex.view.strings.searching"_lang);
|
||||
}
|
||||
else if (this->m_foundStrings.size() > 0) {
|
||||
ImGui::SameLine();
|
||||
ImGui::TextUnformatted(hex::format("hex.view.strings.results"_lang, this->m_filterIndices.size()).c_str());
|
||||
}
|
||||
|
||||
|
||||
ImGui::Separator();
|
||||
|
Loading…
x
Reference in New Issue
Block a user