enable and patch up mod eval
Some checks are pending
/ build (push) Waiting to run

This commit is contained in:
same mf who else 2026-03-28 14:44:11 +02:00
parent c0d8c5f1bb
commit 0af46acf36
2 changed files with 16 additions and 11 deletions

View file

@ -1,4 +1,5 @@
use crate::*; use crate::{*, term::*, draw::*, ratatui::prelude::*};
use dizzle::*;
/// Interpret layout operation. /// Interpret layout operation.
/// ///
@ -165,7 +166,7 @@ use crate::*;
/// impl Understand<Tui, ()> for State {} /// impl Understand<Tui, ()> for State {}
/// # fn main () -> tengri::Usually<()> { /// # fn main () -> tengri::Usually<()> {
/// let state = State; /// 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, "")?;
/// tengri::eval_view_tui(&state, &mut out, "text Hello world!")?; /// tengri::eval_view_tui(&state, &mut out, "text Hello world!")?;
/// tengri::eval_view_tui(&state, &mut out, "fg (g 0) (text Hello world!)")?; /// tengri::eval_view_tui(&state, &mut out, "fg (g 0) (text Hello world!)")?;
@ -174,9 +175,9 @@ use crate::*;
/// # Ok(()) } /// # Ok(()) }
/// ``` /// ```
pub fn eval_view_tui <'a, S> ( 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<bool> where ) -> Usually<bool> where
S: Understand<TuiOut, ()> S: Understand<Tui, ()>
+ for<'b>Namespace<'b, bool> + for<'b>Namespace<'b, bool>
+ for<'b>Namespace<'b, u16> + for<'b>Namespace<'b, u16>
+ for<'b>Namespace<'b, Color> + for<'b>Namespace<'b, Color>
@ -199,18 +200,21 @@ pub fn eval_view_tui <'a, S> (
Some("fg") => { Some("fg") => {
let arg0 = arg0?.expect("fg: expected arg 0 (color)"); 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 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(&fg(color, thunk(move|output: &mut Tui|{
output.place(&TuiOut::fg(color, thunk)) state.understand(output, &arg1)?;
// FIXME?: don't max out the used area?
Ok(output.area().into())
})))
}, },
Some("bg") => { 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 arg0 = arg0?.expect("bg: expected arg 0 (color)");
let color = Namespace::namespace(state, arg0)?.unwrap_or_else(||panic!("bg: {arg0:?}: not a 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(&bg(color, thunk(move|output: &mut Tui|{
output.place(&TuiOut::bg(color, thunk)) state.understand(output, &arg1)?;
// FIXME?: don't max out the used area?
Ok(output.area().into())
})))
}, },
_ => return Ok(false) _ => return Ok(false)

View file

@ -25,6 +25,7 @@ pub(crate) use ::{
#[cfg(feature = "lang")] pub extern crate dizzle as lang; #[cfg(feature = "lang")] pub extern crate dizzle as lang;
#[cfg(feature = "lang")] pub use ::dizzle::{self, Usually, Perhaps, impl_default}; #[cfg(feature = "lang")] pub use ::dizzle::{self, Usually, Perhaps, impl_default};
#[cfg(feature = "lang")] pub mod eval;
#[cfg(feature = "time")] pub mod time; #[cfg(feature = "time")] pub mod time;