mirror of
https://github.com/extrawurst/gitui.git
synced 2024-11-27 10:15:07 +03:00
switch to tui clear new in 0.9
This commit is contained in:
parent
7a479b1896
commit
1b90436421
@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
);
|
||||
|
||||
|
@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +0,0 @@
|
||||
use tui::{buffer::Buffer, layout::Rect, widgets::Widget};
|
||||
|
||||
pub struct Clear<T: Widget>(T);
|
||||
|
||||
impl<T: Widget> Clear<T> {
|
||||
pub fn new(w: T) -> Self {
|
||||
Self(w)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Widget> Widget for Clear<T> {
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
mod clear;
|
||||
mod scrolllist;
|
||||
|
||||
pub use clear::Clear;
|
||||
use scrolllist::ScrollableList;
|
||||
use tui::{
|
||||
backend::Backend,
|
||||
|
Loading…
Reference in New Issue
Block a user