diff --git a/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h b/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h index c0c2baf47..46d24299c 100644 --- a/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h +++ b/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h @@ -235,11 +235,13 @@ namespace ImGuiExt { inline void TextFormattedWrappedSelectable(std::string_view fmt, auto &&...args) { // Manually wrap text, using the letter M (generally the widest character in non-monospaced fonts) to calculate the character width to use. - auto text = wolv::util::wrapMonospacedString( + auto text = wolv::util::trim(wolv::util::wrapMonospacedString( hex::format(fmt, std::forward(args)...), ImGui::CalcTextSize("M").x, ImGui::GetContentRegionAvail().x - ImGui::GetStyle().ScrollbarSize - ImGui::GetStyle().FrameBorderSize - ); + )); + + auto textSize = ImGui::CalcTextSize(text.c_str()); ImGui::PushID(text.c_str()); @@ -251,7 +253,7 @@ namespace ImGuiExt { "##", const_cast(text.c_str()), text.size(), - ImVec2(0, -FLT_MIN), + ImVec2(0, textSize.y), ImGuiInputTextFlags_ReadOnly | ImGuiInputTextFlags_NoHorizontalScroll ); ImGui::PopItemWidth(); diff --git a/plugins/builtin/source/content/data_information_sections.cpp b/plugins/builtin/source/content/data_information_sections.cpp index 18e76ca82..d80b5d59d 100644 --- a/plugins/builtin/source/content/data_information_sections.cpp +++ b/plugins/builtin/source/content/data_information_sections.cpp @@ -42,13 +42,13 @@ namespace hex::plugin::builtin { ImGui::TableNextColumn(); ImGuiExt::TextFormatted("{}", name); ImGui::TableNextColumn(); - ImGuiExt::TextFormattedWrapped("{}", value); + ImGuiExt::TextFormattedWrappedSelectable("{}", value); } ImGui::TableNextColumn(); ImGuiExt::TextFormatted("{}", "hex.ui.common.region"_lang); ImGui::TableNextColumn(); - ImGuiExt::TextFormatted("0x{:X} - 0x{:X}", m_region.getStartAddress(), m_region.getEndAddress()); + ImGuiExt::TextFormattedSelectable("0x{:X} - 0x{:X}", m_region.getStartAddress(), m_region.getEndAddress()); ImGui::EndTable(); } @@ -103,7 +103,7 @@ namespace hex::plugin::builtin { if (m_dataDescription == "data") { ImGuiExt::TextFormattedColored(ImVec4(0.92F, 0.25F, 0.2F, 1.0F), "{} ({})", "hex.builtin.information_section.magic.octet_stream_text"_lang, m_dataDescription); } else { - ImGuiExt::TextFormattedWrapped("{}", m_dataDescription); + ImGuiExt::TextFormattedWrappedSelectable("{}", m_dataDescription); } } @@ -119,7 +119,7 @@ namespace hex::plugin::builtin { ImGuiExt::HelpHover("hex.builtin.information_section.magic.octet_stream_warning"_lang, ICON_VS_INFO); ImGui::PopStyleVar(); } else { - ImGuiExt::TextFormatted("{}", m_dataMimeType); + ImGuiExt::TextFormattedSelectable("{}", m_dataMimeType); } } @@ -127,14 +127,14 @@ namespace hex::plugin::builtin { ImGui::TableNextColumn(); ImGui::TextUnformatted("hex.builtin.information_section.magic.apple_type"_lang); ImGui::TableNextColumn(); - ImGuiExt::TextFormatted("{}", m_dataAppleCreatorType); + ImGuiExt::TextFormattedSelectable("{}", m_dataAppleCreatorType); } if (!m_dataExtensions.empty()) { ImGui::TableNextColumn(); ImGui::TextUnformatted("hex.builtin.information_section.magic.extension"_lang); ImGui::TableNextColumn(); - ImGuiExt::TextFormatted("{}", m_dataExtensions); + ImGuiExt::TextFormattedSelectable("{}", m_dataExtensions); } ImGui::EndTable(); @@ -257,7 +257,7 @@ namespace hex::plugin::builtin { ImGui::TableNextColumn(); ImGuiExt::TextFormatted("{}", "hex.builtin.information_section.info_analysis.block_size"_lang); ImGui::TableNextColumn(); - ImGuiExt::TextFormatted("hex.builtin.information_section.info_analysis.block_size.desc"_lang, m_chunkBasedEntropy.getSize(), m_chunkBasedEntropy.getChunkSize()); + ImGuiExt::TextFormattedSelectable("hex.builtin.information_section.info_analysis.block_size.desc"_lang, m_chunkBasedEntropy.getSize(), m_chunkBasedEntropy.getChunkSize()); ImGui::TableNextColumn(); ImGuiExt::TextFormatted("{}", "hex.builtin.information_section.info_analysis.file_entropy"_lang); @@ -277,7 +277,7 @@ namespace hex::plugin::builtin { ImGui::TableNextColumn(); ImGuiExt::TextFormatted("{}", "hex.builtin.information_section.info_analysis.highest_entropy"_lang); ImGui::TableNextColumn(); - ImGuiExt::TextFormatted("{:.5f} @", m_highestBlockEntropy); + ImGuiExt::TextFormattedSelectable("{:.5f} @", m_highestBlockEntropy); ImGui::SameLine(); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0)); ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); @@ -290,7 +290,7 @@ namespace hex::plugin::builtin { ImGui::TableNextColumn(); ImGuiExt::TextFormatted("{}", "hex.builtin.information_section.info_analysis.lowest_entropy"_lang); ImGui::TableNextColumn(); - ImGuiExt::TextFormatted("{:.5f} @", m_lowestBlockEntropy); + ImGuiExt::TextFormattedSelectable("{:.5f} @", m_lowestBlockEntropy); ImGui::SameLine(); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0)); ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); diff --git a/plugins/yara_rules/source/content/data_information_sections.cpp b/plugins/yara_rules/source/content/data_information_sections.cpp index 389ba7b36..a7d58ceed 100644 --- a/plugins/yara_rules/source/content/data_information_sections.cpp +++ b/plugins/yara_rules/source/content/data_information_sections.cpp @@ -78,7 +78,7 @@ namespace hex::plugin::yara { if (ImGuiExt::BeginSubWindow(categoryName.c_str())) { for (const auto &match : category.matchedRules) { const auto &ruleName = match.metadata.contains("name") ? match.metadata.at("name") : match.identifier; - ImGui::TextUnformatted(ruleName.c_str()); + ImGuiExt::TextFormattedSelectable("{}", ruleName); } } ImGuiExt::EndSubWindow();