mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
extract match_exp
This commit is contained in:
parent
9a70fbc416
commit
3975837393
3 changed files with 56 additions and 48 deletions
|
|
@ -50,7 +50,7 @@ impl EdnItem<&str> {
|
|||
}
|
||||
}
|
||||
}
|
||||
impl<T: AsRef<str> + PartialEq + Default + Clone + std::fmt::Debug> EdnItem<T> {
|
||||
impl<T: AsRef<str>> EdnItem<T> {
|
||||
pub fn to_ref (&self) -> EdnItem<&str> {
|
||||
match self {
|
||||
Self::Nil => EdnItem::Nil,
|
||||
|
|
|
|||
|
|
@ -46,7 +46,26 @@ impl<E: Output, T: EdnViewData<E> + Send + Sync> Content<E> for EdnView<E, T> {
|
|||
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() {
|
||||
let head = &head.to_ref();
|
||||
match_exp(s, &head.to_ref(), &tail)
|
||||
} else {
|
||||
panic!("todo: add error handling to content() chain. invalid expression {e:?}");
|
||||
().boxed()
|
||||
},
|
||||
},
|
||||
Self::Err(error) => {
|
||||
Box::new(())//&format!("EdnView error: {error:?}"))
|
||||
},
|
||||
_ => 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) {
|
||||
|
||||
(Key("align/c"), [a]) => Align::c(s.get_content(a.to_ref())).boxed(),
|
||||
|
|
@ -86,16 +105,4 @@ impl<E: Output, T: EdnViewData<E> + Send + Sync> Content<E> for EdnView<E, T> {
|
|||
|
||||
_ => todo!("{:?} {:?}", &head, &tail)
|
||||
}
|
||||
} else {
|
||||
panic!("todo: add error handling to content() chain. invalid expression {e:?}")
|
||||
},
|
||||
},
|
||||
Self::Err(error) => {
|
||||
Box::new(())//&format!("EdnView error: {error:?}"))
|
||||
},
|
||||
_ => todo!()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,12 +5,6 @@ use EdnItem::*;
|
|||
|
||||
const EDN: &'static str = include_str!("groovebox.edn");
|
||||
|
||||
//impl Content<TuiOut> for Groovebox {
|
||||
//fn content (&self) -> impl Render<TuiOut> {
|
||||
//self.size.of(EdnView::from_source(self, EDN))
|
||||
//}
|
||||
//}
|
||||
|
||||
// this works:
|
||||
render!(TuiOut: (self: Groovebox) => self.size.of(
|
||||
Bsp::s(self.toolbar_view(),
|
||||
|
|
@ -19,6 +13,13 @@ render!(TuiOut: (self: Groovebox) => self.size.of(
|
|||
Bsp::n(self.status_view(),
|
||||
Bsp::w(self.pool_view(), Fill::xy(Bsp::e(self.sampler_view(), &self.editor)))))))));
|
||||
|
||||
// this almost works:
|
||||
//impl Content<TuiOut> for Groovebox {
|
||||
//fn content (&self) -> impl Render<TuiOut> {
|
||||
//self.size.of(EdnView::from_source(self, EDN))
|
||||
//}
|
||||
//}
|
||||
|
||||
impl Groovebox {
|
||||
fn toolbar_view (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
Fill::x(Fixed::y(2, lay!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue