blob: 6ad891d9cafc91caed1ccbe5ee5522686757ea8e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
use ratatui::buffer::Buffer;
use ratatui::layout::Rect;
use ratatui::style::Style;
use ratatui::widgets::Widget;
pub struct TuiMessage<'a> {
message: &'a str,
style: Style,
}
impl<'a> TuiMessage<'a> {
pub fn new(message: &'a str, style: Style) -> Self {
Self { message, style }
}
}
impl<'a> Widget for TuiMessage<'a> {
fn render(self, area: Rect, buf: &mut Buffer) {
if area.width < 4 || area.height < 1 {
return;
}
let x = area.left();
let y = area.top();
buf.set_stringn(x, y, self.message, area.width as usize, self.style);
}
}
|