mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
implement more edn operators
This commit is contained in:
parent
7b3de1e68d
commit
cf9a031c0f
2 changed files with 39 additions and 51 deletions
|
|
@ -49,21 +49,42 @@ impl<E: Output, T: EdnViewData<E> + Send + Sync> Content<E> for EdnView<E, T> {
|
||||||
Exp(e) => if let [head, tail @ ..] = e.as_slice() {
|
Exp(e) => if let [head, tail @ ..] = e.as_slice() {
|
||||||
let head = &head.to_ref();
|
let head = &head.to_ref();
|
||||||
match (head, tail) {
|
match (head, tail) {
|
||||||
|
|
||||||
|
(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/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/w"), [a]) => Align::w(s.get_content(a.to_ref())).boxed(),
|
||||||
(Key("align/x"), [a]) => Align::x(s.get_content(a.to_ref())).boxed(),
|
(Key("align/nw"), [a]) => Align::nw(s.get_content(a.to_ref())).boxed(),
|
||||||
(Key("bsp/s"), [a, b]) => Bsp::s(s.get_content(a.to_ref()), s.get_content(b.to_ref()),).boxed(),
|
(Key("align/ne"), [a]) => Align::ne(s.get_content(a.to_ref())).boxed(),
|
||||||
(Key("bsp/n"), [a, b]) => Bsp::n(s.get_content(a.to_ref()), s.get_content(b.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/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/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/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/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/y"), [y, a]) => Fixed::y(s.get_unit(y.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("fixed/xy"), [xy, a]) => Fixed::xy(s.get_unit(xy.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/y"), [y, a]) => Max::y(s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
|
||||||
(Key("lay"), args) => Map(||args.iter(), |a, _|s.get_content(a.to_ref())).boxed(),
|
|
||||||
(Key("row"), args) => Map(||args.iter(), |a, _|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("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(),
|
||||||
|
|
||||||
_ => todo!("{:?} {:?}", &head, &tail)
|
_ => todo!("{:?} {:?}", &head, &tail)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -76,39 +97,5 @@ impl<E: Output, T: EdnViewData<E> + Send + Sync> Content<E> for EdnView<E, T> {
|
||||||
_ => todo!()
|
_ => todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
//let items = &self.layout;
|
|
||||||
//if let (Some(first), rest) = (items.get(0).map(EdnItem::to_str), &items[1..]) {
|
|
||||||
//match (first, rest) {
|
|
||||||
//("when", [c, a, ..]) => Box::new(move|state|Box::new(
|
|
||||||
//When(state.get_bool(&c.to_ref()), state.get_content(&a.to_ref())))),
|
|
||||||
//_ => Box::new(|_|Box::new(()))
|
|
||||||
//}
|
|
||||||
//} else {
|
|
||||||
//Box::new(|_|Box::new(()))
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
//Box::new(match [items.get(0).map(|x|x.to_str()), items[1..]] {
|
|
||||||
//["when", [c, a, ..]] => When(state.get_bool(c), state.get_content(a)),
|
|
||||||
//["either", [c, a, b, ..]] => Either(state.get_bool(c), state.get_content(a), state.get_content(b)),
|
|
||||||
//["fill", [a, ..]] => Fill::xy(state.get_content(a)),
|
|
||||||
//["fill/x", [a, ..]] => Fill::x(state.get_content(a)),
|
|
||||||
//["fill/y", [a, ..]] => Fill::y(state.get_content(a)),
|
|
||||||
//["fixed", [x, y, a, ..]] => Fixed::xy(state.get_unit(x), state.get_unit(y), state.get_content(a)),
|
|
||||||
//["fixed/x", [x, a, ..]] => Fixed::x(state.get_unit(x), state.get_content(a)),
|
|
||||||
//["fixed/y", [y, a, ..]] => Fixed::y(state.get_unit(y), state.get_content(a)),
|
|
||||||
//["shrink", [x, y, a, ..]] => Shrink::xy(state.get_unit(x), state.get_unit(y), state.get_content(a)),
|
|
||||||
//["shrink/x", [x, a, ..]] => Shrink::x(state.get_unit(x), state.get_content(a)),
|
|
||||||
//["shrink/y", [y, a, ..]] => Shrink::y(state.get_unit(y), state.get_content(a)),
|
|
||||||
//["expand", [x, y, a, ..]] => Expand::xy(state.get_unit(x), state.get_unit(y), state.get_content(a)),
|
|
||||||
//["expand/x", [x, a, ..]] => Expand::x(state.get_unit(x), state.get_content(a)),
|
|
||||||
//["expand/y", [y, a, ..]] => Expand::y(state.get_unit(y), state.get_content(a)),
|
|
||||||
//["push", [x, y, a, ..]] => Push::xy(state.get_unit(x), state.get_unit(y), state.get_content(a)),
|
|
||||||
//["push/x", [x, a, ..]] => Push::x(state.get_unit(x), state.get_content(a)),
|
|
||||||
//["push/y", [y, a, ..]] => Push::y(state.get_unit(y), state.get_content(a)),
|
|
||||||
//["pull", [x, y, a, ..]] => Pull::xy(state.get_unit(x), state.get_unit(y), state.get_content(a)),
|
|
||||||
//["pull/x", [x, a, ..]] => Pull::x(state.get_unit(x), state.get_content(a)),
|
|
||||||
//["pull/y", [y, a, ..]] => Pull::y(state.get_unit(y), state.get_content(a)),
|
|
||||||
//_ => Box::
|
|
||||||
//})
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
(bsp/s
|
(bsp/s
|
||||||
(fill/x (fixed/y 2 (lay
|
(fill/x (fixed/y 2 (bsp/a
|
||||||
|
(align/x :transport)
|
||||||
|
(bsp/a
|
||||||
(align/w :input-meter-l)
|
(align/w :input-meter-l)
|
||||||
(align/e :input-meter-r)
|
(align/e :input-meter-r)))))
|
||||||
(align/x :transport))))
|
|
||||||
(bsp/n
|
(bsp/n
|
||||||
(row :clip-play :clip-next :clip-edit :edit-stat)
|
(bsp/e :clip-play (bsp/e :clip-next (bsp/e :clip-edit :edit-stat)))
|
||||||
(bsp/n
|
(bsp/n
|
||||||
(max/y :sample-h (fill/xy :sample-view))
|
(max/y :sample-h (fill/xy :sample-view))
|
||||||
(bsp/n
|
(bsp/n
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue