diff --git a/crates/tek/src/tui/app_sequencer.rs b/crates/tek/src/tui/app_sequencer.rs index f788e013..3cb8200f 100644 --- a/crates/tek/src/tui/app_sequencer.rs +++ b/crates/tek/src/tui/app_sequencer.rs @@ -280,7 +280,17 @@ pub fn to_sequencer_command (state: &SequencerTui, input: &TuiInput) -> Option {} + key!(Char('e')) => if let Some((_, Some(playing_phrase))) = state.player.play_phrase() { + let editing_phrase = state.editor.phrase.as_ref().map(|p|p.read().unwrap().clone()); + let selected_phrase = state.phrases.phrase().clone(); + if Some(selected_phrase.read().unwrap().clone()) != editing_phrase { + Editor(Show(Some(selected_phrase))) + } else { + Editor(Show(Some(playing_phrase.clone()))) + } + } else { + return None + }, // Transport: Play/pause key!(Char(' ')) => @@ -295,7 +305,7 @@ pub fn to_sequencer_command (state: &SequencerTui, input: &TuiInput) -> Option + key!(Char('[')) | key!(Char(']')) | key!(Char('c')) | key!(Shift-Char('A')) | key!(Shift-Char('D')) => Phrases(PhrasesCommand::input_to_command(&state.phrases, input)?), // Enqueue currently edited phrase diff --git a/crates/tek/src/tui/phrase_list.rs b/crates/tek/src/tui/phrase_list.rs index 27dcafdb..7ffd6a20 100644 --- a/crates/tek/src/tui/phrase_list.rs +++ b/crates/tek/src/tui/phrase_list.rs @@ -33,6 +33,9 @@ impl Default for PhraseListModel { } impl PhraseListModel { + pub(crate) fn phrase (&self) -> &Arc> { + &self.phrases[self.phrase_index()] + } pub(crate) fn phrase_index (&self) -> usize { self.phrase.load(Ordering::Relaxed) } @@ -250,10 +253,10 @@ fn to_phrases_command (state: &PhraseListModel, input: &TuiInput) -> Option Cmd::Import(Browse::Begin), key!(Char('x')) => Cmd::Export(Browse::Begin), key!(Char('c')) => Cmd::Phrase(Pool::SetColor(index, ItemColor::random())), - key!(Up) => Cmd::Select( + key!(Up) | key!(Char('[')) => Cmd::Select( index.overflowing_sub(1).0.min(state.phrases().len() - 1) ), - key!(Down) => Cmd::Select( + key!(Down) | key!(Char(']')) => Cmd::Select( index.saturating_add(1) % state.phrases().len() ), key!(Char('<')) => if index > 1 { @@ -274,13 +277,13 @@ fn to_phrases_command (state: &PhraseListModel, input: &TuiInput) -> Option Cmd::Phrase(Pool::Add(count, Phrase::new( + key!(Char('a')) | key!(Shift-Char('A')) => Cmd::Phrase(Pool::Add(count, Phrase::new( String::from("(new)"), true, 4 * PPQ, None, Some(ItemPalette::random()) ))), key!(Char('i')) => Cmd::Phrase(Pool::Add(index + 1, Phrase::new( String::from("(new)"), true, 4 * PPQ, None, Some(ItemPalette::random()) ))), - key!(Char('d')) => { + key!(Char('d')) | key!(Shift-Char('D')) => { let mut phrase = state.phrases()[index].read().unwrap().duplicate(); phrase.color = ItemPalette::random_near(phrase.color, 0.25); Cmd::Phrase(Pool::Add(index + 1, phrase))