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
|
|
@ -5,7 +5,7 @@ use ::{
|
|||
};
|
||||
|
||||
tui_main!(State {
|
||||
cursor: 10,
|
||||
cursor: 0,
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
|
|
@ -20,11 +20,14 @@ tui_view!(|self: State| {
|
|||
let heading = format!("State {}/{} in {:?}", index, VIEWS.len(), &wh);
|
||||
let title = bg(Color::Rgb(60, 10, 10), heading.align_n().push_y(1));
|
||||
let code = bg(Color::Rgb(10, 60, 10), format!("{}", src).align_n().push_y(2));
|
||||
//let content = ;//();//bg(Color::Rgb(10, 10, 60), View(self, CstIter::new(src)));
|
||||
let widget = thunk(move|to: &mut Tui|self.interpret(to, &src).map(Some));
|
||||
let widget = thunk(move|to: &mut Tui|self.interpret(to, &src));
|
||||
self.size.of(south(title, north(code, widget)))
|
||||
});
|
||||
|
||||
#[dizzle::namespace(bool)]
|
||||
#[dizzle::namespace(u16)]
|
||||
#[dizzle::namespace(Option<u16>)]
|
||||
#[dizzle::namespace(Color)]
|
||||
#[derive(Debug, Default)]
|
||||
struct State {
|
||||
/** Command history (undo/redo). */
|
||||
|
|
@ -35,7 +38,16 @@ struct State {
|
|||
size: Sizer,
|
||||
}
|
||||
|
||||
impl Interpret<Tui, XYWH<u16>> for State {
|
||||
impl Interpret<Tui, Option<XYWH<u16>>> for State {
|
||||
fn interpret_expr <'a> (&'a self, to: &mut Tui, lang: &'a impl Expression) -> Drawn<u16> {
|
||||
Ok(Some(if let Some(area) = eval_view(self, to, lang)? {
|
||||
area
|
||||
} else if let Some(area) = eval_view_tui(self, to, lang)? {
|
||||
area
|
||||
} else {
|
||||
return Err(format!("App::interpret_expr: unexpected: {lang:?}").into())
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)] enum Action {
|
||||
|
|
@ -45,11 +57,6 @@ impl Interpret<Tui, XYWH<u16>> for State {
|
|||
Prev
|
||||
}
|
||||
|
||||
//impl_from!(Action: |input: &TuiIn| todo!());
|
||||
|
||||
fn draw_example (state: &State, to: &mut Tui) {
|
||||
}
|
||||
|
||||
impl Action {
|
||||
|
||||
const BINDS: &'static str = stringify! {
|
||||
|
|
@ -155,9 +162,11 @@ const VIEWS: &'static [&'static str] = &[
|
|||
|
||||
];
|
||||
|
||||
//namespace!(State: bool {});
|
||||
//namespace!(State: u16 {});
|
||||
//namespace!(State: Color {});
|
||||
//handle!(TuiIn: |self: State, input|Action::from(input).eval(self).map(|_|None));
|
||||
//view!(State: Tui: [ evaluate_output_expression, evaluate_output_expression_tui ]);
|
||||
//draw!(State: Tui: [ draw_example ]);
|
||||
|
||||
//impl_from!(Action: |input: &TuiIn| todo!());
|
||||
|
||||
//fn draw_example (state: &State, to: &mut Tui) {
|
||||
//}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue