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 /tui-react/src | |
parent | 48cbe0919da1dd6aa8c933b5d156e7f0ce5997a8 (diff) |
tui-react now works with tui 10.0; tracks tui's version number now
Diffstat (limited to 'tui-react/src')
-rw-r--r-- | tui-react/src/lib.rs | 4 | ||||
-rw-r--r-- | tui-react/src/list.rs | 12 |
2 files changed, 9 insertions, 7 deletions
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, |