re-add tui_main, fixing examples

This commit is contained in:
i do not exist 2026-04-15 11:11:36 +03:00
parent a93fe92a59
commit 6c382e2627
7 changed files with 89 additions and 44 deletions

View file

@ -21,6 +21,23 @@ use ::{
event::{poll, read, Event, KeyEvent, KeyCode, KeyModifiers, KeyEventKind, KeyEventState},
}
};
#[macro_export] macro_rules! tui_main {
($state:expr) => {
pub fn main () -> Usually<()> {
tengri::exit::Exit::run(|exit|{
let state = Arc::new(RwLock::new($state));
Ok((
::tengri::keys::tui_input(
exit.as_ref(), &state, std::time::Duration::from_millis(100)
)?,
::tengri::term::tui_output(
stdout(), exit.as_ref(), &state, std::time::Duration::from_millis(10)
)?
))
})
}
}
}
pub struct Tui(pub Buffer, pub XYWH<u16>);
impl Screen for Tui { type Unit = u16; }
impl Deref for Tui { type Target = Buffer; fn deref (&self) -> &Buffer { &self.0 } }