fix: orphaned fn
Some checks failed
/ build (push) Has been cancelled

This commit is contained in:
AAAAAAAAAAAAAAAAAAAAAAAAAAAA 2026-01-17 03:46:24 +02:00
parent 1344967f33
commit a933cbe285
4 changed files with 84 additions and 87 deletions

View file

@ -102,3 +102,47 @@ impl<T: TuiWidget + Send + Sync + 'static> TuiRun<T> for Arc<RwLock<Tui>> {
Ok(())
}
}
#[cfg(feature = "dsl")]
pub fn evaluate_output_expression_tui <'a, S> (
state: &S, mut output: &mut TuiOut, expr: impl DslExpr + 'a
) -> Usually<bool> where
S: View<TuiOut, ()>
+ for<'b>DslNs<'b, bool>
+ for<'b>DslNs<'b, u16>
+ for<'b>DslNs<'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 tail0 = args.tail();
let arg1 = tail0.head();
let tail1 = tail0.tail();
let arg2 = tail1.head();
match frags.next() {
Some("text") => if let Some(src) = args?.src()? { output.place(&src) },
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")),
Thunk::new(move|output: &mut TuiOut|state.view(output, &arg1).unwrap()),
))
},
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")),
Thunk::new(move|output: &mut TuiOut|state.view(output, &arg1).unwrap()),
))
},
_ => return Ok(false)
};
Ok(true)
}