mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 19:56:44 +01:00
This commit is contained in:
parent
21832453d9
commit
17506726cb
36 changed files with 280 additions and 271 deletions
|
|
@ -36,7 +36,7 @@ pub(crate) use std::io::{stdout, Stdout};
|
|||
|
||||
#[cfg(test)] #[test] fn test_tui_engine () -> Usually<()> {
|
||||
use crate::*;
|
||||
use std::sync::{Arc, RwLock};
|
||||
//use std::sync::{Arc, RwLock};
|
||||
struct TestComponent(String);
|
||||
impl Content<TuiOut> for TestComponent {
|
||||
fn content (&self) -> impl Render<TuiOut> {
|
||||
|
|
@ -44,21 +44,21 @@ pub(crate) use std::io::{stdout, Stdout};
|
|||
}
|
||||
}
|
||||
impl Handle<TuiIn> for TestComponent {
|
||||
fn handle (&mut self, from: &TuiIn) -> Perhaps<bool> {
|
||||
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));
|
||||
let _state = std::sync::Arc::new(std::sync::RwLock::new(state));
|
||||
//engine.run(&state)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)] #[test] fn test_parse_key () {
|
||||
use KeyModifiers as Mods;
|
||||
let test = |x: &str, y|assert_eq!(KeyMatcher::new(x).build(), Some(Event::Key(y)));
|
||||
//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",
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ impl<T, U> Field<T, U> {
|
|||
value_align: None,
|
||||
}
|
||||
}
|
||||
fn label <L> (
|
||||
pub fn label <L> (
|
||||
self,
|
||||
label: Option<L>,
|
||||
align: Option<Direction>,
|
||||
|
|
@ -75,7 +75,7 @@ impl<T, U> Field<T, U> {
|
|||
..self
|
||||
}
|
||||
}
|
||||
fn value <V> (
|
||||
pub fn value <V> (
|
||||
self,
|
||||
value: Option<V>,
|
||||
align: Option<Direction>,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::*;
|
||||
|
||||
render!(TuiOut: |self: u64, to|todo!());
|
||||
render!(TuiOut: |self: u64, _to|todo!());
|
||||
|
||||
render!(TuiOut: |self: f64, to|todo!());
|
||||
render!(TuiOut: |self: f64, _to|todo!());
|
||||
|
|
|
|||
|
|
@ -56,13 +56,13 @@ impl TuiIn {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "dsl")]
|
||||
impl DslInput for TuiIn {
|
||||
fn matches_dsl (&self, token: &str) -> bool {
|
||||
if let Some(event) = KeyMatcher::new(token).build() {
|
||||
&event == self.event()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
//#[cfg(feature = "dsl")]
|
||||
//impl DslInput for TuiIn {
|
||||
//fn matches_dsl (&self, token: &str) -> bool {
|
||||
//if let Some(event) = KeyMatcher::new(token).build() {
|
||||
//&event == self.event()
|
||||
//} else {
|
||||
//false
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue