shorten command names

This commit is contained in:
🪞👃🪞 2024-11-07 02:20:03 +01:00
parent dd72cea679
commit d3718f0b78

View file

@ -14,7 +14,7 @@ enum SequencerCommand {
} }
#[derive(Clone, PartialEq)] #[derive(Clone, PartialEq)]
pub enum PhrasePoolCommand { pub enum PhrasePoolCommand {
Previous, Prev,
Next, Next,
MoveUp, MoveUp,
MoveDown, MoveDown,
@ -40,9 +40,9 @@ pub enum PhraseRenameCommand {
pub enum PhraseLengthCommand { pub enum PhraseLengthCommand {
Begin, Begin,
Next, Next,
Previous, Prev,
Increment, Inc,
Decrement, Dec,
Set(usize), Set(usize),
Confirm, Confirm,
Cancel, Cancel,
@ -53,8 +53,8 @@ pub enum PhraseEditorCommand {
ToggleDirection, ToggleDirection,
EnterEditMode, EnterEditMode,
ExitEditMode, ExitEditMode,
NoteLengthDecrement, NoteLengthDec,
NoteLengthIncrement, NoteLengthInc,
TimeZoomIn, TimeZoomIn,
TimeZoomOut, TimeZoomOut,
NoteAppend, NoteAppend,
@ -96,7 +96,7 @@ impl HandleKey<SequencerCommand> for Sequencer<Tui> {
impl HandleKey<PhrasePoolCommand> for PhrasePool<Tui> { impl HandleKey<PhrasePoolCommand> for PhrasePool<Tui> {
fn match_input (&self, from: &TuiInput) -> Option<PhrasePoolCommand> { fn match_input (&self, from: &TuiInput) -> Option<PhrasePoolCommand> {
match from.event() { match from.event() {
key!(KeyCode::Up) => Some(PhrasePoolCommand::Previous), key!(KeyCode::Up) => Some(PhrasePoolCommand::Prev),
key!(KeyCode::Down) => Some(PhrasePoolCommand::Next), key!(KeyCode::Down) => Some(PhrasePoolCommand::Next),
key!(KeyCode::Char(',')) => Some(PhrasePoolCommand::MoveUp), key!(KeyCode::Char(',')) => Some(PhrasePoolCommand::MoveUp),
key!(KeyCode::Char('.')) => Some(PhrasePoolCommand::MoveDown), key!(KeyCode::Char('.')) => Some(PhrasePoolCommand::MoveDown),
@ -131,10 +131,10 @@ impl HandleKey<PhraseRenameCommand> for PhrasePool<Tui> {
impl HandleKey<PhraseLengthCommand> for PhrasePool<Tui> { impl HandleKey<PhraseLengthCommand> for PhrasePool<Tui> {
fn match_input (&self, from: &TuiInput) -> Option<PhraseLengthCommand> { fn match_input (&self, from: &TuiInput) -> Option<PhraseLengthCommand> {
match from.event() { match from.event() {
key!(KeyCode::Up) => Some(PhraseLengthCommand::Increment), key!(KeyCode::Up) => Some(PhraseLengthCommand::Inc),
key!(KeyCode::Down) => Some(PhraseLengthCommand::Decrement), key!(KeyCode::Down) => Some(PhraseLengthCommand::Dec),
key!(KeyCode::Right) => Some(PhraseLengthCommand::Next), key!(KeyCode::Right) => Some(PhraseLengthCommand::Next),
key!(KeyCode::Left) => Some(PhraseLengthCommand::Previous), key!(KeyCode::Left) => Some(PhraseLengthCommand::Prev),
key!(KeyCode::Enter) => Some(PhraseLengthCommand::Confirm), key!(KeyCode::Enter) => Some(PhraseLengthCommand::Confirm),
key!(KeyCode::Esc) => Some(PhraseLengthCommand::Cancel), key!(KeyCode::Esc) => Some(PhraseLengthCommand::Cancel),
_ => None _ => None
@ -147,8 +147,8 @@ impl HandleKey<PhraseEditorCommand> for PhraseEditor<Tui> {
key!(KeyCode::Char('`')) => Some(PhraseEditorCommand::ToggleDirection), key!(KeyCode::Char('`')) => Some(PhraseEditorCommand::ToggleDirection),
key!(KeyCode::Enter) => Some(PhraseEditorCommand::EnterEditMode), key!(KeyCode::Enter) => Some(PhraseEditorCommand::EnterEditMode),
key!(KeyCode::Esc) => Some(PhraseEditorCommand::ExitEditMode), key!(KeyCode::Esc) => Some(PhraseEditorCommand::ExitEditMode),
key!(KeyCode::Char('[')) => Some(PhraseEditorCommand::NoteLengthDecrement), key!(KeyCode::Char('[')) => Some(PhraseEditorCommand::NoteLengthDec),
key!(KeyCode::Char(']')) => Some(PhraseEditorCommand::NoteLengthIncrement), key!(KeyCode::Char(']')) => Some(PhraseEditorCommand::NoteLengthInc),
key!(KeyCode::Char('a')) => Some(PhraseEditorCommand::NoteAppend), key!(KeyCode::Char('a')) => Some(PhraseEditorCommand::NoteAppend),
key!(KeyCode::Char('s')) => Some(PhraseEditorCommand::NoteSet), key!(KeyCode::Char('s')) => Some(PhraseEditorCommand::NoteSet),
key!(KeyCode::Char('-')) => Some(PhraseEditorCommand::TimeZoomOut), key!(KeyCode::Char('-')) => Some(PhraseEditorCommand::TimeZoomOut),
@ -224,7 +224,7 @@ impl<E: Engine> Command<Sequencer<E>> for SequencerCommand {
impl<E: Engine> Command<PhrasePool<E>> for PhrasePoolCommand { impl<E: Engine> Command<PhrasePool<E>> for PhrasePoolCommand {
fn run (&self, state: &mut PhrasePool<E>) -> Perhaps<Self> { fn run (&self, state: &mut PhrasePool<E>) -> Perhaps<Self> {
match self { match self {
Self::Previous => { Self::Prev => {
state.select_prev() state.select_prev()
}, },
Self::Next => { Self::Next => {
@ -319,13 +319,13 @@ impl<E: Engine> Command<PhrasePool<E>> for PhraseLengthCommand {
Self::Begin => { Self::Begin => {
unreachable!(); unreachable!();
}, },
Self::Previous => { Self::Prev => {
focus.prev() focus.prev()
}, },
Self::Next => { Self::Next => {
focus.next() focus.next()
}, },
Self::Increment => match focus { Self::Inc => match focus {
PhraseLengthFocus::Bar => { PhraseLengthFocus::Bar => {
*length += 4 * PPQ *length += 4 * PPQ
}, },
@ -336,7 +336,7 @@ impl<E: Engine> Command<PhrasePool<E>> for PhraseLengthCommand {
*length += 1 *length += 1
}, },
}, },
Self::Decrement => match focus { Self::Dec => match focus {
PhraseLengthFocus::Bar => { PhraseLengthFocus::Bar => {
*length = length.saturating_sub(4 * PPQ) *length = length.saturating_sub(4 * PPQ)
}, },
@ -387,10 +387,10 @@ impl<E: Engine> Command<PhraseEditor<E>> for PhraseEditorCommand {
Self::TimeZoomIn => { Self::TimeZoomIn => {
state.time_zoom_in() state.time_zoom_in()
}, },
Self::NoteLengthDecrement => { Self::NoteLengthDec => {
state.note_length_dec() state.note_length_dec()
}, },
Self::NoteLengthIncrement => { Self::NoteLengthInc => {
state.note_length_inc() state.note_length_inc()
}, },
Self::NotePageUp => { Self::NotePageUp => {