summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Thiel <sebastian.thiel@icloud.com>2020-03-30 00:50:48 +0800
committerSebastian Thiel <sebastian.thiel@icloud.com>2020-03-30 00:50:48 +0800
commitdff2c8637198f1b695d3ccf25a49566e55e38249 (patch)
tree10baa495a9c0a4120d7b14c68c95c6eeb5b487d8
parent12fd9936abfce74df3b5e3b005d7eff7e7d8204d (diff)
Revert "use tui-react to draw text…"
This reverts commit e8c00b70
-rw-r--r--tui-react/src/list.rs28
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,
+ );
}
}
}