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.
This commit is contained in:
thankyouverycool 2022-03-17 08:47:26 -04:00 committed by Andreas Kling
parent 17b16f3997
commit 5c27ce2561
Notes: sideshowbarker 2024-07-17 17:14:11 +09:00

View file

@ -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 "<...>";