use std::{thread::sleep, time::Duration};
use yacll::{
input::{Event, KeyCode},
Result, Yogurt,
};
fn main() -> Result<()> {
let mut y = Yogurt::new();
y.enter_alt()?;
y.cursor_on(yacll::stylize::CursorAttr::Hidden)?;
y.mv_print((0, 0), "press the any key to advance.")?;
y.flush()?;
y.block_event()?;
y.mv_print((0, 1), "now press the q key in the next 10 seconds!")?;
y.flush()?;
match y.read_event(Duration::from_secs(10))? {
Some(some) => {
if let Event::Key(ke) = some {
if let KeyCode::Char('q') = ke.code {
y.mv_print((0, 2), "you did it!")?;
} else {
y.mv_print((0, 2), "that's not q!")?;
}
} else {
y.mv_print((0, 2), "that event isn't a key event!")?;
}
}
None => y.mv_print((0, 2), "you failed...")?,
}
y.flush()?;
sleep(Duration::from_secs(3));
y.cursor_off(yacll::stylize::CursorAttr::Hidden)?;
y.leave_alt()?;
Ok(())
}