mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-04-03 13:30:44 +02:00
This commit is contained in:
parent
c0d8c5f1bb
commit
0af46acf36
2 changed files with 16 additions and 11 deletions
26
src/eval.rs
26
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<Tui, ()> 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<bool> where
|
||||
S: Understand<TuiOut, ()>
|
||||
S: Understand<Tui, ()>
|
||||
+ 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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue