mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-08-07 22:17:07 +02:00
dizzle: use procmacro in examples
This commit is contained in:
parent
7a0459756e
commit
be98e666f5
7 changed files with 53 additions and 61 deletions
25
src/eval.rs
25
src/eval.rs
|
|
@ -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!() }
|
||||
|
|
|
|||
|
|
@ -103,7 +103,10 @@ impl Tui {
|
|||
/// Implement standard [main] entrypoint for TUI apps.
|
||||
#[macro_export] macro_rules! tui_main {
|
||||
($state:expr) => {
|
||||
pub fn main () -> Usually<()> { tui_run_main(Arc::new(RwLock::new($state))) }
|
||||
pub fn main () -> Usually<()> {
|
||||
tui_setup_panic();
|
||||
tui_run_main(Arc::new(RwLock::new($state)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue