From 5c27ce2561ad60af4a16a1f6b3dda9ea49b99250 Mon Sep 17 00:00:00 2001 From: thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> Date: Thu, 17 Mar 2022 08:47:26 -0400 Subject: [PATCH] ClipboardHistory: Show ranges and max dimensions for copied glyphs Makes copy history a bit more informative by showing the code point range of the selection copied, or the individual character if the selection contains only one glyph. --- .../ClipboardHistory/ClipboardHistoryModel.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp b/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp index 27f9f7cb7f..57d2211511 100644 --- a/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp +++ b/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp @@ -85,9 +85,17 @@ GUI::Variant ClipboardHistoryModel::data(const GUI::ModelIndex& index, GUI::Mode } if (data_and_type.mime_type.starts_with("glyph/")) { StringBuilder builder; - builder.append("["); - builder.append(data_and_type.metadata.get("count").value_or("?")); - builder.append(" glyph(s)]"); + auto count = data_and_type.metadata.get("count").value().to_uint().value_or(0); + auto start = data_and_type.metadata.get("start").value().to_uint().value_or(0); + auto width = data_and_type.metadata.get("width").value().to_uint().value_or(0); + auto height = data_and_type.metadata.get("height").value().to_uint().value_or(0); + if (count > 1) { + builder.appendff("U+{:04X}..U+{:04X} ({} glyphs) [{}x{}]", start, start + count - 1, count, width, height); + } else { + builder.appendff("U+{:04X} (", start); + builder.append_code_point(start); + builder.appendff(") [{}x{}]", width, height); + } return builder.to_string(); } return "<...>";