mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
start implementing support for rendering edn keys
This commit is contained in:
parent
ab1301687d
commit
b80f5c5c70
1 changed files with 16 additions and 3 deletions
|
|
@ -35,11 +35,24 @@ impl<E: Engine, T: EdnLayout<E> + Send + Sync> Content<E> for EdnView<E, T> {
|
|||
fn content (&self) -> impl Render<E> {
|
||||
use EdnItem::*;
|
||||
match &self.layout {
|
||||
Nil => None,
|
||||
Sym(t) => Some(self.context.get_content(t.as_str())),
|
||||
Nil => ().boxed(),
|
||||
Sym(t) => self.context.get_content(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) => todo!("exp {e:?}"),
|
||||
Exp(e) => if let [head, tail @ ..] = e.as_slice() {
|
||||
let head = &head.to_ref();
|
||||
match (head, tail) {
|
||||
(Key("when"), [Sym(c), Sym(a)]) => When(
|
||||
self.context.get_bool(c.as_str()),
|
||||
self.context.get_content(a.as_str())).boxed(),
|
||||
(Key("bsp/s"), [Sym(a), Sym(b)]) => Bsp::s(
|
||||
self.context.get_content(a.as_str()),
|
||||
self.context.get_content(b.as_str())).boxed(),
|
||||
_ => todo!("{:?} {:?}", &head, &tail)
|
||||
}
|
||||
} else {
|
||||
panic!("todo: add error handling to content() chain. invalid expression {e:?}")
|
||||
},
|
||||
}
|
||||
//let items = &self.layout;
|
||||
//if let (Some(first), rest) = (items.get(0).map(EdnItem::to_str), &items[1..]) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue