dizzle: use procmacro in examples

This commit is contained in:
facile pop culture reference 2026-07-25 07:13:28 +03:00
parent 7a0459756e
commit be98e666f5
7 changed files with 53 additions and 61 deletions

View file

@ -146,7 +146,9 @@ pub fn eval_view <'a, O: Screen + 'a, S> (
Some("align") => thunk(move|output: &mut O|{
state.interpret(output, &arg0)
}).align(eval_enum!("align", output, state, frags.next(), arg0, Azimuth {
"c" => C, "n" => N, "s" => S, "e" => E, "w" => W, "x" => X, "y" => Y
"c" => C, "x" => X, "y" => Y,
"n" => N, "s" => S, "e" => E, "w" => W,
"nw" => NW, "sw" => SW, "ne" => NE, "se" => SE,
})).draw(output),
Some("exact") => eval_xy!(
"exact" => expr, head, output, state, frags.next(), exact_wh, exact_w, exact_h, arg0, arg1, arg2,
@ -176,27 +178,14 @@ pub fn eval_view <'a, O: Screen + 'a, S> (
/// ```
/// use tengri::{*, lang::*, ratatui::prelude::Color};
///
/// #[namespace(bool {})]
/// #[namespace(u8: try_to_u8)]
/// #[namespace(u16: try_to_u16)]
/// #[namespace(Color: try_to_color)]
/// #[namespace(bool)]
/// #[namespace(u8 try_to_u8)]
/// #[namespace(u16 try_to_u16)]
/// #[namespace(Color try_to_color)]
/// #[interpret(Tui -> Option<XYWH<u16>>: try_eval_tui)]
/// struct State;
/// tengri::lang::primitive!(u8: try_to_u8);
/// tengri::lang::primitive!(u16: try_to_u16);
/// tengri::lang::namespace!(State: bool {
/// });
/// tengri::lang::namespace!(State: u8 {
/// literal = |x|try_to_u8(x);
/// });
/// tengri::lang::namespace!(State: u16 {
/// literal = |x|try_to_u16(x);
/// });
/// tengri::lang::namespace!(State: Color {
/// expression = |_state| {
/// "g" (x: u8) => { ItemTheme::G[x as usize].base.term }
/// };
/// });
/// tengri::lang::interpret!(|self: State, context: Tui, lang|->Option<XYWH<u16>>{
/// expression = {
/// "text" (...rest) => { todo!() }