src/widgets/force_clear.rs

2512b334b421431b5e8577ab9c3031350fcd71bd
youtube-tui/src/widgets/force_clear.rs history · blame · raw

20 lines · 468 bytes

 1use tui::{
 2    buffer::Buffer,
 3    layout::Rect,
 4    style::{Color, Style},
 5    widgets::Widget,
 6};
 7
 8pub struct ForceClear;
 9
10impl Widget for ForceClear {
11    fn render(self, rect: Rect, buffer: &mut Buffer) {
12        for y in rect.y..rect.y + rect.height {
13            for x in rect.x..rect.x + rect.width {
14                buffer
15                    .get_mut(x, y)
16                    .set_style(Style::default().bg(Color::DarkGray));
17            }
18        }
19    }
20}