mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
44 lines
2 KiB
Rust
44 lines
2 KiB
Rust
use crate::*;
|
|
|
|
handle!(TuiIn: |self: Tek, input|if let Some(handler) = self.handler {
|
|
handler(self, input)
|
|
} else {
|
|
Ok(None)
|
|
});
|
|
|
|
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"))? ||
|
|
layer(app, input, include_str!("../../../config/keys_arranger.edn"))? ||
|
|
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))
|
|
}
|
|
|
|
pub fn handle_sequencer (app: &mut Tek, input: &TuiIn) -> Perhaps<bool> {
|
|
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))
|
|
}
|
|
|
|
pub fn handle_groovebox (app: &mut Tek, input: &TuiIn) -> Perhaps<bool> {
|
|
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))
|
|
}
|
|
|
|
pub fn handle_sampler (app: &mut Tek, input: &TuiIn) -> Perhaps<bool> {
|
|
Ok((layer(app, input, include_str!("../../../config/keys_global.edn"))? ||
|
|
layer(app, input, include_str!("../../../config/keys_sampler.edn"))?).then_some(true))
|
|
}
|
|
|
|
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)
|
|
}
|