diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2020-09-26 20:04:34 -0400 |
---|---|---|
committer | ClementTsang <cjhtsang@uwaterloo.ca> | 2020-09-26 20:21:59 -0400 |
commit | 750d8f3cb747103cca7a2a4afe8ff41ff1318b6f (patch) | |
tree | ac34a6a538c1f94cb395b20a23c9186b749ca6e6 /src/canvas/widgets/basic_table_arrows.rs | |
parent | 6db76029e2419d53c81cb2111e487f83ee248a2f (diff) |
refactor: tui-rs 0.11.0 refactor (#253)
Refactors tui-rs usage to the new 0.11.0 release. This release also fixes the highlighting bug from #249, and now, expanding a widget no longer overrides the widget title colour.
This commit also introduces #255, but that seems to be easy to bandaid so hopefully it will get fixed soon?
Diffstat (limited to 'src/canvas/widgets/basic_table_arrows.rs')
-rw-r--r-- | src/canvas/widgets/basic_table_arrows.rs | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/canvas/widgets/basic_table_arrows.rs b/src/canvas/widgets/basic_table_arrows.rs index fd64e8dc..bce169e1 100644 --- a/src/canvas/widgets/basic_table_arrows.rs +++ b/src/canvas/widgets/basic_table_arrows.rs @@ -7,7 +7,9 @@ use tui::{ backend::Backend, layout::{Alignment, Constraint, Direction, Layout, Rect}, terminal::Frame, - widgets::{Block, Paragraph, Text}, + text::Span, + text::Spans, + widgets::{Block, Paragraph}, }; pub trait BasicTableArrows { @@ -97,13 +99,19 @@ impl BasicTableArrows for Painter { usize::from(draw_loc.width).saturating_sub(6 + left_name.len() + right_name.len()); let left_arrow_text = vec![ - Text::raw("\n"), - Text::styled(format!("◄ {}", left_name), self.colours.text_style), + Spans::default(), + Spans::from(Span::styled( + format!("◄ {}", left_name), + self.colours.text_style, + )), ]; let right_arrow_text = vec![ - Text::raw("\n"), - Text::styled(format!("{} ►", right_name), self.colours.text_style), + Spans::default(), + Spans::from(Span::styled( + format!("{} ►", right_name), + self.colours.text_style, + )), ]; let margined_draw_loc = Layout::default() @@ -120,11 +128,11 @@ impl BasicTableArrows for Painter { .split(draw_loc); f.render_widget( - Paragraph::new(left_arrow_text.iter()).block(Block::default()), + Paragraph::new(left_arrow_text).block(Block::default()), margined_draw_loc[0], ); f.render_widget( - Paragraph::new(right_arrow_text.iter()) + Paragraph::new(right_arrow_text) .block(Block::default()) .alignment(Alignment::Right), margined_draw_loc[2], |