diff --git a/CHANGELOG.md b/CHANGELOG.md index 95b5c95..e214d80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,18 @@ +0.0.14 (2021-09-29) +================== + +* **Feature 1** Add package to snapcraft to increase accessibility. +* [BUG #55](https://github.com/alexhallam/tv/issues/55): +Fix panic on Unicode string truncation +* [BUG #40](https://github.com/alexhallam/tv/issues/30): +Remove trailing comma. +* [BUG #48](https://github.com/alexhallam/tv/issues/48): +Logicals 1/0 were mentioned in comments, but not implemented. +* [BUG #60](https://github.com/alexhallam/tv/issues/60): +Ellipsis then space, not space then ellipsis. + +The rest of the updates had to do with README updates and spelling errors in code comments. + 0.0.13 (2021-09-27) ================== This version was made possible by the contributions of @Lireer! Thank You! diff --git a/Cargo.lock b/Cargo.lock index c9125e7..79364c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -507,7 +507,7 @@ dependencies = [ [[package]] name = "tidy-viewer" -version = "0.0.12" +version = "0.0.14" dependencies = [ "console", "crossterm", @@ -520,6 +520,7 @@ dependencies = [ "regex", "structopt", "tabwriter", + "unicode-truncate", ] [[package]] @@ -528,6 +529,15 @@ version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" +[[package]] +name = "unicode-truncate" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a04be5ca5f7a4a7270ffea82bc41c59b87c611ed04f20e77c338e8d3c2348e42" +dependencies = [ + "unicode-width", +] + [[package]] name = "unicode-width" version = "0.1.8" diff --git a/Cargo.toml b/Cargo.toml index a5cd364..bb5f2de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ license = "Unlicense/MIT" name = "tidy-viewer" readme = "README.md" repository = "https://github.com/alexhallam/tv" -version = "0.0.13" +version = "0.0.14" [package.metadata.deb] assets = [ diff --git a/data/d.csv b/data/d.csv deleted file mode 100644 index a4dbcc2..0000000 --- a/data/d.csv +++ /dev/null @@ -1,2 +0,0 @@ -date -2021-01-01 diff --git a/data/ellipsis.csv b/data/ellipsis.csv new file mode 100644 index 0000000..ea8213c --- /dev/null +++ b/data/ellipsis.csv @@ -0,0 +1,4 @@ +long_text,double +jaywalker-swear-popcorn-opacity-nuttiness-roster,5.89 +unspoiled-treachery-yearning-deputize-stimuli-coexist,2.34 +conflict-yield-sulphate-grumpily-vagrantly-subsiding,7.89 diff --git a/data/logical.csv b/data/logical.csv new file mode 100644 index 0000000..ae5fa7e --- /dev/null +++ b/data/logical.csv @@ -0,0 +1,6 @@ +bool,TF +1,F +1,T +0,F +0,T + diff --git a/data/unicode_pr55.csv b/data/unicode_pr55.csv new file mode 100644 index 0000000..80357f4 --- /dev/null +++ b/data/unicode_pr55.csv @@ -0,0 +1,2 @@ +aColumn,bColumn,cColumn,dColumn,eColumn,fColumn,gColumn +1,üÜğĞçÇşŞöÖ,üÜğĞçÇşŞöÖ üÜğĞçÇşŞöÖ,77,TR,77,77 diff --git a/src/datatype.rs b/src/datatype.rs index ff4e181..087f461 100644 --- a/src/datatype.rs +++ b/src/datatype.rs @@ -9,9 +9,9 @@ pub fn is_logical(text: &str) -> bool { // col_logical -l, T,F,TRUE,FALSE,True,False,true,false,t,f,1,0 lazy_static! { static ref R: Regex = - Regex::new(r"^true$|^false$|^t$|^f$|TRUE$|^FALSE$|^T$|^F$|^True|^False").unwrap(); + Regex::new(r"^true$|^false$|^t$|^f$|TRUE$|^FALSE$|^T$|^F$|^True|^False|^1$|^0$") + .unwrap(); } - //let r = Regex::new(rgex).unwrap(); R.is_match(text) } @@ -85,6 +85,8 @@ pub fn is_na_string_padded(text: &str) -> bool { pub fn infer_type_from_string(text: &str) -> &'static str { if is_time(text) { "" + } else if is_logical(text) { + "" } else if is_integer(text) { "" } else if is_date_time(text) { @@ -93,8 +95,6 @@ pub fn infer_type_from_string(text: &str) -> &'static str { "" } else if is_double(text) { "" - } else if is_logical(text) { - "" } else { "" } @@ -111,7 +111,9 @@ pub fn trunc_strings(vec_col: &[&str], width: usize) -> Vec { let len = string.chars().count(); if len > width { let (rv, _) = string.unicode_truncate(width - 1); - [rv.to_string(), ellipsis.to_string()].join(" ") + let spacer: &str = &" "; + let string_and_ellipses = [rv.to_string(), ellipsis.to_string()].join(""); + [string_and_ellipses, spacer.to_string()].join("") } else { let add_space = width - len + 1; let borrowed_string: &str = &" ".repeat(add_space);