mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
cmdsys: separate match_key_static
This commit is contained in:
parent
1f375219db
commit
a4925082ca
2 changed files with 66 additions and 30 deletions
|
|
@ -155,7 +155,7 @@ impl Handle<Tui> for PhrasePool<Tui> {
|
|||
if let TuiEvent::Input(crossterm::event::Event::Key(key)) = from.event() {
|
||||
match self.mode {
|
||||
Some(PhrasePoolMode::Rename(..)) => {
|
||||
if HandleKey::<PhraseNameCommand>::match_key(key).is_some() {
|
||||
if HandleKey::<PhraseNameCommand>::match_key_static(key).is_some() {
|
||||
let _undo = HandleKey::<PhraseNameCommand>::handle_key(self, key)?;
|
||||
return Ok(Some(true))
|
||||
} else if let KeyEvent { code: KeyCode::Char(c), .. } = key {
|
||||
|
|
@ -332,14 +332,26 @@ impl<E: Engine> Command<PhrasePool<E>> for PhraseLengthCommand {
|
|||
focus.next()
|
||||
},
|
||||
Self::Increment => match focus {
|
||||
PhraseLengthFocus::Bar => { *length += 4 * PPQ },
|
||||
PhraseLengthFocus::Beat => { *length += PPQ },
|
||||
PhraseLengthFocus::Tick => { *length += 1 },
|
||||
PhraseLengthFocus::Bar => {
|
||||
*length += 4 * PPQ
|
||||
},
|
||||
PhraseLengthFocus::Beat => {
|
||||
*length += PPQ
|
||||
},
|
||||
PhraseLengthFocus::Tick => {
|
||||
*length += 1
|
||||
},
|
||||
},
|
||||
Self::Decrement => match focus {
|
||||
PhraseLengthFocus::Bar => { *length = length.saturating_sub(4 * PPQ) },
|
||||
PhraseLengthFocus::Beat => { *length = length.saturating_sub(PPQ) },
|
||||
PhraseLengthFocus::Tick => { *length = length.saturating_sub(1) },
|
||||
PhraseLengthFocus::Bar => {
|
||||
*length = length.saturating_sub(4 * PPQ)
|
||||
},
|
||||
PhraseLengthFocus::Beat => {
|
||||
*length = length.saturating_sub(PPQ)
|
||||
},
|
||||
PhraseLengthFocus::Tick => {
|
||||
*length = length.saturating_sub(1)
|
||||
},
|
||||
},
|
||||
Self::Cancel => {
|
||||
state.mode = None;
|
||||
|
|
@ -366,26 +378,41 @@ impl<E: Engine> Command<PhrasePool<E>> for PhraseLengthCommand {
|
|||
impl<E: Engine> Command<PhraseEditor<E>> for PhraseEditorCommand {
|
||||
fn run (&self, state: &mut PhraseEditor<E>) -> Perhaps<Self> {
|
||||
match self {
|
||||
Self::ToggleDirection => { state.mode = !state.mode; },
|
||||
Self::EnterEditMode => { state.entered = true; },
|
||||
Self::ExitEditMode => { state.entered = false; },
|
||||
|
||||
Self::TimeZoomOut => { state.time_zoom_out() },
|
||||
Self::TimeZoomIn => { state.time_zoom_in() },
|
||||
|
||||
Self::NoteLengthDecrement => { state.note_length_dec() },
|
||||
Self::NoteLengthIncrement => { state.note_length_inc() },
|
||||
Self::NotePageUp => { state.note_page_up() },
|
||||
Self::NotePageDown => { state.note_page_down() },
|
||||
Self::NoteAppend => if state.entered {
|
||||
Self::ToggleDirection => {
|
||||
state.mode = !state.mode;
|
||||
},
|
||||
Self::EnterEditMode => {
|
||||
state.entered = true;
|
||||
},
|
||||
Self::ExitEditMode => {
|
||||
state.entered = false;
|
||||
},
|
||||
Self::TimeZoomOut => {
|
||||
state.time_zoom_out()
|
||||
},
|
||||
Self::TimeZoomIn => {
|
||||
state.time_zoom_in()
|
||||
},
|
||||
Self::NoteLengthDecrement => {
|
||||
state.note_length_dec()
|
||||
},
|
||||
Self::NoteLengthIncrement => {
|
||||
state.note_length_inc()
|
||||
},
|
||||
Self::NotePageUp => {
|
||||
state.note_page_up()
|
||||
},
|
||||
Self::NotePageDown => {
|
||||
state.note_page_down()
|
||||
},
|
||||
Self::NoteAppend => if state.entered {
|
||||
state.put();
|
||||
state.time_cursor_advance();
|
||||
},
|
||||
Self::NoteSet => if state.entered {
|
||||
Self::NoteSet => if state.entered {
|
||||
state.put();
|
||||
},
|
||||
|
||||
Self::GoUp => match state.entered {
|
||||
Self::GoUp => match state.entered {
|
||||
true => state.note_cursor_inc(),
|
||||
false => state.note_scroll_inc(),
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue