From 2afae4b6aa32417538d854b24b6a1efbaefcc813 Mon Sep 17 00:00:00 2001 From: unspeaker Date: Sun, 12 Jan 2025 23:39:26 +0100 Subject: [PATCH] wip: some meandering and then it clicked --- edn/src/edn_provide.rs | 38 +++--- output/src/edn_view.rs | 286 +++++++++++++++++------------------------ tek/src/view.rs | 2 +- 3 files changed, 141 insertions(+), 185 deletions(-) diff --git a/edn/src/edn_provide.rs b/edn/src/edn_provide.rs index 83ee1791..9a79c80a 100644 --- a/edn/src/edn_provide.rs +++ b/edn/src/edn_provide.rs @@ -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 > (&$self, edn: &EdnItem) -> Option<$type> { - //Some(match edn.to_ref() { - //$(EdnItem::Sym($pat) => $expr),*, - //_ => return None - //}) - //} - //} - impl EdnProvide<$type> for $State { - fn get > (&$self, edn: &EdnItem) -> Option<$type> { + ($lt:lifetime: $type:ty:|$self:ident:$State:ty|{ $($pat:pat => $expr:expr),* $(,)? }) => { + impl<$lt> EdnProvide<$lt, $type> for $State { + fn get > (&$lt $self, edn: &$lt EdnItem) -> 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 > (&'a $self, edn: &'a EdnItem) -> 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 { - fn get > (&self, _edn: &EdnItem) -> Option { +pub trait EdnProvide<'a, U> { + fn get > (&'a self, _edn: &'a EdnItem) -> Option { None } - fn get_or_fail > (&self, edn: &EdnItem) -> U { + fn get_or_fail > (&'a self, edn: &'a EdnItem) -> U { self.get(edn).expect("no value") } } -impl, U> EdnProvide for &T { - fn get > (&self, edn: &EdnItem) -> Option { +impl<'a, T: EdnProvide<'a, U>, U> EdnProvide<'a, U> for &T { + fn get > (&'a self, edn: &'a EdnItem) -> Option { (*self).get(edn) } - fn get_or_fail > (&self, edn: &EdnItem) -> U { + fn get_or_fail > (&'a self, edn: &'a EdnItem) -> U { (*self).get_or_fail(edn) } } diff --git a/output/src/edn_view.rs b/output/src/edn_view.rs index 7f7e9fb1..613ab0a0 100644 --- a/output/src/edn_view.rs +++ b/output/src/edn_view.rs @@ -6,119 +6,83 @@ pub type EdnCallback<'a, O, State> = pub type EdnRenderCallback<'a, O, State> = Box>; /// Provides values to the template -pub trait EdnViewData: - EdnProvide + - EdnProvide + - EdnProvide + - EdnProvide>> +pub trait EdnViewData<'a, E: Output>: + EdnProvide<'a, bool> + + EdnProvide<'a, usize> + + EdnProvide<'a, E::Unit> + + EdnProvide<'a, Box + '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 (&self, item: EdnItem<&str>) -> E::Unit { - match &item { - Num(n) => (*n as u16).into(), - _ => 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_content <'a> (&'a self, item: EdnItem<&str>) -> Box + 'a> where E: 'a { - match item.to_ref() { + fn arg (&'a self, item: &'a EdnItem<&'a str>) -> Option where Self: EdnProvide<'a, T> { + EdnProvide::::get(self, item) + } + fn item (&'a self, item: &'a EdnItem<&'a str>) -> Option + 'a>> { + self.get(item) + } + fn get_content (&'a self, item: &'a EdnItem<&'a str>) -> Box + '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: //panic!("no content") } } -impl EdnViewData for T where T: - EdnProvide + - EdnProvide + - EdnProvide + - EdnProvide>> +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 + 'a>> {} /// Renders from EDN source and context. #[derive(Default)] -pub enum EdnView> { +pub enum EdnView<'a, E: Output, T: EdnViewData<'a, E>> { #[default] Inert, - _Unused(PhantomData), - Ok(T, EdnItem), + _Unused(PhantomData<&'a E>), + Ok(T, EdnItem<&'a str>), //render: BoxBox + Send + Sync + 'a> + Send + Sync + 'a> Err(String) } -impl> EdnView { - 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>) -> Self { + Self::Ok(state, EdnItem::Exp(items)) } } -impl + Send + Sync> Content for EdnView { +implEdnViewData<'a, E> + Send + Sync> Content for EdnView<'_, E, T> { fn content (&self) -> impl Render { - 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> ( - s: &'a State, - head: &EdnItem<&str>, - tail: &'a [EdnItem] -) -> Box + 'a> { - match (head, tail) { +//fn match_exp <'a, E: Output + 'a, State: EdnViewData<'a, E>> ( + //s: &'a State, + //head: &EdnItem<&str>, + //tail: &'a [EdnItem] +//) -> Box + '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) + //} +//} diff --git a/tek/src/view.rs b/tek/src/view.rs index 9708f01e..e5b55980 100644 --- a/tek/src/view.rs +++ b/tek/src/view.rs @@ -1,6 +1,6 @@ use crate::*; render!(TuiOut: (self: App) => self.size.of(EdnView::from_source(self, self.edn.as_ref()))); -edn_provide!(Box>: |self: App|{ +edn_provide!('a: Box + 'a>: |self: App|{ ":editor" => (&self.editor).boxed(), ":inputs" => self.input_row(self.w(), 3).boxed(), ":outputs" => self.output_row(self.w(), 3).boxed(),