mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
This commit is contained in:
parent
99d9da6ffd
commit
fc038dbd97
10 changed files with 71 additions and 89 deletions
|
|
@ -7,7 +7,7 @@ macro_rules! cmd_todo { ($msg:literal) => {{ println!($msg); None }}; }
|
|||
handle!(TuiIn: |self: App, input|self.handle_tui_key_with_history(input));
|
||||
impl App {
|
||||
fn handle_tui_key_with_history (&mut self, input: &TuiIn) -> Perhaps<bool> {
|
||||
Ok(if let Some(command) = self.config.keys.command(self, input) {
|
||||
Ok(if let Some(command) = self.config.keys.keybind_resolve(self, input)? {
|
||||
// FIXME failed commands not persisted in undo history
|
||||
let undo = command.clone().execute(self)?;
|
||||
self.history.push((command, undo));
|
||||
|
|
@ -38,6 +38,7 @@ impl AppCommand {
|
|||
})
|
||||
}
|
||||
fn dialog (app: &mut App, command: DialogCommand) -> Perhaps<Self> {
|
||||
panic!("dialog");
|
||||
Ok(command.delegate(&mut app.dialog, |command|Self::Dialog{command})?)
|
||||
}
|
||||
fn project (app: &mut App, command: ArrangementCommand) -> Perhaps<Self> {
|
||||
|
|
@ -111,33 +112,10 @@ impl AppCommand {
|
|||
//Ok(None)
|
||||
//}
|
||||
}
|
||||
impl<'state> Context<'state, ClockCommand> for App {
|
||||
fn get <'source> (&'state self, iter: &mut TokenIter<'source>) -> Option<ClockCommand> {
|
||||
Context::get(&self.clock(), iter)
|
||||
}
|
||||
}
|
||||
impl<'state> Context<'state, MidiEditCommand> for App {
|
||||
fn get <'source> (&'state self, iter: &mut TokenIter<'source>) -> Option<MidiEditCommand> {
|
||||
self.editor().map(|e|Context::get(e, iter)).flatten()
|
||||
}
|
||||
}
|
||||
impl<'state> Context<'state, PoolCommand> for App {
|
||||
fn get <'source> (&'state self, iter: &mut TokenIter<'source>) -> Option<PoolCommand> {
|
||||
Context::get(&self.pool, iter)
|
||||
}
|
||||
}
|
||||
impl<'state> Context<'state, SamplerCommand> for App {
|
||||
fn get <'source> (&'state self, iter: &mut TokenIter<'source>) -> Option<SamplerCommand> {
|
||||
self.project.sampler().map(|p|Context::get(p, iter)).flatten()
|
||||
}
|
||||
}
|
||||
impl<'state> Context<'state, ArrangementCommand> for App {
|
||||
fn get <'source> (&'state self, iter: &mut TokenIter<'source>) -> Option<ArrangementCommand> {
|
||||
Context::get(&self.project, iter)
|
||||
}
|
||||
}
|
||||
impl<'state> Context<'state, DialogCommand> for App {
|
||||
fn get <'source> (&'state self, iter: &mut TokenIter<'source>) -> Option<DialogCommand> {
|
||||
Context::get(&self, iter)
|
||||
}
|
||||
}
|
||||
|
||||
dsl!(ClockCommand: |self: App, iter|self.clock().take(iter));
|
||||
dsl!(MidiEditCommand: |self: App, iter|Ok(self.editor().map(|x|x.take(iter)).transpose()?.flatten()));
|
||||
dsl!(PoolCommand: |self: App, iter|self.pool.take(iter));
|
||||
dsl!(SamplerCommand: |self: App, iter|Ok(self.project.sampler().map(|x|x.take(iter)).transpose()?.flatten()));
|
||||
dsl!(ArrangementCommand: |self: App, iter|self.project.take(iter));
|
||||
dsl!(DialogCommand: |self: App, iter|Dsl::take(&self.dialog, iter));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue