aboutsummaryrefslogtreecommitdiff
path: root/src/components/hello_world.rs
blob: ac9d02bbc19999f63513f2deaa8d317d64ff333f (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
use ratatui::prelude::{Frame, Rect};
use ratatui::widgets::{Paragraph, Wrap};

use crate::component::Component;

#[derive(Default, Clone)]
pub struct HelloWorld {
    pub text: String,
}

impl Component for HelloWorld {
    fn init(&mut self) -> eyre::Result<()> {
        self.text = "Hello, world!".to_string();
        Ok(())
    }

    fn render(&mut self, frame: &mut Frame, rect: Rect) -> eyre::Result<()> {
        frame.render_widget(
            Paragraph::new(self.text.clone()).wrap(Wrap { trim: true }),
            rect,
        );

        Ok(())
    }
}