mirror of
https://gitlab.com/arnekeller/ascii-table.git
synced 2024-12-04 21:49:08 +00:00
save game
This commit is contained in:
parent
42746ffdc3
commit
2c4042919f
37
src/lib.rs
37
src/lib.rs
@ -233,24 +233,25 @@ impl AsciiTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn count_characters(&self, cell: &str) -> usize {
|
fn count_characters(&self, cell: &str) -> usize {
|
||||||
let mut count = 0;
|
// let mut count = 0;
|
||||||
let mut block = false;
|
// let mut block = false;
|
||||||
let mut iter = cell.chars().peekable();
|
// let mut iter = cell.chars().peekable();
|
||||||
while let Some(ch) = iter.next() {
|
// while let Some(ch) = iter.next() {
|
||||||
if block {
|
// if block {
|
||||||
if ch != '\u{1b}' && ch != '[' && ch != ';' && ch != 'm' && !('0'..'9').contains(&ch) {
|
// if ch != '\u{1b}' && ch != '[' && ch != ';' && ch != 'm' && !('0'..'9').contains(&ch) {
|
||||||
block = false;
|
// block = false;
|
||||||
count += 1;
|
// count += 1;
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
if ch == '\u{1b}' && Some(&'[') == iter.peek() {
|
// if ch == '\u{1b}' && Some(&'[') == iter.peek() {
|
||||||
block = true;
|
// block = true;
|
||||||
} else {
|
// } else {
|
||||||
count += 1;
|
// count += 1;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
count
|
// count
|
||||||
|
cell.chars().count()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn truncate_widths(&self, mut widths: Vec<usize>) -> Vec<usize> {
|
fn truncate_widths(&self, mut widths: Vec<usize>) -> Vec<usize> {
|
||||||
|
Loading…
Reference in New Issue
Block a user