mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
focus: exit on next/prev
This commit is contained in:
parent
adb666c527
commit
ac8e8b2bf0
4 changed files with 18 additions and 16 deletions
|
|
@ -5,9 +5,9 @@ pub trait Command<S>: Sized {
|
||||||
fn execute (self, state: &mut S) -> Perhaps<Self>;
|
fn execute (self, state: &mut S) -> Perhaps<Self>;
|
||||||
}
|
}
|
||||||
pub fn delegate <B, C: Command<S>, S> (
|
pub fn delegate <B, C: Command<S>, S> (
|
||||||
|
cmd: C,
|
||||||
wrap: impl Fn(C)->B,
|
wrap: impl Fn(C)->B,
|
||||||
state: &mut S,
|
state: &mut S,
|
||||||
cmd: C
|
|
||||||
) -> Perhaps<B> {
|
) -> Perhaps<B> {
|
||||||
Ok(cmd.execute(state)?.map(|x|wrap(x)))
|
Ok(cmd.execute(state)?.map(|x|wrap(x)))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ pub trait FocusGrid {
|
||||||
if self.focused() == current { // FIXME: prevent infinite loop
|
if self.focused() == current { // FIXME: prevent infinite loop
|
||||||
self.focus_next()
|
self.focus_next()
|
||||||
}
|
}
|
||||||
|
self.focus_exit();
|
||||||
self.update_focus();
|
self.update_focus();
|
||||||
}
|
}
|
||||||
fn focus_prev (&mut self) {
|
fn focus_prev (&mut self) {
|
||||||
|
|
@ -80,6 +81,7 @@ pub trait FocusGrid {
|
||||||
if self.focused() == current { // FIXME: prevent infinite loop
|
if self.focused() == current { // FIXME: prevent infinite loop
|
||||||
self.focus_prev()
|
self.focus_prev()
|
||||||
}
|
}
|
||||||
|
self.focus_exit();
|
||||||
self.update_focus();
|
self.update_focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,21 +38,21 @@ impl<E: Engine> Command<Arranger<E>> for ArrangerCommand {
|
||||||
fn execute (self, state: &mut Arranger<E>) -> Perhaps<Self> {
|
fn execute (self, state: &mut Arranger<E>) -> Perhaps<Self> {
|
||||||
let undo = match self {
|
let undo = match self {
|
||||||
Self::Focus(cmd) => {
|
Self::Focus(cmd) => {
|
||||||
delegate(Self::Focus, state, cmd)
|
delegate(cmd, Self::Focus, state)
|
||||||
},
|
|
||||||
Self::Transport(cmd) => if let Some(ref transport) = state.transport {
|
|
||||||
delegate(Self::Transport, &mut*transport.write().unwrap(), cmd)
|
|
||||||
} else {
|
|
||||||
Ok(None)
|
|
||||||
},
|
},
|
||||||
Self::Phrases(cmd) => {
|
Self::Phrases(cmd) => {
|
||||||
delegate(Self::Phrases, &mut*state.phrases.write().unwrap(), cmd)
|
delegate(cmd, Self::Phrases, &mut*state.phrases.write().unwrap())
|
||||||
},
|
},
|
||||||
Self::Editor(cmd) => {
|
Self::Editor(cmd) => {
|
||||||
delegate(Self::Editor, &mut state.editor, cmd)
|
delegate(cmd, Self::Editor, &mut state.editor)
|
||||||
},
|
},
|
||||||
Self::Arrangement(cmd) => {
|
Self::Arrangement(cmd) => {
|
||||||
delegate(Self::Arrangement, &mut state.arrangement, cmd)
|
delegate(cmd, Self::Arrangement, &mut state.arrangement)
|
||||||
|
},
|
||||||
|
Self::Transport(cmd) => if let Some(ref transport) = state.transport {
|
||||||
|
delegate(cmd, Self::Transport, &mut*transport.write().unwrap())
|
||||||
|
} else {
|
||||||
|
Ok(None)
|
||||||
},
|
},
|
||||||
}?;
|
}?;
|
||||||
state.show_phrase();
|
state.show_phrase();
|
||||||
|
|
|
||||||
|
|
@ -75,16 +75,16 @@ impl<E: Engine> Command<Sequencer<E>> for SequencerCommand {
|
||||||
fn execute (self, state: &mut Sequencer<E>) -> Perhaps<Self> {
|
fn execute (self, state: &mut Sequencer<E>) -> Perhaps<Self> {
|
||||||
match self {
|
match self {
|
||||||
Self::Focus(cmd) => {
|
Self::Focus(cmd) => {
|
||||||
return delegate(Self::Focus, state, cmd)
|
return delegate(cmd, Self::Focus, state)
|
||||||
},
|
|
||||||
Self::Transport(cmd) => if let Some(ref transport) = state.transport {
|
|
||||||
return delegate(Self::Transport, &mut*transport.write().unwrap(), cmd)
|
|
||||||
},
|
},
|
||||||
Self::Phrases(cmd) => {
|
Self::Phrases(cmd) => {
|
||||||
return delegate(Self::Phrases, &mut*state.phrases.write().unwrap(), cmd)
|
return delegate(cmd, Self::Phrases, &mut*state.phrases.write().unwrap())
|
||||||
},
|
},
|
||||||
Self::Editor(cmd) => {
|
Self::Editor(cmd) => {
|
||||||
return delegate(Self::Editor, &mut state.editor, cmd)
|
return delegate(cmd, Self::Editor, &mut state.editor)
|
||||||
|
},
|
||||||
|
Self::Transport(cmd) => if let Some(ref transport) = state.transport {
|
||||||
|
return delegate(cmd, Self::Transport, &mut*transport.write().unwrap())
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
Ok(None)
|
Ok(None)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue