1
0
mirror of synced 2024-11-28 09:30:51 +01:00

ui: Limit maximum length of data displayed in pattern tooltip

This commit is contained in:
WerWolv 2022-10-07 16:27:29 +02:00
parent ce8c64a679
commit 2b135cf7e0
2 changed files with 9 additions and 2 deletions

View File

@ -304,6 +304,13 @@ namespace hex {
std::optional<std::string> getEnvironmentVariable(const std::string &env);
inline std::string limitStringLength(const std::string &string, size_t maxLength) {
if (string.length() <= maxLength)
return string;
return string.substr(0, maxLength - 3) + "...";
}
namespace scope_guard {
#define SCOPE_GUARD ::hex::scope_guard::ScopeGuardOnExit() + [&]()

View File

@ -276,6 +276,7 @@ namespace hex::plugin::builtin {
auto patterns = ProviderExtraData::getCurrent().patternLanguage.runtime->getPatternsAtAddress(address);
if (!patterns.empty() && !std::all_of(patterns.begin(), patterns.end(), [](const auto &pattern) { return pattern->isHidden(); })) {
ImGui::BeginTooltip();
for (const auto &pattern : patterns) {
if (pattern->isHidden())
continue;
@ -294,7 +295,6 @@ namespace hex::plugin::builtin {
ImGui::PopStyleColor(2);
}
ImGui::PopID();
}
ImGui::EndTooltip();
}
@ -716,7 +716,7 @@ namespace hex::plugin::builtin {
ImGui::SameLine();
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
ImGui::SameLine();
ImGui::TextFormatted("{} ", pattern->getFormattedValue());
ImGui::TextFormatted("{} ", hex::limitStringLength(pattern->getFormattedValue(), 64));
if (ImGui::GetIO().KeyShift) {
ImGui::Indent();