navigate by note_len

This commit is contained in:
🪞👃🪞 2024-12-10 15:08:51 +01:00
parent 9b705f48e0
commit 1aa4386e42

View file

@ -614,6 +614,7 @@ impl InputToCommand<Tui, PhraseEditorModel> for PhraseCommand {
let time_point = state.time_point.load(Ordering::Relaxed);
let time_zoom = state.view_mode.time_zoom();
let length = state.phrase.as_ref().map(|p|p.read().unwrap().length).unwrap_or(1);
let note_len = state.note_len;
Some(match from.event() {
key!(Char('`')) => ToggleDirection,
key!(Esc) => SetEditMode(PhraseEditMode::Scroll),
@ -633,8 +634,8 @@ impl InputToCommand<Tui, PhraseEditorModel> for PhraseCommand {
key!(Down) => SetNoteScroll(note_lo.saturating_sub(1)),
key!(PageUp) => SetNoteScroll(note_lo + 3),
key!(PageDown) => SetNoteScroll(note_lo.saturating_sub(3)),
key!(Left) => SetTimeScroll(time_start.saturating_sub(1)),
key!(Right) => SetTimeScroll(time_start + 1),
key!(Left) => SetTimeScroll(time_start.saturating_sub(time_zoom)),
key!(Right) => SetTimeScroll(time_start + time_zoom),
_ => return None
},
PhraseEditMode::Note => match from.event() {
@ -643,8 +644,10 @@ impl InputToCommand<Tui, PhraseEditorModel> for PhraseCommand {
key!(Down) => SetNoteCursor(note_point.saturating_sub(1)),
key!(PageUp) => SetNoteCursor(note_point + 3),
key!(PageDown) => SetNoteCursor(note_point.saturating_sub(3)),
key!(Left) => SetTimeCursor(time_point.saturating_sub(time_zoom)),
key!(Right) => SetTimeCursor((time_point + time_zoom) % length),
key!(Left) => SetTimeCursor(time_point.saturating_sub(note_len)),
key!(Right) => SetTimeCursor((time_point + note_len) % length),
key!(Shift-Left) => SetTimeCursor(time_point.saturating_sub(time_zoom)),
key!(Shift-Right) => SetTimeCursor((time_point + time_zoom) % length),
_ => return None
},
}