diff options
| author | Brooks J Rady <b.j.rady@gmail.com> | 2021-01-06 13:34:21 +0000 |
|---|---|---|
| committer | Brooks J Rady <b.j.rady@gmail.com> | 2021-01-06 13:34:21 +0000 |
| commit | d509b0c339fc7857dc6ef17d678961b0060de646 (patch) | |
| tree | 274466a42800200a52eee5b7fc21a953b6a4becf /src/utils | |
| parent | Also borken (diff) | |
| download | sl0ppij-d509b0c339fc7857dc6ef17d678961b0060de646.tar.gz sl0ppij-d509b0c339fc7857dc6ef17d678961b0060de646.tar.xz sl0ppij-d509b0c339fc7857dc6ef17d678961b0060de646.zip | |
Very nearly working
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/shared.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/utils/shared.rs b/src/utils/shared.rs index 3b8b5fbd..f5d4c303 100644 --- a/src/utils/shared.rs +++ b/src/utils/shared.rs @@ -1,15 +1,15 @@ -use std::iter; +use std::{iter, str::from_utf8}; use strip_ansi_escapes::strip; // FIXME: Should this be an extension trait? Or here at all? pub fn ansi_len(s: &str) -> usize { - strip(s.as_bytes()).unwrap().len() + from_utf8(&strip(s.as_bytes()).unwrap()).unwrap().chars().count() } pub fn pad_to_size(s: &str, rows: usize, columns: usize) -> String { s.lines() - .map(|l| [l, &str::repeat(" ", dbg!(columns) - dbg!(ansi_len(l)))].concat()) + .map(|l| [l, &str::repeat(" ", columns - ansi_len(l))].concat()) .chain(iter::repeat(str::repeat(" ", columns))) .take(rows) .collect::<Vec<_>>() |
