From 4ab9463164d69e47d241652c82235b43c83a2510 Mon Sep 17 00:00:00 2001 From: unspeaker Date: Wed, 25 Dec 2024 05:58:45 +0100 Subject: [PATCH] PhrasesCommand -> PoolCommand --- crates/tek/src/tui/app_sequencer.rs | 12 ++++++------ crates/tek/src/tui/arranger_command.rs | 16 ++++++++-------- crates/tek/src/tui/pool.rs | 12 ++++++------ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/crates/tek/src/tui/app_sequencer.rs b/crates/tek/src/tui/app_sequencer.rs index 66307476..fbf5dd44 100644 --- a/crates/tek/src/tui/app_sequencer.rs +++ b/crates/tek/src/tui/app_sequencer.rs @@ -83,7 +83,7 @@ handle!(|self:SequencerTui,input|SequencerCommand::execute_with_state(self, #[derive(Clone, Debug)] pub enum SequencerCommand { History(isize), Clock(ClockCommand), - Phrases(PhrasesCommand), + Phrases(PoolCommand), Editor(PhraseCommand), Enqueue(Option>>), } @@ -103,7 +103,7 @@ input_to_command!(SequencerCommand: |state: SequencerTui, input|match input // Shift-U: redo key_pat!(Char('U')) => History( 1), // Tab: Toggle visibility of phrase pool column - key_pat!(Tab) => Phrases(PhrasesCommand::Show(!state.phrases.visible)), + key_pat!(Tab) => Phrases(PoolCommand::Show(!state.phrases.visible)), // q: Enqueue currently edited phrase key_pat!(Char('q')) => Enqueue(Some(state.phrases.phrase().clone())), // 0: Enqueue phrase 0 (stop all) @@ -124,7 +124,7 @@ input_to_command!(SequencerCommand: |state: SequencerTui, input|match input // The ones defined above supersede them. _ => if let Some(command) = PhraseCommand::input_to_command(&state.editor, input) { Editor(command) - } else if let Some(command) = PhrasesCommand::input_to_command(&state.phrases, input) { + } else if let Some(command) = PoolCommand::input_to_command(&state.phrases, input) { Phrases(command) } else { return None @@ -132,18 +132,18 @@ input_to_command!(SequencerCommand: |state: SequencerTui, input|match input }); command!(|self: SequencerCommand, state: SequencerTui|match self { Self::Phrases(cmd) => { - let mut default = |cmd: PhrasesCommand|cmd + let mut default = |cmd: PoolCommand|cmd .execute(&mut state.phrases) .map(|x|x.map(Phrases)); match cmd { // autoselect: automatically load selected phrase in editor - PhrasesCommand::Select(_) => { + PoolCommand::Select(_) => { let undo = default(cmd)?; state.editor.set_phrase(Some(state.phrases.phrase())); undo }, // update color in all places simultaneously - PhrasesCommand::Phrase(SetColor(index, _)) => { + PoolCommand::Phrase(SetColor(index, _)) => { let undo = default(cmd)?; state.editor.set_phrase(Some(state.phrases.phrase())); undo diff --git a/crates/tek/src/tui/arranger_command.rs b/crates/tek/src/tui/arranger_command.rs index 8c95e457..59370065 100644 --- a/crates/tek/src/tui/arranger_command.rs +++ b/crates/tek/src/tui/arranger_command.rs @@ -11,7 +11,7 @@ use KeyCode::{Char, Delete, Tab, Up, Down, Left, Right}; Clip(ArrangerClipCommand), Select(ArrangerSelection), Zoom(usize), - Phrases(PhrasesCommand), + Phrases(PoolCommand), Editor(PhraseCommand), StopAll, Clear, @@ -65,7 +65,7 @@ input_to_command!(ArrangerCommand: |state: ArrangerTui, input|match input.e Self::Track(ArrangerTrackCommand::Add), // Tab: Toggle visibility of phrase pool column key_pat!(Tab) => - Self::Phrases(PhrasesCommand::Show(!state.phrases.visible)), + Self::Phrases(PoolCommand::Show(!state.phrases.visible)), _ => { use ArrangerCommand as Cmd; use ArrangerSelection as Selected; @@ -76,7 +76,7 @@ input_to_command!(ArrangerCommand: |state: ArrangerTui, input|match input.e let s_len = state.scenes.len(); match state.selected() { Selected::Clip(t, s) => match input.event() { - key_pat!(Char('g')) => Some(Cmd::Phrases(PhrasesCommand::Select(0))), + key_pat!(Char('g')) => Some(Cmd::Phrases(PoolCommand::Select(0))), key_pat!(Char('q')) => Some(Cmd::Clip(Clip::Enqueue(t, s))), key_pat!(Char(',')) => Some(Cmd::Clip(Clip::Put(t, s, None))), key_pat!(Char('.')) => Some(Cmd::Clip(Clip::Put(t, s, None))), @@ -155,7 +155,7 @@ input_to_command!(ArrangerCommand: |state: ArrangerTui, input|match input.e } }.or_else(||if let Some(command) = PhraseCommand::input_to_command(&state.editor, input) { Some(Self::Editor(command)) - } else if let Some(command) = PhrasesCommand::input_to_command(&state.phrases, input) { + } else if let Some(command) = PoolCommand::input_to_command(&state.phrases, input) { Some(Self::Phrases(command)) } else { None @@ -171,7 +171,7 @@ fn to_arrangement_command (state: &ArrangerTui, input: &TuiInput) -> Option match input.event() { - key_pat!(Char('g')) => Some(Cmd::Phrases(PhrasesCommand::Select(0))), + key_pat!(Char('g')) => Some(Cmd::Phrases(PoolCommand::Select(0))), key_pat!(Char('q')) => Some(Cmd::Clip(Clip::Enqueue(t, s))), key_pat!(Char(',')) => Some(Cmd::Clip(Clip::Put(t, s, None))), key_pat!(Char('.')) => Some(Cmd::Clip(Clip::Put(t, s, None))), @@ -266,18 +266,18 @@ command!(|self: ArrangerCommand, state: ArrangerTui|match self { Some(Self::Color(old)) }, Self::Phrases(cmd) => { - let mut default = |cmd: PhrasesCommand|{ + let mut default = |cmd: PoolCommand|{ cmd.execute(&mut state.phrases).map(|x|x.map(Self::Phrases)) }; match cmd { // autoselect: automatically load selected phrase in editor - PhrasesCommand::Select(_) => { + PoolCommand::Select(_) => { let undo = default(cmd)?; state.editor.set_phrase(Some(state.phrases.phrase())); undo }, // reload phrase in editor to update color - PhrasesCommand::Phrase(PhrasePoolCommand::SetColor(index, _)) => { + PoolCommand::Phrase(PhrasePoolCommand::SetColor(index, _)) => { let undo = default(cmd)?; state.editor.set_phrase(Some(state.phrases.phrase())); undo diff --git a/crates/tek/src/tui/pool.rs b/crates/tek/src/tui/pool.rs index 53901fea..61d506cc 100644 --- a/crates/tek/src/tui/pool.rs +++ b/crates/tek/src/tui/pool.rs @@ -35,7 +35,7 @@ pub enum PoolMode { } #[derive(Clone, PartialEq, Debug)] -pub enum PhrasesCommand { +pub enum PoolCommand { Show(bool), /// Update the contents of the phrase pool Phrase(Pool), @@ -51,8 +51,8 @@ pub enum PhrasesCommand { Export(Browse), } -command!(|self:PhrasesCommand, state: PoolModel|{ - use PhrasesCommand::*; +command!(|self:PoolCommand, state: PoolModel|{ + use PoolCommand::*; match self { Show(visible) => { state.visible = visible; @@ -104,7 +104,7 @@ command!(|self:PhrasesCommand, state: PoolModel|{ } }); -input_to_command!(PhrasesCommand:|state: PoolModel,input|match state.phrases_mode() { +input_to_command!(PoolCommand:|state: PoolModel,input|match state.phrases_mode() { Some(PoolMode::Rename(..)) => Self::Rename(Rename::input_to_command(state, input)?), Some(PoolMode::Length(..)) => Self::Length(Length::input_to_command(state, input)?), Some(PoolMode::Import(..)) => Self::Import(Browse::input_to_command(state, input)?), @@ -112,9 +112,9 @@ input_to_command!(PhrasesCommand:|state: PoolModel,input|match state.phrase _ => to_phrases_command(state, input)? }); -fn to_phrases_command (state: &PoolModel, input: &TuiInput) -> Option { +fn to_phrases_command (state: &PoolModel, input: &TuiInput) -> Option { use KeyCode::{Up, Down, Delete, Char}; - use PhrasesCommand as Cmd; + use PoolCommand as Cmd; let index = state.phrase_index(); let count = state.phrases().len(); Some(match input.event() {