From 2c4042919f789a76cf2a88240447e52b0724530d Mon Sep 17 00:00:00 2001 From: Gerrit Viljoen Date: Sat, 16 May 2020 22:12:51 +0200 Subject: [PATCH] save game --- src/lib.rs | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 28c3455..4f65481 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -233,24 +233,25 @@ impl AsciiTable { } fn count_characters(&self, cell: &str) -> usize { - let mut count = 0; - let mut block = false; - let mut iter = cell.chars().peekable(); - while let Some(ch) = iter.next() { - if block { - if ch != '\u{1b}' && ch != '[' && ch != ';' && ch != 'm' && !('0'..'9').contains(&ch) { - block = false; - count += 1; - } - } else { - if ch == '\u{1b}' && Some(&'[') == iter.peek() { - block = true; - } else { - count += 1; - } - } - } - count +// let mut count = 0; +// let mut block = false; +// let mut iter = cell.chars().peekable(); +// while let Some(ch) = iter.next() { +// if block { +// if ch != '\u{1b}' && ch != '[' && ch != ';' && ch != 'm' && !('0'..'9').contains(&ch) { +// block = false; +// count += 1; +// } +// } else { +// if ch == '\u{1b}' && Some(&'[') == iter.peek() { +// block = true; +// } else { +// count += 1; +// } +// } +// } +// count + cell.chars().count() } fn truncate_widths(&self, mut widths: Vec) -> Vec {