From 0af46acf3634ec2e2a44330adcf070868367589f Mon Sep 17 00:00:00 2001 From: same mf who else Date: Sat, 28 Mar 2026 14:44:11 +0200 Subject: [PATCH] enable and patch up mod eval --- src/eval.rs | 26 +++++++++++++++----------- src/lib.rs | 1 + 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/eval.rs b/src/eval.rs index d47aae6..0089ee3 100644 --- a/src/eval.rs +++ b/src/eval.rs @@ -1,4 +1,5 @@ -use crate::*; +use crate::{*, term::*, draw::*, ratatui::prelude::*}; +use dizzle::*; /// Interpret layout operation. /// @@ -165,7 +166,7 @@ use crate::*; /// impl Understand for State {} /// # fn main () -> tengri::Usually<()> { /// let state = State; -/// let mut out = TuiOut::default(); +/// let mut out = Tui::default(); /// tengri::eval_view_tui(&state, &mut out, "")?; /// tengri::eval_view_tui(&state, &mut out, "text Hello world!")?; /// tengri::eval_view_tui(&state, &mut out, "fg (g 0) (text Hello world!)")?; @@ -174,9 +175,9 @@ use crate::*; /// # Ok(()) } /// ``` pub fn eval_view_tui <'a, S> ( - state: &S, output: &mut Buffer, expr: impl Expression + 'a + state: &S, output: &mut Tui, expr: impl Expression + 'a ) -> Usually where - S: Understand + S: Understand + for<'b>Namespace<'b, bool> + for<'b>Namespace<'b, u16> + for<'b>Namespace<'b, Color> @@ -199,18 +200,21 @@ pub fn eval_view_tui <'a, S> ( Some("fg") => { let arg0 = arg0?.expect("fg: expected arg 0 (color)"); let color = Namespace::namespace(state, arg0)?.unwrap_or_else(||panic!("fg: {arg0:?}: not a color")); - let thunk = Thunk::new(move|output: &mut Buffer|state.understand(output, &arg1).unwrap()); - output.place(&TuiOut::fg(color, thunk)) + output.place(&fg(color, thunk(move|output: &mut Tui|{ + state.understand(output, &arg1)?; + // FIXME?: don't max out the used area? + Ok(output.area().into()) + }))) }, Some("bg") => { - //panic!("expr: {expr:?}\nhead: {head:?}\nfrags: {frags:?}\nargs: {args:?}\narg0: {arg0:?}\ntail0: {tail0:?}\narg1: {arg1:?}\ntail1: {tail1:?}\narg2: {arg2:?}"); - //panic!("head: {head:?}\narg0: {arg0:?}\narg1: {arg1:?}\narg2: {arg2:?}");; - //panic!("head: {head:?}\narg0: {arg0:?}\narg1: {arg1:?}\narg2: {arg2:?}"); let arg0 = arg0?.expect("bg: expected arg 0 (color)"); let color = Namespace::namespace(state, arg0)?.unwrap_or_else(||panic!("bg: {arg0:?}: not a color")); - let thunk = Thunk::new(move|output: &mut Buffer|state.understand(output, &arg1).unwrap()); - output.place(&TuiOut::bg(color, thunk)) + output.place(&bg(color, thunk(move|output: &mut Tui|{ + state.understand(output, &arg1)?; + // FIXME?: don't max out the used area? + Ok(output.area().into()) + }))) }, _ => return Ok(false) diff --git a/src/lib.rs b/src/lib.rs index 349ca17..4a1cbd3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,6 +25,7 @@ pub(crate) use ::{ #[cfg(feature = "lang")] pub extern crate dizzle as lang; #[cfg(feature = "lang")] pub use ::dizzle::{self, Usually, Perhaps, impl_default}; +#[cfg(feature = "lang")] pub mod eval; #[cfg(feature = "time")] pub mod time;