summaryrefslogtreecommitdiffstats
path: root/src/ui/widgets/tui_message.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/widgets/tui_message.rs')
-rw-r--r--src/ui/widgets/tui_message.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/ui/widgets/tui_message.rs b/src/ui/widgets/tui_message.rs
new file mode 100644
index 0000000..d4d245c
--- /dev/null
+++ b/src/ui/widgets/tui_message.rs
@@ -0,0 +1,27 @@
+use tui::buffer::Buffer;
+use tui::layout::Rect;
+use tui::style::Style;
+use tui::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);
+ }
+}