wip: some meandering and then it clicked

This commit is contained in:
🪞👃🪞 2025-01-12 23:39:26 +01:00
parent 8c54f8e426
commit 2afae4b6aa
3 changed files with 141 additions and 185 deletions

View file

@ -2,41 +2,43 @@ use crate::*;
/// Implement `EdnProvide` for a type and context
#[macro_export] macro_rules! edn_provide {
($type:ty:|$self:ident:$State:ty|{ $($pat:pat => $expr:expr),* $(,)? }) => {
//impl EdnProvide<$type> for $State {
//fn get <S: AsRef<str>> (&$self, edn: &EdnItem<S>) -> Option<$type> {
//Some(match edn.to_ref() {
//$(EdnItem::Sym($pat) => $expr),*,
//_ => return None
//})
//}
//}
impl EdnProvide<$type> for $State {
fn get <S: AsRef<str>> (&$self, edn: &EdnItem<S>) -> Option<$type> {
($lt:lifetime: $type:ty:|$self:ident:$State:ty|{ $($pat:pat => $expr:expr),* $(,)? }) => {
impl<$lt> EdnProvide<$lt, $type> for $State {
fn get <S: AsRef<str>> (&$lt $self, edn: &$lt EdnItem<S>) -> Option<$type> {
Some(match edn.to_ref() {
$(EdnItem::Sym($pat) => $expr),*,
_ => return None
})
}
}
};
($type:ty:|$self:ident:$State:ty|{ $($pat:pat => $expr:expr),* $(,)? }) => {
impl<'a> EdnProvide<'a, $type> for $State {
fn get <S: AsRef<str>> (&'a $self, edn: &'a EdnItem<S>) -> Option<$type> {
Some(match edn.to_ref() {
$(EdnItem::Sym($pat) => $expr),*,
_ => return None
})
}
}
};
}
/// Map EDN tokens to parameters of a given type for a given context
pub trait EdnProvide<U> {
fn get <S: AsRef<str>> (&self, _edn: &EdnItem<S>) -> Option<U> {
pub trait EdnProvide<'a, U> {
fn get <S: AsRef<str>> (&'a self, _edn: &'a EdnItem<S>) -> Option<U> {
None
}
fn get_or_fail <S: AsRef<str>> (&self, edn: &EdnItem<S>) -> U {
fn get_or_fail <S: AsRef<str>> (&'a self, edn: &'a EdnItem<S>) -> U {
self.get(edn).expect("no value")
}
}
impl<T: EdnProvide<U>, U> EdnProvide<U> for &T {
fn get <S: AsRef<str>> (&self, edn: &EdnItem<S>) -> Option<U> {
impl<'a, T: EdnProvide<'a, U>, U> EdnProvide<'a, U> for &T {
fn get <S: AsRef<str>> (&'a self, edn: &'a EdnItem<S>) -> Option<U> {
(*self).get(edn)
}
fn get_or_fail <S: AsRef<str>> (&self, edn: &EdnItem<S>) -> U {
fn get_or_fail <S: AsRef<str>> (&'a self, edn: &'a EdnItem<S>) -> U {
(*self).get_or_fail(edn)
}
}

View file

@ -6,119 +6,83 @@ pub type EdnCallback<'a, O, State> =
pub type EdnRenderCallback<'a, O, State> =
Box<EdnCallback<'a, O, State>>;
/// Provides values to the template
pub trait EdnViewData<E: Output>:
EdnProvide<bool> +
EdnProvide<usize> +
EdnProvide<E::Unit> +
EdnProvide<Box<dyn Render<E>>>
pub trait EdnViewData<'a, E: Output>:
EdnProvide<'a, bool> +
EdnProvide<'a, usize> +
EdnProvide<'a, E::Unit> +
EdnProvide<'a, Box<dyn Render<E> + 'a>>
{
fn get_bool (&self, item: EdnItem<&str>) -> bool {
fn get_bool (&'a self, item: &'a EdnItem<&str>) -> bool {
match &item {
Num(0) => false,
Num(_) => true,
Sym(":true") | Sym(":t") => true,
Sym(":false") | Sym(":f") => false,
_ => EdnProvide::get_or_fail(self, &item)
_ => EdnProvide::get_or_fail(self, item)
}
}
fn get_usize (&self, item: EdnItem<&str>) -> usize {
match &item {
Num(n) => *n,
_ => EdnProvide::get_or_fail(self, &item)
fn get_usize (&'a self, item: &'a EdnItem<&str>) -> usize {
match &item { Num(n) => *n, _ => EdnProvide::get_or_fail(self, item) }
}
fn get_unit (&'a self, item: &'a EdnItem<&str>) -> E::Unit {
match &item { Num(n) => (*n as u16).into(), _ => EdnProvide::get_or_fail(self, item) }
}
fn get_unit (&self, item: EdnItem<&str>) -> E::Unit {
match &item {
Num(n) => (*n as u16).into(),
_ => EdnProvide::get_or_fail(self, &item)
fn arg <T> (&'a self, item: &'a EdnItem<&'a str>) -> Option<T> where Self: EdnProvide<'a, T> {
EdnProvide::<T>::get(self, item)
}
fn item (&'a self, item: &'a EdnItem<&'a str>) -> Option<Box<dyn Render<E> + 'a>> {
self.get(item)
}
fn get_content <'a> (&'a self, item: EdnItem<&str>) -> Box<dyn Render<E> + 'a> where E: 'a {
match item.to_ref() {
fn get_content (&'a self, item: &'a EdnItem<&'a str>) -> Box<dyn Render<E> + 'a> where E: 'a {
match item {
Nil => Box::new(()),
Exp(e) => if let [head, tail @ ..] = e.as_slice() {
match (head, tail) {
(Key("when"), [c, a]) => When(
self.get_bool(c.to_ref()),
self.get_content(a.to_ref())).boxed(),
(Key("either"),[c, a, b]) => Either(
self.get_bool(c.to_ref()),
self.get_content(a.to_ref()),
self.get_content(b.to_ref())).boxed(),
(Key("when"), [c, a]) =>
When(self.arg(c).unwrap(), self.item(a)).boxed(),
(Key("either"), [c, a, b]) =>
Either(self.arg(c).unwrap(), self.item(a), self.item(b)).boxed(),
(Key("align/c"), [a]) => Align::c(
self.get_content(a.to_ref())).boxed(),
(Key("align/x"), [a]) => Align::x(
self.get_content(a.to_ref())).boxed(),
(Key("align/y"), [a]) => Align::y(
self.get_content(a.to_ref())).boxed(),
(Key("align/n"), [a]) => Align::n(
self.get_content(a.to_ref())).boxed(),
(Key("align/s"), [a]) => Align::s(
self.get_content(a.to_ref())).boxed(),
(Key("align/e"), [a]) => Align::e(
self.get_content(a.to_ref())).boxed(),
(Key("align/w"), [a]) => Align::w(
self.get_content(a.to_ref())).boxed(),
(Key("align/nw"), [a]) => Align::nw(
self.get_content(a.to_ref())).boxed(),
(Key("align/ne"), [a]) => Align::ne(
self.get_content(a.to_ref())).boxed(),
(Key("align/sw"), [a]) => Align::sw(
self.get_content(a.to_ref())).boxed(),
(Key("align/se"), [a]) => Align::se(
self.get_content(a.to_ref())).boxed(),
(Key("align/c"), [a]) => Align::c(self.item(a)).boxed(),
(Key("align/x"), [a]) => Align::x(self.item(a)).boxed(),
(Key("align/y"), [a]) => Align::y(self.item(a)).boxed(),
(Key("align/n"), [a]) => Align::n(self.item(a)).boxed(),
(Key("align/s"), [a]) => Align::s(self.item(a)).boxed(),
(Key("align/e"), [a]) => Align::e(self.item(a)).boxed(),
(Key("align/w"), [a]) => Align::w(self.item(a)).boxed(),
(Key("align/nw"), [a]) => Align::nw(self.item(a)).boxed(),
(Key("align/ne"), [a]) => Align::ne(self.item(a)).boxed(),
(Key("align/sw"), [a]) => Align::sw(self.item(a)).boxed(),
(Key("align/se"), [a]) => Align::se(self.item(a)).boxed(),
(Key("bsp/a"), [a, b]) => Bsp::a(
self.get_content(a.to_ref()), self.get_content(b.to_ref()),).boxed(),
(Key("bsp/b"), [a, b]) => Bsp::b(
self.get_content(a.to_ref()), self.get_content(b.to_ref()),).boxed(),
(Key("bsp/e"), [a, b]) => Bsp::e(
self.get_content(a.to_ref()), self.get_content(b.to_ref()),).boxed(),
(Key("bsp/n"), [a, b]) => Bsp::n(
self.get_content(a.to_ref()), self.get_content(b.to_ref()),).boxed(),
(Key("bsp/s"), [a, b]) => Bsp::s(
self.get_content(a.to_ref()), self.get_content(b.to_ref()),).boxed(),
(Key("bsp/w"), [a, b]) => Bsp::w(
self.get_content(a.to_ref()), self.get_content(b.to_ref()),).boxed(),
(Key("bsp/a"), [a, b]) => Bsp::a(self.item(a), self.item(b),).boxed(),
(Key("bsp/b"), [a, b]) => Bsp::b(self.item(a), self.item(b),).boxed(),
(Key("bsp/e"), [a, b]) => Bsp::e(self.item(a), self.item(b),).boxed(),
(Key("bsp/n"), [a, b]) => Bsp::n(self.item(a), self.item(b),).boxed(),
(Key("bsp/s"), [a, b]) => Bsp::s(self.item(a), self.item(b),).boxed(),
(Key("bsp/w"), [a, b]) => Bsp::w(self.item(a), self.item(b),).boxed(),
(Key("fill/x"), [a]) => Fill::x(
self.get_content(a.to_ref())).boxed(),
(Key("fill/y"), [a]) => Fill::y(
self.get_content(a.to_ref())).boxed(),
(Key("fill/xy"), [a]) => Fill::xy(
self.get_content(a.to_ref())).boxed(),
(Key("fill/x"), [a]) => Fill::x(self.item(a)).boxed(),
(Key("fill/y"), [a]) => Fill::y(self.item(a)).boxed(),
(Key("fill/xy"), [a]) => Fill::xy(self.item(a)).boxed(),
(Key("fixed/x"), [x, a]) => Fixed::x(
self.get_unit(x.to_ref()), self.get_content(a.to_ref())).boxed(),
(Key("fixed/y"), [y, a]) => Fixed::y(
self.get_unit(y.to_ref()), self.get_content(a.to_ref())).boxed(),
(Key("fixed/xy"), [x, y, a]) => Fixed::xy(
self.get_unit(x.to_ref()), self.get_unit(y.to_ref()), self.get_content(a.to_ref())).boxed(),
(Key("fixed/x"), [x, a]) => Fixed::x(self.arg(x).unwrap(), self.item(a)).boxed(),
(Key("fixed/y"), [y, a]) => Fixed::y(self.arg(y).unwrap(), self.item(a)).boxed(),
(Key("fixed/xy"), [x, y, a]) => Fixed::xy(self.arg(x).unwrap(), self.arg(y).unwrap(), self.item(a)).boxed(),
(Key("max/x"), [x, a]) => Max::x(
self.get_unit(x.to_ref()), self.get_content(a.to_ref())).boxed(),
(Key("max/y"), [y, a]) => Max::y(
self.get_unit(y.to_ref()), self.get_content(a.to_ref())).boxed(),
(Key("max/x"), [x, a]) => Max::x(self.arg(x).unwrap(), self.item(a)).boxed(),
(Key("max/y"), [y, a]) => Max::y(self.arg(y).unwrap(), self.item(a)).boxed(),
(Key("push/x"), [x, a]) => Push::x(
self.get_unit(x.to_ref()), self.get_content(a.to_ref())).boxed(),
(Key("push/y"), [y, a]) => Push::y(
self.get_unit(y.to_ref()), self.get_content(a.to_ref())).boxed(),
(Key("push/x"), [x, a]) => Push::x(self.arg(x).unwrap(), self.item(a)).boxed(),
(Key("push/y"), [y, a]) => Push::y(self.arg(y).unwrap(), self.item(a)).boxed(),
(Key("pad/x"), [x, a]) => Padding::x(
self.get_unit(x.to_ref()), self.get_content(a.to_ref())).boxed(),
(Key("pad/y"), [y, a]) => Padding::y(
self.get_unit(y.to_ref()), self.get_content(a.to_ref())).boxed(),
(Key("pad/xy"), [x, y, a]) => Padding::xy(
self.get_unit(x.to_ref()), self.get_unit(y.to_ref()), self.get_content(a.to_ref())).boxed(),
(Key("pad/x"), [x, a]) => Padding::x(self.arg(x).unwrap(), self.item(a)).boxed(),
(Key("pad/y"), [y, a]) => Padding::y(self.arg(y).unwrap(), self.item(a)).boxed(),
(Key("pad/xy"), [x, y, a]) => Padding::xy(self.arg(x).unwrap(), self.arg(y).unwrap(), self.item(a)).boxed(),
(Key("grow/x"), [x, a]) => Margin::x(
self.get_unit(x.to_ref()), self.get_content(a.to_ref())).boxed(),
(Key("grow/y"), [y, a]) => Margin::y(
self.get_unit(y.to_ref()), self.get_content(a.to_ref())).boxed(),
(Key("grow/xy"), [x, y, a]) => Margin::xy(
self.get_unit(x.to_ref()), self.get_unit(y.to_ref()), self.get_content(a.to_ref())).boxed(),
(Key("grow/x"), [x, a]) => Margin::x(self.arg(x).unwrap(), self.item(a)).boxed(),
(Key("grow/y"), [y, a]) => Margin::y(self.arg(y).unwrap(), self.item(a)).boxed(),
(Key("grow/xy"), [x, y, a]) => Margin::xy(self.arg(x).unwrap(), self.arg(y).unwrap(), self.item(a)).boxed(),
_ => todo!("{:?} {:?}", &head, &tail)
}
@ -130,117 +94,107 @@ pub trait EdnViewData<E: Output>:
//panic!("no content")
}
}
impl<E: Output, T> EdnViewData<E> for T where T:
EdnProvide<bool> +
EdnProvide<usize> +
EdnProvide<E::Unit> +
EdnProvide<Box<dyn Render<E>>>
impl<'a, E: Output, T> EdnViewData<'a, E> for T where T:
EdnProvide<'a, bool> +
EdnProvide<'a, usize> +
EdnProvide<'a, E::Unit> +
EdnProvide<'a, Box<dyn Render<E> + 'a>>
{}
/// Renders from EDN source and context.
#[derive(Default)]
pub enum EdnView<E: Output, T: EdnViewData<E>> {
pub enum EdnView<'a, E: Output, T: EdnViewData<'a, E>> {
#[default]
Inert,
_Unused(PhantomData<E>),
Ok(T, EdnItem<String>),
_Unused(PhantomData<&'a E>),
Ok(T, EdnItem<&'a str>),
//render: Box<dyn Fn(&'a T)->Box<dyn Render<E> + Send + Sync + 'a> + Send + Sync + 'a>
Err(String)
}
impl<E: Output, T: EdnViewData<E>> EdnView<E, T> {
pub fn from_source (state: T, source: &str) -> Self {
impl<'a, E: Output, T: EdnViewData<'a, E>> EdnView<'a, E, T> {
pub fn from_source (state: T, source: &'a str) -> Self {
match EdnItem::read_one(&source) {
Ok((layout, _)) => Self::Ok(state, layout),
Err(error) => Self::Err(format!("{error}"))
}
}
pub fn from_items (state: T, items: &[EdnItem<&str>]) -> Self {
Self::Ok(state, EdnItem::Exp(items.iter().map(|i|(*i).clone()).collect()))
pub fn from_items (state: T, items: Vec<EdnItem<&'a str>>) -> Self {
Self::Ok(state, EdnItem::Exp(items))
}
}
impl<E: Output, T: EdnViewData<E> + Send + Sync> Content<E> for EdnView<E, T> {
impl<E: Output, T: for<'a>EdnViewData<'a, E> + Send + Sync> Content<E> for EdnView<'_, E, T> {
fn content (&self) -> impl Render<E> {
use EdnItem::*;
match self {
Self::Ok(s, layout) => match layout {
Nil => ().boxed(),
Sym(t) => s.get_content(Sym(t.as_str())).boxed(),
Key(t) => panic!("todo: add error handling to content() chain. unexpected key {t}"),
Num(n) => panic!("todo: add error handling to content() chain. unexpected num {n}"),
Exp(e) => if let [head, tail @ ..] = e.as_slice() {
match_exp(s, &head.to_ref(), &tail)
} else {
panic!("todo: add error handling to content() chain. invalid expression {e:?}");
},
Self::Ok(state, layout) => {
state.get_content(layout)
},
Self::Err(_error) => {
Box::new(())//&format!("EdnView error: {error:?}")) // FIXME: String is not Render
},
_ => todo!()
}
}
}
fn match_exp <'a, E: Output + 'a, State: EdnViewData<E>> (
s: &'a State,
head: &EdnItem<&str>,
tail: &'a [EdnItem<String>]
) -> Box<dyn Render<E> + 'a> {
match (head, tail) {
//fn match_exp <'a, E: Output + 'a, State: EdnViewData<'a, E>> (
//s: &'a State,
//head: &EdnItem<&str>,
//tail: &'a [EdnItem<String>]
//) -> Box<dyn Render<E> + 'a> {
//match (head, tail) {
(Key("when"), [c, a]) => When(
s.get_bool(c.to_ref()),
s.get_content(a.to_ref())).boxed(),
//(Key("when"), [c, a]) => When(
//s.get_bool(c.to_ref()),
//s.get_content(a.to_ref())).boxed(),
(Key("either"),[c, a, b]) => Either(
s.get_bool(c.to_ref()),
s.get_content(a.to_ref()),
s.get_content(b.to_ref())).boxed(),
//(Key("either"),[c, a, b]) => Either(
//s.get_bool(c.to_ref()),
//s.get_content(a.to_ref()),
//s.get_content(b.to_ref())).boxed(),
(Key("align/c"), [a]) => Align::c(s.get_content(a.to_ref())).boxed(),
(Key("align/x"), [a]) => Align::x(s.get_content(a.to_ref())).boxed(),
(Key("align/y"), [a]) => Align::y(s.get_content(a.to_ref())).boxed(),
(Key("align/n"), [a]) => Align::n(s.get_content(a.to_ref())).boxed(),
(Key("align/s"), [a]) => Align::s(s.get_content(a.to_ref())).boxed(),
(Key("align/e"), [a]) => Align::e(s.get_content(a.to_ref())).boxed(),
(Key("align/w"), [a]) => Align::w(s.get_content(a.to_ref())).boxed(),
(Key("align/nw"), [a]) => Align::nw(s.get_content(a.to_ref())).boxed(),
(Key("align/ne"), [a]) => Align::ne(s.get_content(a.to_ref())).boxed(),
(Key("align/sw"), [a]) => Align::sw(s.get_content(a.to_ref())).boxed(),
(Key("align/se"), [a]) => Align::se(s.get_content(a.to_ref())).boxed(),
//(Key("align/c"), [a]) => Align::c(s.get_content(a.to_ref())).boxed(),
//(Key("align/x"), [a]) => Align::x(s.get_content(a.to_ref())).boxed(),
//(Key("align/y"), [a]) => Align::y(s.get_content(a.to_ref())).boxed(),
//(Key("align/n"), [a]) => Align::n(s.get_content(a.to_ref())).boxed(),
//(Key("align/s"), [a]) => Align::s(s.get_content(a.to_ref())).boxed(),
//(Key("align/e"), [a]) => Align::e(s.get_content(a.to_ref())).boxed(),
//(Key("align/w"), [a]) => Align::w(s.get_content(a.to_ref())).boxed(),
//(Key("align/nw"), [a]) => Align::nw(s.get_content(a.to_ref())).boxed(),
//(Key("align/ne"), [a]) => Align::ne(s.get_content(a.to_ref())).boxed(),
//(Key("align/sw"), [a]) => Align::sw(s.get_content(a.to_ref())).boxed(),
//(Key("align/se"), [a]) => Align::se(s.get_content(a.to_ref())).boxed(),
(Key("bsp/a"), [a, b]) => Bsp::a(s.get_content(a.to_ref()), s.get_content(b.to_ref()),).boxed(),
(Key("bsp/b"), [a, b]) => Bsp::b(s.get_content(a.to_ref()), s.get_content(b.to_ref()),).boxed(),
(Key("bsp/e"), [a, b]) => Bsp::e(s.get_content(a.to_ref()), s.get_content(b.to_ref()),).boxed(),
(Key("bsp/n"), [a, b]) => Bsp::n(s.get_content(a.to_ref()), s.get_content(b.to_ref()),).boxed(),
(Key("bsp/s"), [a, b]) => Bsp::s(s.get_content(a.to_ref()), s.get_content(b.to_ref()),).boxed(),
(Key("bsp/w"), [a, b]) => Bsp::w(s.get_content(a.to_ref()), s.get_content(b.to_ref()),).boxed(),
//(Key("bsp/a"), [a, b]) => Bsp::a(s.get_content(a.to_ref()), s.get_content(b.to_ref()),).boxed(),
//(Key("bsp/b"), [a, b]) => Bsp::b(s.get_content(a.to_ref()), s.get_content(b.to_ref()),).boxed(),
//(Key("bsp/e"), [a, b]) => Bsp::e(s.get_content(a.to_ref()), s.get_content(b.to_ref()),).boxed(),
//(Key("bsp/n"), [a, b]) => Bsp::n(s.get_content(a.to_ref()), s.get_content(b.to_ref()),).boxed(),
//(Key("bsp/s"), [a, b]) => Bsp::s(s.get_content(a.to_ref()), s.get_content(b.to_ref()),).boxed(),
//(Key("bsp/w"), [a, b]) => Bsp::w(s.get_content(a.to_ref()), s.get_content(b.to_ref()),).boxed(),
(Key("fill/x"), [a]) => Fill::x(s.get_content(a.to_ref())).boxed(),
(Key("fill/y"), [a]) => Fill::y(s.get_content(a.to_ref())).boxed(),
(Key("fill/xy"), [a]) => Fill::xy(s.get_content(a.to_ref())).boxed(),
//(Key("fill/x"), [a]) => Fill::x(s.get_content(a.to_ref())).boxed(),
//(Key("fill/y"), [a]) => Fill::y(s.get_content(a.to_ref())).boxed(),
//(Key("fill/xy"), [a]) => Fill::xy(s.get_content(a.to_ref())).boxed(),
(Key("fixed/x"), [x, a]) => Fixed::x(s.get_unit(x.to_ref()), s.get_content(a.to_ref())).boxed(),
(Key("fixed/y"), [y, a]) => Fixed::y(s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
(Key("fixed/xy"), [x, y, a]) => Fixed::xy(s.get_unit(x.to_ref()), s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
//(Key("fixed/x"), [x, a]) => Fixed::x(s.get_unit(x.to_ref()), s.get_content(a.to_ref())).boxed(),
//(Key("fixed/y"), [y, a]) => Fixed::y(s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
//(Key("fixed/xy"), [x, y, a]) => Fixed::xy(s.get_unit(x.to_ref()), s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
(Key("max/x"), [x, a]) => Max::x(s.get_unit(x.to_ref()), s.get_content(a.to_ref())).boxed(),
(Key("max/y"), [y, a]) => Max::y(s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
//(Key("max/x"), [x, a]) => Max::x(s.get_unit(x.to_ref()), s.get_content(a.to_ref())).boxed(),
//(Key("max/y"), [y, a]) => Max::y(s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
(Key("push/x"), [x, a]) => Push::x(s.get_unit(x.to_ref()), s.get_content(a.to_ref())).boxed(),
(Key("push/y"), [y, a]) => Push::y(s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
//(Key("push/x"), [x, a]) => Push::x(s.get_unit(x.to_ref()), s.get_content(a.to_ref())).boxed(),
//(Key("push/y"), [y, a]) => Push::y(s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
(Key("pad/x"), [x, a]) => Padding::x(s.get_unit(x.to_ref()), s.get_content(a.to_ref())).boxed(),
(Key("pad/y"), [y, a]) => Padding::y(s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
(Key("pad/xy"), [x, y, a]) => Padding::xy(s.get_unit(x.to_ref()), s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
//(Key("pad/x"), [x, a]) => Padding::x(s.get_unit(x.to_ref()), s.get_content(a.to_ref())).boxed(),
//(Key("pad/y"), [y, a]) => Padding::y(s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
//(Key("pad/xy"), [x, y, a]) => Padding::xy(s.get_unit(x.to_ref()), s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
(Key("grow/x"), [x, a]) => Margin::x(s.get_unit(x.to_ref()), s.get_content(a.to_ref())).boxed(),
(Key("grow/y"), [y, a]) => Margin::y(s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
(Key("grow/xy"), [x, y, a]) => Margin::xy(s.get_unit(x.to_ref()), s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
//(Key("grow/x"), [x, a]) => Margin::x(s.get_unit(x.to_ref()), s.get_content(a.to_ref())).boxed(),
//(Key("grow/y"), [y, a]) => Margin::y(s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
//(Key("grow/xy"), [x, y, a]) => Margin::xy(s.get_unit(x.to_ref()), s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
_ => todo!("{:?} {:?}", &head, &tail)
}
}
//_ => todo!("{:?} {:?}", &head, &tail)
//}
//}

View file

@ -1,6 +1,6 @@
use crate::*;
render!(TuiOut: (self: App) => self.size.of(EdnView::from_source(self, self.edn.as_ref())));
edn_provide!(Box<dyn Render<TuiOut>>: |self: App|{
edn_provide!('a: Box<dyn Render<TuiOut> + 'a>: |self: App|{
":editor" => (&self.editor).boxed(),
":inputs" => self.input_row(self.w(), 3).boxed(),
":outputs" => self.output_row(self.w(), 3).boxed(),