use std::{
io::Result,
time::{Duration, Instant},
};
use crossterm::event::{poll, read, Event, KeyEvent};
pub struct UIEvents {
tick_rate: Duration,
}
pub struct Cfg {
pub tick_rate: Duration,
}
impl Default for Cfg {
fn default() -> Cfg {
Cfg {
tick_rate: Duration::from_millis(250),
}
}
}
impl UIEvents {
pub fn new() -> UIEvents {
UIEvents::with_config(Cfg::default())
}
pub fn with_config(config: Cfg) -> UIEvents {
UIEvents {
tick_rate: config.tick_rate,
}
}
pub fn next(&self) -> Result