unify edn_view entrypoint

This commit is contained in:
🪞👃🪞 2025-01-14 15:39:28 +01:00
parent df50bb9f47
commit 9cd6e9f195
16 changed files with 603 additions and 541 deletions

View file

@ -4,7 +4,9 @@ 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> {
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() {
@ -20,3 +22,13 @@ impl EdnKeymap {
None
}
}
impl<T: AsRef<str>> From<T> for EdnKeymap {
fn from (source: T) -> Self {
Self(EdnItem::<String>::read_all(source.as_ref()).expect("failed to load keymap"))
}
}
#[cfg(test)] #[test] fn test_edn_keymap () {
let keymap = EdnKeymap::from("");
}