molehole/src/components/hello_world.rs

23 lines
488 B
Rust
Raw Normal View History

2024-03-06 06:11:00 +00:00
use ratatui::prelude::*;
use ratatui::widgets::Paragraph;
use crate::component::Component;
#[derive(Default, Clone)]
pub struct HelloWorld {
pub text: String,
}
impl Component for HelloWorld {
2024-03-06 16:45:18 +00:00
fn init(&mut self) -> eyre::Result<()> {
self.text = "Hello, world!".to_string();
Ok(())
}
2024-03-06 06:11:00 +00:00
fn render(&mut self, frame: &mut Frame, rect: Rect) -> eyre::Result<()> {
frame.render_widget(Paragraph::new(self.text.clone()), rect);
Ok(())
}
}