mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
22 lines
651 B
Rust
22 lines
651 B
Rust
use crate::*;
|
|
use EdnItem::*;
|
|
|
|
pub struct EdnKeymap(pub Vec<EdnItem<String>>);
|
|
|
|
impl EdnKeymap {
|
|
pub fn command <C, D: Command<C>, E: EdnCommand<C>, I: EdnInput> (&self, state: &C, input: &I) -> Option<E> {
|
|
for item in self.0.iter() {
|
|
if let Exp(items) = item {
|
|
match items.as_slice() {
|
|
[Sym(a), b, c @ ..] => if input.matches(a.as_str()) {
|
|
return Some(E::from_edn(state, &b.to_ref(), c))
|
|
},
|
|
_ => unreachable!()
|
|
}
|
|
} else {
|
|
unreachable!()
|
|
}
|
|
}
|
|
None
|
|
}
|
|
}
|