mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: edn keymaps are handled!
This commit is contained in:
parent
ca1fb3c414
commit
a66bc5ca5e
1 changed files with 14 additions and 12 deletions
|
|
@ -383,17 +383,18 @@ handle!(TuiIn: |self: App, input|{
|
||||||
let mut command: Option<AppCommand> = None;
|
let mut command: Option<AppCommand> = None;
|
||||||
let edns: Vec<EdnItem<&str>> = EdnItem::read_all(Self::KEYS_APP)?;
|
let edns: Vec<EdnItem<&str>> = EdnItem::read_all(Self::KEYS_APP)?;
|
||||||
for item in edns {
|
for item in edns {
|
||||||
match item {
|
if let Exp(e) = item {
|
||||||
Exp(e) => match e.as_slice() {
|
match e.as_slice() {
|
||||||
[Sym(key), c, args @ ..] if input.matches_edn(key) => {
|
[Sym(key), c, args @ ..] if input.matches_edn(key) => {
|
||||||
command = AppCommand::from_edn(self, c, args);
|
command = AppCommand::from_edn(self, c, args);
|
||||||
if command.is_some() {
|
if command.is_some() {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
}
|
||||||
_ => panic!("invalid config")
|
} else {
|
||||||
|
panic!("invalid config")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(if let Some(command) = command {
|
Ok(if let Some(command) = command {
|
||||||
|
|
@ -420,13 +421,14 @@ handle!(TuiIn: |self: App, input|{
|
||||||
Zoom(Option<usize>),
|
Zoom(Option<usize>),
|
||||||
}
|
}
|
||||||
edn_command!(AppCommand: |state: App| {
|
edn_command!(AppCommand: |state: App| {
|
||||||
("color" [c: Color] Self::Color(c.map(ItemPalette::from).unwrap_or_default()))
|
|
||||||
("compact" [c: bool ] Self::Compact(c))
|
|
||||||
("enqueue" [c: Arc<RwLock<MidiClip>>] Self::Enqueue(c))
|
|
||||||
("history" [d: isize] Self::History(d.unwrap_or(0)))
|
|
||||||
("select" [s: Selection] Self::Select(s.expect("no selection")))
|
|
||||||
("stop-all" [] Self::StopAll)
|
("stop-all" [] Self::StopAll)
|
||||||
|
("compact" [c: bool] Self::Compact(c))
|
||||||
|
("color" [c: Color] Self::Color(c.map(ItemPalette::from).unwrap_or_default()))
|
||||||
|
("undo" [d: usize] Self::History(-(d.unwrap_or(0)as isize)))
|
||||||
|
("redo" [d: usize] Self::History(d.unwrap_or(0) as isize))
|
||||||
("zoom" [z: usize] Self::Zoom(z))
|
("zoom" [z: usize] Self::Zoom(z))
|
||||||
|
("select" [s: Selection] Self::Select(s.expect("no selection")))
|
||||||
|
("enqueue" [c: Arc<RwLock<MidiClip>>] Self::Enqueue(c))
|
||||||
|
|
||||||
("clip" [a, ..b] Self::Clip(
|
("clip" [a, ..b] Self::Clip(
|
||||||
ClipCommand::from_edn(state, &a.to_ref(), b).expect("invalid command")))
|
ClipCommand::from_edn(state, &a.to_ref(), b).expect("invalid command")))
|
||||||
|
|
@ -444,8 +446,8 @@ edn_command!(AppCommand: |state: App| {
|
||||||
TrackCommand::from_edn(state, &a.to_ref(), b).expect("invalid command")))
|
TrackCommand::from_edn(state, &a.to_ref(), b).expect("invalid command")))
|
||||||
});
|
});
|
||||||
command!(|self: AppCommand, state: App|match self {
|
command!(|self: AppCommand, state: App|match self {
|
||||||
Self::Zoom(_) => { todo!(); },
|
Self::Zoom(_) => { println!("\n\rtodo: global zoom"); None },
|
||||||
Self::History(delta) => { todo!("undo/redo") },
|
Self::History(delta) => { println!("\n\rtodo: undo/redo"); None },
|
||||||
Self::Select(s) => { state.selected = s; None },
|
Self::Select(s) => { state.selected = s; None },
|
||||||
Self::Clock(cmd) => cmd.delegate(state, Self::Clock)?,
|
Self::Clock(cmd) => cmd.delegate(state, Self::Clock)?,
|
||||||
Self::Scene(cmd) => cmd.delegate(state, Self::Scene)?,
|
Self::Scene(cmd) => cmd.delegate(state, Self::Scene)?,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue