ux: Search for strings asynchronously
This commit is contained in:
parent
a4b4360df6
commit
490c7e8fec
@ -24,7 +24,7 @@ namespace hex {
|
||||
void drawMenu() override;
|
||||
|
||||
private:
|
||||
bool m_shouldInvalidate = false;
|
||||
bool m_searching = false;
|
||||
|
||||
std::vector<FoundString> m_foundStrings;
|
||||
int m_minimumLength = 5;
|
||||
@ -33,6 +33,7 @@ namespace hex {
|
||||
std::string m_selectedString;
|
||||
std::string m_demangledName;
|
||||
|
||||
void searchStrings();
|
||||
void createStringContextMenu(const FoundString &foundString);
|
||||
};
|
||||
|
||||
|
@ -239,6 +239,7 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.view.strings.min_length", "Minimum length" },
|
||||
{ "hex.view.strings.filter", "Filter" },
|
||||
{ "hex.view.strings.extract", "Extract" },
|
||||
{ "hex.view.strings.searching", "[%c] Searching..."}
|
||||
{ "hex.view.strings.offset", "Offset" },
|
||||
{ "hex.view.strings.size", "Size" },
|
||||
{ "hex.view.strings.string", "String" },
|
||||
|
@ -4,8 +4,10 @@
|
||||
#include <hex/helpers/utils.hpp>
|
||||
|
||||
#include <cstring>
|
||||
#include <thread>
|
||||
|
||||
#include <llvm/Demangle/Demangle.h>
|
||||
#include <imgui_imhex_extensions.h>
|
||||
|
||||
using namespace std::literals::string_literals;
|
||||
|
||||
@ -43,14 +45,12 @@ namespace hex {
|
||||
}
|
||||
}
|
||||
|
||||
void ViewStrings::searchStrings() {
|
||||
this->m_foundStrings.clear();
|
||||
this->m_searching = true;
|
||||
|
||||
void ViewStrings::drawContent() {
|
||||
auto provider = SharedData::currentProvider;
|
||||
|
||||
if (this->m_shouldInvalidate) {
|
||||
this->m_shouldInvalidate = false;
|
||||
|
||||
this->m_foundStrings.clear();
|
||||
std::thread([this] {
|
||||
auto provider = SharedData::currentProvider;
|
||||
|
||||
std::vector<u8> buffer(1024, 0x00);
|
||||
u32 foundCharacters = 0;
|
||||
@ -79,17 +79,32 @@ namespace hex {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->m_searching = false;
|
||||
}).detach();
|
||||
|
||||
}
|
||||
|
||||
void ViewStrings::drawContent() {
|
||||
auto provider = SharedData::currentProvider;
|
||||
|
||||
|
||||
if (ImGui::Begin("Strings", &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
|
||||
if (ImGui::Begin("hex.view.strings.name"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
|
||||
if (provider != nullptr && provider->isReadable()) {
|
||||
if (ImGui::InputInt("hex.view.strings.min_length"_lang, &this->m_minimumLength, 1, 0))
|
||||
this->m_shouldInvalidate = true;
|
||||
ImGui::Disabled([this]{
|
||||
if (ImGui::InputInt("hex.view.strings.min_length"_lang, &this->m_minimumLength, 1, 0))
|
||||
this->m_foundStrings.clear();
|
||||
|
||||
ImGui::InputText("hex.view.strings.filter"_lang, this->m_filter.data(), this->m_filter.size());
|
||||
if (ImGui::Button("hex.view.strings.extract"_lang))
|
||||
this->searchStrings();
|
||||
}, this->m_searching);
|
||||
|
||||
if (this->m_searching) {
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("hex.view.strings.searching"_lang, "|/-\\"[u8(ImGui::GetTime() * 20) % 4]);
|
||||
}
|
||||
|
||||
ImGui::InputText("hex.view.strings.filter"_lang, this->m_filter.data(), this->m_filter.size());
|
||||
if (ImGui::Button("hex.view.strings.extract"_lang))
|
||||
this->m_shouldInvalidate = true;
|
||||
|
||||
ImGui::Separator();
|
||||
ImGui::NewLine();
|
||||
|
Loading…
x
Reference in New Issue
Block a user