Event handling (#5)

- Refactor `event` handling (heavily inspired by [crates-tui](https://github.com/ratatui/crates-tui/) via [Tui with Terminal and EventHandler](https://ratatui.rs/recipes/apps/terminal-and-event-handler/))
- Refactor widget structure
- Disable `nixos-unstable` temporarily
- Add `.rustfmt.toml`
This commit is contained in:
Jens K.
2024-12-02 15:43:04 +01:00
committed by GitHub
parent db5909f3d9
commit 2f587c97b5
17 changed files with 469 additions and 95 deletions

23
src/widgets/countdown.rs Normal file
View File

@@ -0,0 +1,23 @@
use ratatui::{
buffer::Buffer,
layout::Rect,
widgets::{Paragraph, Widget},
};
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct Countdown {
headline: String,
}
impl Countdown {
pub const fn new(headline: String) -> Self {
Self { headline }
}
}
impl Widget for Countdown {
fn render(self, area: Rect, buf: &mut Buffer) {
let h = Paragraph::new(self.headline).centered();
h.render(area, buf);
}
}