fokken wip

This commit is contained in:
facile pop culture reference 2026-06-16 14:23:03 +03:00
parent be14173126
commit 2dc501c184
11 changed files with 129 additions and 136 deletions

View file

@ -59,23 +59,16 @@ macro_rules! eval_enum ((
/// Interpret layout operation.
///
/// ```
/// # use tengri::{lang::*, draw::*, eval::*};
/// struct Target { xywh: XYWH<u16> /*platform-specific*/}
/// impl tengri::Out for Target {
/// type Unit = u16;
/// fn area (&self) -> XYWH<u16> { self.xywh }
/// fn area_mut (&mut self) -> &mut XYWH<u16> { &mut self.xywh }
/// fn show <'t, T: Draw<Self> + ?Sized> (&mut self, area: XYWH<u16>, content: &'t T) {}
/// }
/// # use tengri::{lang::*, draw::*, eval::*, term::*};
///
/// struct State {/*app-specific*/}
/// impl<'b> Namespace<'b, bool> for State {}
/// impl<'b> Namespace<'b, u16> for State {}
/// impl Interpret<Target, ()> for State {}
/// impl Interpret<Tui, XYWH<u16>> for State {}
///
/// # fn main () -> tengri::Usually<()> {
/// let state = State {};
/// let mut target = Target { xywh: Default::default() };
/// let mut target = Tui::new(80, 25);
/// eval_view(&state, &mut target, &"")?;
/// eval_view(&state, &mut target, &"(when true (text hello))")?;
/// eval_view(&state, &mut target, &"(either true (text hello) (text world))")?;
@ -197,13 +190,15 @@ pub fn eval_view_tui <'a, S> (
match frags.next() {
Some("text") => {
if let Some(src) = args?.src()? { output.place(&src) }
if let Some(src) = args?.src()? {
output.show(output.xywh(), &src)
}
},
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"));
output.place(&fg(color, thunk(move|output: &mut Tui|{
output.show(output.xywh(), &fg(color, thunk(move|output: &mut Tui|{
state.interpret(output, &arg1)?;
// FIXME?: don't max out the used area?
Ok(output.area().into())
@ -211,9 +206,9 @@ pub fn eval_view_tui <'a, S> (
},
Some("bg") => {
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"));
output.place(&bg(color, thunk(move|output: &mut Tui|{
output.show(output.xywh(), &bg(color, thunk(move|output: &mut Tui|{
state.interpret(output, &arg1)?;
// FIXME?: don't max out the used area?
Ok(output.area().into())