mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-07-17 15:56:57 +02:00
re-add tui_main, fixing examples
This commit is contained in:
parent
a93fe92a59
commit
6c382e2627
7 changed files with 89 additions and 44 deletions
17
src/term.rs
17
src/term.rs
|
|
@ -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 } }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue