mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-01 21:17:44 -05:00
Various fixes and improvements
This commit is contained in:
@@ -19,6 +19,9 @@ namespace hex {
|
||||
ViewHexEditor::ViewHexEditor(std::vector<lang::PatternData*> &patternData)
|
||||
: View("hex.view.hexeditor.title"_lang), m_patternData(patternData) {
|
||||
|
||||
this->m_searchStringBuffer.resize(0xFFF, 0x00);
|
||||
this->m_searchHexBuffer.resize(0xFFF, 0x00);
|
||||
|
||||
this->m_memoryEditor.ReadFn = [](const ImU8 *data, size_t off) -> ImU8 {
|
||||
auto provider = SharedData::currentProvider;
|
||||
if (!provider->isAvailable() || !provider->isReadable())
|
||||
@@ -952,13 +955,13 @@ R"(
|
||||
if (ImGui::BeginPopupContextVoid("hex.view.hexeditor.menu.file.search"_lang)) {
|
||||
ImGui::TextUnformatted("hex.view.hexeditor.menu.file.search"_lang);
|
||||
if (ImGui::BeginTabBar("searchTabs")) {
|
||||
char *currBuffer;
|
||||
std::vector<char> *currBuffer = nullptr;
|
||||
if (ImGui::BeginTabItem("hex.view.hexeditor.search.string"_lang)) {
|
||||
this->m_searchFunction = findString;
|
||||
this->m_lastSearchBuffer = &this->m_lastStringSearch;
|
||||
currBuffer = this->m_searchStringBuffer;
|
||||
currBuffer = &this->m_searchStringBuffer;
|
||||
|
||||
ImGui::InputText("##nolabel", currBuffer, 0xFFFF, ImGuiInputTextFlags_CallbackCompletion,
|
||||
ImGui::InputText("##nolabel", currBuffer->data(), currBuffer->size(), ImGuiInputTextFlags_CallbackCompletion,
|
||||
InputCallback, this);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
@@ -966,25 +969,27 @@ R"(
|
||||
if (ImGui::BeginTabItem("hex.view.hexeditor.search.hex"_lang)) {
|
||||
this->m_searchFunction = findHex;
|
||||
this->m_lastSearchBuffer = &this->m_lastHexSearch;
|
||||
currBuffer = this->m_searchHexBuffer;
|
||||
currBuffer = &this->m_searchHexBuffer;
|
||||
|
||||
ImGui::InputText("##nolabel", currBuffer, 0xFFFF,
|
||||
ImGui::InputText("##nolabel", currBuffer->data(), currBuffer->size(),
|
||||
ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CallbackCompletion,
|
||||
InputCallback, this);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui::Button("hex.view.hexeditor.search.find"_lang))
|
||||
Find(currBuffer);
|
||||
if (currBuffer != nullptr) {
|
||||
if (ImGui::Button("hex.view.hexeditor.search.find"_lang))
|
||||
Find(currBuffer->data());
|
||||
|
||||
if (this->m_lastSearchBuffer->size() > 0) {
|
||||
if ((ImGui::Button("hex.view.hexeditor.search.find_next"_lang)))
|
||||
FindNext();
|
||||
if (this->m_lastSearchBuffer->size() > 0) {
|
||||
if ((ImGui::Button("hex.view.hexeditor.search.find_next"_lang)))
|
||||
FindNext();
|
||||
|
||||
ImGui::SameLine();
|
||||
ImGui::SameLine();
|
||||
|
||||
if ((ImGui::Button("hex.view.hexeditor.search.find_prev"_lang)))
|
||||
FindPrevious();
|
||||
if ((ImGui::Button("hex.view.hexeditor.search.find_prev"_lang)))
|
||||
FindPrevious();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndTabBar();
|
||||
|
||||
@@ -16,13 +16,11 @@ namespace hex {
|
||||
this->m_foundStrings.clear();
|
||||
});
|
||||
|
||||
this->m_filter = new char[0xFFFF];
|
||||
std::memset(this->m_filter, 0x00, 0xFFFF);
|
||||
this->m_filter.resize(0xFFFF, 0x00);
|
||||
}
|
||||
|
||||
ViewStrings::~ViewStrings() {
|
||||
View::unsubscribeEvent(Events::DataChanged);
|
||||
delete[] this->m_filter;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +87,7 @@ namespace hex {
|
||||
if (ImGui::InputInt("hex.view.strings.min_length"_lang, &this->m_minimumLength, 1, 0))
|
||||
this->m_shouldInvalidate = true;
|
||||
|
||||
ImGui::InputText("hex.view.strings.filter"_lang, this->m_filter, 0xFFFF);
|
||||
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;
|
||||
|
||||
@@ -109,17 +107,17 @@ namespace hex {
|
||||
if (sortSpecs->SpecsDirty) {
|
||||
std::sort(this->m_foundStrings.begin(), this->m_foundStrings.end(),
|
||||
[&sortSpecs](FoundString &left, FoundString &right) -> bool {
|
||||
if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("hex.view.strings.offset"_lang)) {
|
||||
if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("offset")) {
|
||||
if (sortSpecs->Specs->SortDirection == ImGuiSortDirection_Ascending)
|
||||
return left.offset > right.offset;
|
||||
else
|
||||
return left.offset < right.offset;
|
||||
} else if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("hex.view.strings.size"_lang)) {
|
||||
} else if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("size")) {
|
||||
if (sortSpecs->Specs->SortDirection == ImGuiSortDirection_Ascending)
|
||||
return left.size > right.size;
|
||||
else
|
||||
return left.size < right.size;
|
||||
} else if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("hex.view.strings.string"_lang)) {
|
||||
} else if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("string")) {
|
||||
if (sortSpecs->Specs->SortDirection == ImGuiSortDirection_Ascending)
|
||||
return left.string > right.string;
|
||||
else
|
||||
@@ -141,8 +139,8 @@ namespace hex {
|
||||
for (u64 i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
||||
auto &foundString = this->m_foundStrings[i];
|
||||
|
||||
if (strlen(this->m_filter) != 0 &&
|
||||
foundString.string.find(this->m_filter) == std::string::npos)
|
||||
if (strlen(this->m_filter.data()) != 0 &&
|
||||
foundString.string.find(this->m_filter.data()) == std::string::npos)
|
||||
continue;
|
||||
|
||||
ImGui::TableNextRow();
|
||||
@@ -172,7 +170,7 @@ namespace hex {
|
||||
|
||||
if (ImGui::BeginPopup("hex.view.strings.demangle.title"_lang)) {
|
||||
if (ImGui::BeginChild("##scrolling", ImVec2(500, 150))) {
|
||||
ImGui::Text("hex.view.strings.demangle.title"_lang);
|
||||
ImGui::TextUnformatted("hex.view.strings.demangle.title"_lang);
|
||||
ImGui::Separator();
|
||||
ImGui::TextWrapped("%s", this->m_demangledName.c_str());
|
||||
ImGui::EndChild();
|
||||
|
||||
Reference in New Issue
Block a user