Append ellipse to truncated labels.
This commit is contained in:
parent
3021fdb848
commit
a95c00aa57
2 changed files with 5 additions and 2 deletions
|
@ -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");
|
||||
|
|
|
@ -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 => (),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue