mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
This commit is contained in:
parent
3561867640
commit
5696cbbebb
6 changed files with 45 additions and 68 deletions
|
|
@ -6,16 +6,6 @@ handle!(TuiIn: |self: Tek, input|if let Some(handler) = self.handler {
|
|||
Ok(None)
|
||||
});
|
||||
|
||||
fn layer (app: &mut Tek, input: &TuiIn, keymap: &str) -> Usually<bool> {
|
||||
if let Some(command) = SourceIter(keymap).command::<_, TekCommand, _>(app, input) {
|
||||
if let Some(undo) = command.execute(app)? {
|
||||
app.history.push(undo);
|
||||
}
|
||||
return Ok(true)
|
||||
}
|
||||
return Ok(false)
|
||||
}
|
||||
|
||||
pub fn handle_arranger (app: &mut Tek, input: &TuiIn) -> Perhaps<bool> {
|
||||
Ok((app.is_editing() && app.editor.handle(input)? == Some(true) ||
|
||||
layer(app, input, include_str!("../../../config/keys_global.edn"))? ||
|
||||
|
|
@ -43,34 +33,12 @@ pub fn handle_sampler (app: &mut Tek, input: &TuiIn) -> Perhaps<bool> {
|
|||
layer(app, input, include_str!("../../../config/keys_sampler.edn"))?).then_some(true))
|
||||
}
|
||||
|
||||
// TODO:
|
||||
//#[derive(Default)]
|
||||
//struct Handler<T, U> {
|
||||
//layers: Vec<(Box<dyn Fn(&T)->bool>, &'static str)>,
|
||||
//__: std::marker::PhantomData<U>
|
||||
//}
|
||||
|
||||
//impl<T, U: AtomInput> Handler<T, U> {
|
||||
//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<T> + TryFromAtom<'a, T>> (&self, state: &mut T, input: &U) -> Perhaps<bool> {
|
||||
//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)
|
||||
//}
|
||||
//}
|
||||
fn layer (app: &mut Tek, input: &TuiIn, keymap: &str) -> Usually<bool> {
|
||||
if let Some(command) = SourceIter(keymap).command::<_, TekCommand, _>(app, input) {
|
||||
if let Some(undo) = command.execute(app)? {
|
||||
app.history.push(undo);
|
||||
}
|
||||
return Ok(true)
|
||||
}
|
||||
return Ok(false)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue