diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-07-22 09:45:08 +0800 |
---|---|---|
committer | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-07-22 09:45:08 +0800 |
commit | 773497cc48a406a069be84e14194d51484fdbec2 (patch) | |
tree | a1f48a3aad71d82bee35c6db9785e4f748b29b19 | |
parent | 48cbe0919da1dd6aa8c933b5d156e7f0ce5997a8 (diff) |
tui-react now works with tui 10.0; tracks tui's version number now
-rw-r--r-- | Cargo.lock | 30 | ||||
-rw-r--r-- | tui-react/Cargo.toml | 4 | ||||
-rw-r--r-- | tui-react/src/lib.rs | 4 | ||||
-rw-r--r-- | tui-react/src/list.rs | 12 |
4 files changed, 32 insertions, 18 deletions
@@ -205,8 +205,8 @@ checksum = "032534543c938ffc4106ee75411f4b7be2e0260e044d17dae36f9409ada87895" dependencies = [ "crossterm", "termion", - "tui", - "tui-react 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tui 0.9.5", + "tui-react 0.4.1", ] [[package]] @@ -242,8 +242,8 @@ dependencies = [ "petgraph", "pretty_assertions", "structopt", - "tui", - "tui-react 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tui 0.9.5", + "tui-react 0.4.1", "unicode-segmentation", "wild", ] @@ -708,11 +708,13 @@ dependencies = [ ] [[package]] -name = "tui-react" -version = "0.4.1" +name = "tui" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a977b0bb2e2033a6fef950f218f13622c3c34e59754b704ce3492dedab1dfe95" dependencies = [ - "log", - "tui", + "bitflags", + "cassowary", "unicode-segmentation", "unicode-width", ] @@ -724,7 +726,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94a0de793b78a2275af97d92666d52e00b7938518d1668c6f9a09eca2d4a69df" dependencies = [ "log", - "tui", + "tui 0.9.5", + "unicode-segmentation", + "unicode-width", +] + +[[package]] +name = "tui-react" +version = "0.10.0" +dependencies = [ + "log", + "tui 0.10.0", "unicode-segmentation", "unicode-width", ] diff --git a/tui-react/Cargo.toml b/tui-react/Cargo.toml index 4929d98..7fb2055 100644 --- a/tui-react/Cargo.toml +++ b/tui-react/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tui-react" -version = "0.4.1" +version = "0.10.0" authors = ["Sebastian Thiel <sthiel@thoughtworks.com>"] edition = "2018" repository = "https://github.com/Byron/dua-cli" @@ -9,7 +9,7 @@ readme = "README.md" license = "MIT" [dependencies] -tui = { version = "0.9.1", default-features = false } +tui = { version = "0.10.0", default-features = false } log = "0.4.6" unicode-segmentation = "1.6.0" unicode-width = "0.1.7" diff --git a/tui-react/src/lib.rs b/tui-react/src/lib.rs index 16370e5..9333fb5 100644 --- a/tui-react/src/lib.rs +++ b/tui-react/src/lib.rs @@ -54,7 +54,7 @@ pub fn draw_text_with_ellipsis_nowrap( } cell.symbol = g.into(); if let Some(s) = s { - cell.style = s; + cell.set_style(s); } x_offset += width.saturating_sub(1) as u16; @@ -86,7 +86,7 @@ pub fn draw_text_nowrap_fn( for (g, x) in t.as_ref().graphemes(true).zip(bound.left()..bound.right()) { let cell = buf.get_mut(x, bound.y); cell.symbol = g.into(); - cell.style = s(&cell.symbol, x, bound.y); + cell.set_style(s(&cell.symbol, x, bound.y)); } } diff --git a/tui-react/src/list.rs b/tui-react/src/list.rs index 8ffe88c..16e2a91 100644 --- a/tui-react/src/list.rs +++ b/tui-react/src/list.rs @@ -1,7 +1,8 @@ use tui::{ buffer::Buffer, layout::Rect, - widgets::{Block, Paragraph, Text, Widget}, + text::{Span, Spans, Text}, + widgets::{Block, Paragraph, Widget}, }; #[derive(Default)] @@ -33,7 +34,7 @@ impl List { pub fn render<'a, 't>( &mut self, props: ListProps<'a>, - items: impl IntoIterator<Item = Vec<Text<'t>>>, + items: impl IntoIterator<Item = Vec<Span<'t>>>, area: Rect, buf: &mut Buffer, ) { @@ -44,8 +45,9 @@ impl List { let list_area = match block { Some(b) => { + let area = b.inner(area); b.render(area, buf); - b.inner(area) + area } None => area, }; @@ -55,14 +57,14 @@ impl List { return; } - for (i, text_iterator) in items + for (i, vec_of_spans) in items .into_iter() .skip(self.offset) .enumerate() .take(list_area.height as usize) { let (x, y) = (list_area.left(), list_area.top() + i as u16); - Paragraph::new(text_iterator.iter()).render( + Paragraph::new(Text::from(Spans::from(vec_of_spans))).render( Rect { x, y, |