diff --git a/crates/app/src/keys.rs b/crates/app/src/keys.rs index 2bdbcaf1..8628d2e5 100644 --- a/crates/app/src/keys.rs +++ b/crates/app/src/keys.rs @@ -23,26 +23,54 @@ pub fn handle_arranger (app: &mut Tek, input: &TuiIn) -> Perhaps { app.selected.is_clip() && layer(app, input, include_str!("../../../config/keys_clip.edn"))? || app.selected.is_track() && layer(app, input, include_str!("../../../config/keys_track.edn"))? || app.selected.is_scene() && layer(app, input, include_str!("../../../config/keys_scene.edn"))? || - app.selected.is_mix() && layer(app, input, include_str!("../../../config/keys_mix.edn"))? - ).then_some(true)) + app.selected.is_mix() && layer(app, input, include_str!("../../../config/keys_mix.edn"))?).then_some(true)) } pub fn handle_sequencer (app: &mut Tek, input: &TuiIn) -> Perhaps { Ok((app.editor.handle(input)? == Some(true) || layer(app, input, include_str!("../../../config/keys_global.edn"))? || - layer(app, input, include_str!("../../../config/keys_sequencer.edn"))? - ).then_some(true)) + layer(app, input, include_str!("../../../config/keys_sequencer.edn"))?).then_some(true)) } pub fn handle_groovebox (app: &mut Tek, input: &TuiIn) -> Perhaps { Ok((app.editor.handle(input)? == Some(true) || layer(app, input, include_str!("../../../config/keys_global.edn"))? || - layer(app, input, include_str!("../../../config/keys_groovebox.edn"))? - ).then_some(true)) + layer(app, input, include_str!("../../../config/keys_groovebox.edn"))?).then_some(true)) } pub fn handle_sampler (app: &mut Tek, input: &TuiIn) -> Perhaps { Ok((layer(app, input, include_str!("../../../config/keys_global.edn"))? || - layer(app, input, include_str!("../../../config/keys_sampler.edn"))? - ).then_some(true)) + layer(app, input, include_str!("../../../config/keys_sampler.edn"))?).then_some(true)) } + +// TODO: +//#[derive(Default)] +//struct Handler { + //layers: Vec<(Boxbool>, &'static str)>, + //__: std::marker::PhantomData +//} + +//impl Handler { + //fn layer (mut self, condition: impl Fn(&T)->bool + 'static, keymap: &'static str) -> Self { + //self.layers.push((Box::new(condition), keymap)); + //self + //} + //fn layer_if (mut self, keymap: &'static str) -> Self { + //self.layers.push((Box::new(|_|true), keymap)); + //self + //} + //fn handle <'a, C: Command + TryFromAtom<'a, T>> (&self, state: &mut T, input: &U) -> Perhaps { + //for layer in self.layers.iter() { + //if !(layer.0)(state) { + //continue + //} + //if let Some(command) = SourceIter(layer.1).command::<_, C, _>(state, input) { + //if let Some(undo) = command.execute(state)? { + ////app.history.push(undo); + //} + //return Ok(Some(true)) + //} + //} + //Ok(None) + //} +//}