diff --git a/src/components/commit.rs b/src/components/commit.rs index 6051ee5d..b16b5222 100644 --- a/src/components/commit.rs +++ b/src/components/commit.rs @@ -17,7 +17,7 @@ use tui::{ backend::Backend, layout::{Alignment, Rect}, style::{Color, Style}, - widgets::{Block, Borders, Paragraph, Text}, + widgets::{Block, Borders, Clear, Paragraph, Text}, Frame, }; @@ -40,17 +40,17 @@ impl DrawableComponent for CommitComponent { [Text::Raw(Cow::from(self.msg.clone()))] }; + let area = ui::centered_rect(60, 20, f.size()); + f.render_widget(Clear, area); f.render_widget( - ui::Clear::new( - Paragraph::new(txt.iter()) - .block( - Block::default() - .title(strings::COMMIT_TITLE) - .borders(Borders::ALL), - ) - .alignment(Alignment::Left), - ), - ui::centered_rect(60, 20, f.size()), + Paragraph::new(txt.iter()) + .block( + Block::default() + .title(strings::COMMIT_TITLE) + .borders(Borders::ALL), + ) + .alignment(Alignment::Left), + area, ); } } diff --git a/src/components/help.rs b/src/components/help.rs index 0224465b..7441d57b 100644 --- a/src/components/help.rs +++ b/src/components/help.rs @@ -12,7 +12,7 @@ use tui::{ backend::Backend, layout::{Alignment, Constraint, Direction, Layout, Rect}, style::{Color, Style}, - widgets::{Block, Borders, Paragraph, Text}, + widgets::{Block, Borders, Clear, Paragraph, Text}, Frame, }; @@ -41,12 +41,11 @@ impl DrawableComponent for HelpComponent { let area = ui::centered_rect_absolute(65, height, f.size()); + f.render_widget(Clear, area); f.render_widget( - ui::Clear::new( - Block::default() - .title(strings::HELP_TITLE) - .borders(Borders::ALL), - ), + Block::default() + .title(strings::HELP_TITLE) + .borders(Borders::ALL), area, ); diff --git a/src/components/msg.rs b/src/components/msg.rs index b76b35b6..d944ab54 100644 --- a/src/components/msg.rs +++ b/src/components/msg.rs @@ -9,7 +9,7 @@ use strings::commands; use tui::{ backend::Backend, layout::{Alignment, Rect}, - widgets::{Block, Borders, Paragraph, Text}, + widgets::{Block, Borders, Clear, Paragraph, Text}, Frame, }; @@ -24,18 +24,18 @@ impl DrawableComponent for MsgComponent { if self.visible { let txt = vec![Text::Raw(Cow::from(self.msg.as_str()))]; + let area = ui::centered_rect_absolute(65, 25, f.size()); + f.render_widget(Clear, area); f.render_widget( - ui::Clear::new( - Paragraph::new(txt.iter()) - .block( - Block::default() - .title(strings::MSG_TITLE) - .borders(Borders::ALL), - ) - .wrap(true) - .alignment(Alignment::Left), - ), - ui::centered_rect_absolute(65, 25, f.size()), + Paragraph::new(txt.iter()) + .block( + Block::default() + .title(strings::MSG_TITLE) + .borders(Borders::ALL), + ) + .wrap(true) + .alignment(Alignment::Left), + area, ); } } diff --git a/src/components/reset.rs b/src/components/reset.rs index 8b128e2a..0b6a32f0 100644 --- a/src/components/reset.rs +++ b/src/components/reset.rs @@ -14,7 +14,7 @@ use tui::{ backend::Backend, layout::{Alignment, Rect}, style::{Color, Style}, - widgets::{Block, Borders, Paragraph, Text}, + widgets::{Block, Borders, Clear, Paragraph, Text}, Frame, }; @@ -34,17 +34,17 @@ impl DrawableComponent for ResetComponent { Style::default().fg(Color::Red), )); + let area = ui::centered_rect(30, 20, f.size()); + f.render_widget(Clear, area); f.render_widget( - ui::Clear::new( - Paragraph::new(txt.iter()) - .block( - Block::default() - .title(strings::RESET_TITLE) - .borders(Borders::ALL), - ) - .alignment(Alignment::Left), - ), - ui::centered_rect(30, 20, f.size()), + Paragraph::new(txt.iter()) + .block( + Block::default() + .title(strings::RESET_TITLE) + .borders(Borders::ALL), + ) + .alignment(Alignment::Left), + area, ); } } diff --git a/src/ui/clear.rs b/src/ui/clear.rs deleted file mode 100644 index 5bf53b37..00000000 --- a/src/ui/clear.rs +++ /dev/null @@ -1,25 +0,0 @@ -use tui::{buffer::Buffer, layout::Rect, widgets::Widget}; - -pub struct Clear(T); - -impl Clear { - pub fn new(w: T) -> Self { - Self(w) - } -} - -impl Widget for Clear { - fn render(self, area: Rect, buf: &mut Buffer) { - if area.width < 2 || area.height < 2 { - return; - } - - for x in area.left()..area.right() { - for y in area.top()..area.bottom() { - buf.get_mut(x, y).reset(); - } - } - - self.0.render(area, buf); - } -} diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 6bedc947..0d1af3b1 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -1,7 +1,5 @@ -mod clear; mod scrolllist; -pub use clear::Clear; use scrolllist::ScrollableList; use tui::{ backend::Backend,