From 1bba1afd488a677756570815d5de811846ef8ccc Mon Sep 17 00:00:00 2001 From: Alex Hallam Date: Wed, 29 Sep 2021 18:47:15 -0400 Subject: [PATCH 1/5] add unicode data test file --- Cargo.lock | 12 +++++++++++- data/d.csv | 2 -- data/unicode_pr55.csv | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) delete mode 100644 data/d.csv create mode 100644 data/unicode_pr55.csv diff --git a/Cargo.lock b/Cargo.lock index c9125e7..fa2a498 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -507,7 +507,7 @@ dependencies = [ [[package]] name = "tidy-viewer" -version = "0.0.12" +version = "0.0.13" 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/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/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 From 49048bca989cf057f4fa3d80940b555ffc0cb5fb Mon Sep 17 00:00:00 2001 From: Alex Hallam Date: Wed, 29 Sep 2021 19:46:04 -0400 Subject: [PATCH 2/5] fix ellipsis placing --- data/ellipsis.csv | 4 ++++ src/datatype.rs | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 data/ellipsis.csv 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/src/datatype.rs b/src/datatype.rs index ff4e181..08d1278 100644 --- a/src/datatype.rs +++ b/src/datatype.rs @@ -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); From a0ee8086d1742bcce47939a95991744e6d36de36 Mon Sep 17 00:00:00 2001 From: Alex Hallam Date: Wed, 29 Sep 2021 19:47:10 -0400 Subject: [PATCH 3/5] bump version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index a5cd364..fe88449 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.16" [package.metadata.deb] assets = [ From 1d73401fffb9a557ec6bc8b869195235964df824 Mon Sep 17 00:00:00 2001 From: Alex Hallam Date: Wed, 29 Sep 2021 20:15:46 -0400 Subject: [PATCH 4/5] update changelog --- CHANGELOG.md | 15 +++++++++++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- data/logical.csv | 6 ++++++ src/datatype.rs | 7 +++---- 5 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 data/logical.csv 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 fa2a498..79364c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -507,7 +507,7 @@ dependencies = [ [[package]] name = "tidy-viewer" -version = "0.0.13" +version = "0.0.14" dependencies = [ "console", "crossterm", diff --git a/Cargo.toml b/Cargo.toml index fe88449..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.16" +version = "0.0.14" [package.metadata.deb] assets = [ 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/src/datatype.rs b/src/datatype.rs index 08d1278..07ee751 100644 --- a/src/datatype.rs +++ b/src/datatype.rs @@ -9,9 +9,8 @@ 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 +84,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 +94,6 @@ pub fn infer_type_from_string(text: &str) -> &'static str { "" } else if is_double(text) { "" - } else if is_logical(text) { - "" } else { "" } From 2ba53ee212c792a679938c3d9296f8933b1d75ba Mon Sep 17 00:00:00 2001 From: Alex Hallam Date: Wed, 29 Sep 2021 20:21:39 -0400 Subject: [PATCH 5/5] update from rustfmt --- src/datatype.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/datatype.rs b/src/datatype.rs index 07ee751..087f461 100644 --- a/src/datatype.rs +++ b/src/datatype.rs @@ -9,7 +9,8 @@ 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|^1$|^0$").unwrap(); + Regex::new(r"^true$|^false$|^t$|^f$|TRUE$|^FALSE$|^T$|^F$|^True|^False|^1$|^0$") + .unwrap(); } R.is_match(text) }