From 69a2490844d87c09cd5cc51da49e3cd87a03c35a Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 22 Jul 2020 13:50:31 +0800 Subject: [PATCH] Minor style improvements to handle special case --- CHANGELOG.md | 4 ++++ Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- src/interactive/widgets/entries.rs | 19 +++++++++++++------ 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c3a1136..bebb941e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +#### v2.10.0 - Minor improvements of looks; improved windows support + +* previously in interactive mode on Windows, directory sizes would appear as 0 bytes in size. This is now fixed! + #### v2.9.1 - Globs for Windows; fixed handling of colors * On widnows, `dua` will now expand glob patterns by itself as this capability is not implemented by shells `dua` can now run in. diff --git a/Cargo.lock b/Cargo.lock index 56cbd657..a336986c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -206,7 +206,7 @@ dependencies = [ "crossterm", "termion", "tui", - "tui-react 0.10.0", + "tui-react 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -227,7 +227,7 @@ checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" [[package]] name = "dua-cli" -version = "2.9.1" +version = "2.10.0" dependencies = [ "anyhow", "atty", @@ -243,7 +243,7 @@ dependencies = [ "pretty_assertions", "structopt", "tui", - "tui-react 0.10.0", + "tui-react 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-segmentation", "wild", ] @@ -707,9 +707,7 @@ dependencies = [ [[package]] name = "tui-react" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21bbc5221de660fa2cc79a5386d72f268174a90e37eef004f5210cc7f94baf78" +version = "0.10.1" dependencies = [ "log", "tui", @@ -720,6 +718,8 @@ dependencies = [ [[package]] name = "tui-react" version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97bea172550957047351f406690772b6fa6244c20b95cbb230228bbb7477c61" dependencies = [ "log", "tui", diff --git a/Cargo.toml b/Cargo.toml index f1a3b7e2..712a07a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dua-cli" -version = "2.9.1" +version = "2.10.0" authors = ["Sebastian Thiel "] edition = "2018" repository = "https://github.com/Byron/dua-cli" diff --git a/src/interactive/widgets/entries.rs b/src/interactive/widgets/entries.rs index 62d24e30..1d947cf9 100644 --- a/src/interactive/widgets/entries.rs +++ b/src/interactive/widgets/entries.rs @@ -125,13 +125,20 @@ impl Entries { ..style }, ); + let fraction = w.size as f32 / total as f32; + let should_avoid_showing_a_big_reversed_bar = fraction > 0.9; + let local_style = if should_avoid_showing_a_big_reversed_bar { + style.remove_modifier(Modifier::REVERSED) + } else { + style + }; + + let left_bar = Span::styled(" |", local_style); let percentage = Span::styled( - format!( - " |{}| ", - display.byte_vis.display(w.size as f32 / total as f32) - ), - style, + format!("{}", display.byte_vis.display(fraction)), + local_style, ); + let right_bar = Span::styled("| ", local_style); let name = Span::styled( fill_background_to_right( @@ -153,7 +160,7 @@ impl Entries { Style { fg, ..style } }, ); - vec![bytes, percentage, name] + vec![bytes, left_bar, percentage, right_bar, name] }, );