mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-01-31 10:56:41 +01:00
This commit is contained in:
parent
d06e1c41f8
commit
8a5bc7b6ea
4 changed files with 67 additions and 36 deletions
|
|
@ -88,7 +88,7 @@ impl<T: TuiWidget + Send + Sync + 'static> TuiRun<T> for Arc<RwLock<Tui>> {
|
|||
fn run (&self, state: &Arc<RwLock<T>>) -> Usually<()> {
|
||||
let _input_thread = TuiIn::run_input(self, state, Duration::from_millis(100));
|
||||
self.write().unwrap().setup()?;
|
||||
let render_thread = TuiOut::run_output(self, state, Duration::from_millis(10));
|
||||
let render_thread = TuiOut::run_output(self, state, Duration::from_millis(10))?;
|
||||
match render_thread.join() {
|
||||
Ok(result) => {
|
||||
self.write().unwrap().teardown()?;
|
||||
|
|
@ -96,7 +96,7 @@ impl<T: TuiWidget + Send + Sync + 'static> TuiRun<T> for Arc<RwLock<Tui>> {
|
|||
},
|
||||
Err(error) => {
|
||||
self.write().unwrap().teardown()?;
|
||||
panic!("\n\rDraw thread failed: {error:?}.\n\r")
|
||||
panic!("\n\rDraw thread failed: error={error:?}.\n\r")
|
||||
},
|
||||
}
|
||||
Ok(())
|
||||
|
|
@ -105,22 +105,22 @@ impl<T: TuiWidget + Send + Sync + 'static> TuiRun<T> for Arc<RwLock<Tui>> {
|
|||
|
||||
#[cfg(feature = "dsl")]
|
||||
pub fn evaluate_output_expression_tui <'a, S> (
|
||||
state: &S, mut output: &mut TuiOut, expr: impl DslExpr + 'a
|
||||
state: &S, output: &mut TuiOut, expr: impl Expression + 'a
|
||||
) -> Usually<bool> where
|
||||
S: View<TuiOut, ()>
|
||||
+ for<'b>DslNs<'b, bool>
|
||||
+ for<'b>DslNs<'b, u16>
|
||||
+ for<'b>DslNs<'b, Color>
|
||||
+ for<'b>Namespace<'b, bool>
|
||||
+ for<'b>Namespace<'b, u16>
|
||||
+ for<'b>Namespace<'b, Color>
|
||||
{
|
||||
// See `tengri_output::evaluate_output_expression`
|
||||
let head = expr.head()?;
|
||||
let mut frags = head.src()?.unwrap_or_default().split("/");
|
||||
let args = expr.tail();
|
||||
let arg0 = args.head();
|
||||
let args = expr.tail();
|
||||
let arg0 = args.head();
|
||||
let tail0 = args.tail();
|
||||
let arg1 = tail0.head();
|
||||
let arg1 = tail0.head();
|
||||
let tail1 = tail0.tail();
|
||||
let arg2 = tail1.head();
|
||||
let _arg2 = tail1.head();
|
||||
match frags.next() {
|
||||
|
||||
Some("text") => if let Some(src) = args?.src()? { output.place(&src) },
|
||||
|
|
@ -128,7 +128,7 @@ pub fn evaluate_output_expression_tui <'a, S> (
|
|||
Some("fg") => {
|
||||
let arg0 = arg0?.expect("fg: expected arg 0 (color)");
|
||||
output.place(&Tui::fg(
|
||||
DslNs::<Color>::from(state, arg0)?.unwrap_or_else(||panic!("fg: {arg0:?}: not a color")),
|
||||
Namespace::<Color>::resolve(state, arg0)?.unwrap_or_else(||panic!("fg: {arg0:?}: not a color")),
|
||||
Thunk::new(move|output: &mut TuiOut|state.view(output, &arg1).unwrap()),
|
||||
))
|
||||
},
|
||||
|
|
@ -136,7 +136,7 @@ pub fn evaluate_output_expression_tui <'a, S> (
|
|||
Some("bg") => {
|
||||
let arg0 = arg0?.expect("bg: expected arg 0 (color)");
|
||||
output.place(&Tui::bg(
|
||||
DslNs::<Color>::from(state, arg0)?.unwrap_or_else(||panic!("bg: {arg0:?}: not a color")),
|
||||
Namespace::<Color>::resolve(state, arg0)?.unwrap_or_else(||panic!("bg: {arg0:?}: not a color")),
|
||||
Thunk::new(move|output: &mut TuiOut|state.view(output, &arg1).unwrap()),
|
||||
))
|
||||
},
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ impl TuiEvent {
|
|||
Self(event)
|
||||
}
|
||||
#[cfg(feature = "dsl")]
|
||||
pub fn from_dsl (dsl: impl Dsl) -> Perhaps<Self> {
|
||||
pub fn from_dsl (dsl: impl Language) -> Perhaps<Self> {
|
||||
Ok(TuiKey::from_dsl(dsl)?.to_crossterm().map(Self))
|
||||
}
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ pub struct TuiKey(Option<KeyCode>, KeyModifiers);
|
|||
impl TuiKey {
|
||||
const SPLIT: char = '/';
|
||||
#[cfg(feature = "dsl")]
|
||||
pub fn from_dsl (dsl: impl Dsl) -> Usually<Self> {
|
||||
pub fn from_dsl (dsl: impl Language) -> Usually<Self> {
|
||||
if let Some(word) = dsl.word()? {
|
||||
let word = word.trim();
|
||||
Ok(if word == ":char" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue