From a95c00aa57bcd3d3721c346913415ccc2bf22c49 Mon Sep 17 00:00:00 2001 From: shy Date: Mon, 12 Apr 2021 08:59:47 +0200 Subject: [PATCH] Append ellipse to truncated labels. --- src/consts.rs | 2 +- src/utils.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/consts.rs b/src/consts.rs index 5c24442..efdc28f 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -9,7 +9,7 @@ pub const COLOR: [&dyn termion::color::Color; 6] = [ ]; // Maximum length of labels. -pub const LABEL_SIZE_LIMIT: usize = 42; +pub const LABEL_SIZE_LIMIT: usize = 32; pub mod ui { pub const NAME: &str = env!("CARGO_PKG_NAME"); diff --git a/src/utils.rs b/src/utils.rs index 5972a74..0637108 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -8,7 +8,10 @@ pub fn unicode_length(input: &str) -> u16 { pub fn unicode_truncate(input: &mut String, limit: usize) { match UnicodeSegmentation::grapheme_indices(input.as_str(), true).nth(limit) { - Some((i, _)) => input.truncate(i), + Some((i, _)) => { + input.truncate(i); + input.push('…'); + }, None => (), } }