mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-02-21 18:49:04 +01:00
dsl, output, tui: add tests, examples, root dispatchers
This commit is contained in:
parent
8dfe20a58c
commit
ca862b9802
16 changed files with 637 additions and 377 deletions
35
tui/src/tui_test.rs
Normal file
35
tui/src/tui_test.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
use crate::*;
|
||||
#[test] fn test_tui_engine () -> Usually<()> {
|
||||
//use std::sync::{Arc, RwLock};
|
||||
struct TestComponent(String);
|
||||
impl Content<TuiOut> for TestComponent {
|
||||
fn content (&self) -> impl Draw<TuiOut> + Layout<TuiOut> {
|
||||
Some(self.0.as_str())
|
||||
}
|
||||
}
|
||||
impl Handle<TuiIn> for TestComponent {
|
||||
fn handle (&mut self, _from: &TuiIn) -> 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(())
|
||||
}
|
||||
//#[test] fn test_parse_key () {
|
||||
////use KeyModifiers as Mods;
|
||||
//let _test = |x: &str, y|assert_eq!(KeyMatcher::new(x).build(), Some(Event::Key(y)));
|
||||
////test(":x",
|
||||
////KeyEvent::new(KeyCode::Char('x'), Mods::NONE));
|
||||
////test(":ctrl-x",
|
||||
////KeyEvent::new(KeyCode::Char('x'), Mods::CONTROL));
|
||||
////test(":alt-x",
|
||||
////KeyEvent::new(KeyCode::Char('x'), Mods::ALT));
|
||||
////test(":shift-x",
|
||||
////KeyEvent::new(KeyCode::Char('x'), Mods::SHIFT));
|
||||
////test(":ctrl-alt-shift-x",
|
||||
////KeyEvent::new(KeyCode::Char('x'), Mods::CONTROL | Mods::ALT | Mods::SHIFT ));
|
||||
//}
|
||||
Loading…
Add table
Add a link
Reference in a new issue