diff options
-rw-r--r-- | tui-react/src/list.rs | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/tui-react/src/list.rs b/tui-react/src/list.rs index aacb7d9..6c7699a 100644 --- a/tui-react/src/list.rs +++ b/tui-react/src/list.rs @@ -1,10 +1,7 @@ -use crate::draw_text_without_ellipsis_nowrap; -use crate::util::rect::offset_x; use tui::{ buffer::Buffer, layout::Rect, - style::Style, - widgets::{Block, Text, Widget}, + widgets::{Block, Paragraph, Text, Widget}, }; #[derive(Default)] @@ -65,20 +62,15 @@ impl List { .take(list_area.height as usize) { let (x, y) = (list_area.left(), list_area.top() + i as u16); - let mut bound = Rect { - x, - y, - width: list_area.width, - height: 1, - }; - for text in text_iterator.into_iter() { - let (text, style) = match text { - Text::Raw(s) => (s, Style::default()), - Text::Styled(s, style) => (s, style), - }; - let offset = draw_text_without_ellipsis_nowrap(bound, buf, text, Some(style)); - bound = offset_x(bound, offset); - } + Paragraph::new(text_iterator.iter()).draw( + Rect { + x, + y, + width: list_area.width, + height: 1, + }, + buf, + ); } } } |