mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
wip: big flat pt.3, testing standalone tui
This commit is contained in:
parent
a5628fb663
commit
cb680ab096
4 changed files with 189 additions and 139 deletions
|
|
@ -1,8 +1,8 @@
|
|||
mod component; pub use self::component::*;
|
||||
mod engine; pub use self::engine::*;
|
||||
mod input; pub use self::input::*;
|
||||
mod output; pub use self::output::*;
|
||||
mod tui; pub use self::tui::*;
|
||||
//mod component; pub use self::component::*;
|
||||
mod engine; pub use self::engine::*;
|
||||
mod input; pub use self::input::*;
|
||||
mod output; pub use self::output::*;
|
||||
mod tui; pub use self::tui::*;
|
||||
|
||||
pub use std::error::Error;
|
||||
|
||||
|
|
@ -58,5 +58,22 @@ pub type Perhaps<T> = Result<Option<T>, Box<dyn Error>>;
|
|||
}
|
||||
|
||||
#[cfg(test)] #[test] fn test_tui_engine () -> Usually<()> {
|
||||
use std::sync::{Arc, RwLock};
|
||||
struct TestComponent(String);
|
||||
impl Content<Tui> for TestComponent {
|
||||
fn content (&self) -> Option<impl Render<Tui>> {
|
||||
Some(&self.0)
|
||||
}
|
||||
}
|
||||
impl Handle<Tui> for TestComponent {
|
||||
fn handle (&mut self, from: &TuiInput) -> Perhaps<bool> {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
let engine = Tui::new()?;
|
||||
engine.read().unwrap().exited.store(true, std::sync::atomic::Ordering::Relaxed);
|
||||
let state = TestComponent("hello world".into());
|
||||
let state = std::sync::Arc::new(std::sync::RwLock::new(state));
|
||||
engine.run(&state)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue