mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
keymap is now constant PhraseEditorModel::KEYS
This commit is contained in:
parent
9f85012259
commit
c83f949f53
2 changed files with 34 additions and 33 deletions
|
|
@ -40,8 +40,7 @@ impl PhraseEditorModel {
|
|||
fn phrase_length (&self) -> usize {
|
||||
self.phrase().as_ref().map(|p|p.read().unwrap().length).unwrap_or(1)
|
||||
}
|
||||
fn to_editor_command (&self, from: &TuiInput) -> Option<PhraseCommand> {
|
||||
event_map!([
|
||||
const KEYS: [(TuiEvent, &'static dyn Fn(&Self)->PhraseCommand);27] = [
|
||||
(kexp!(Ctrl-Alt-Up), &|s: &Self|SetNoteScroll(s.note_point() + 3)),
|
||||
(kexp!(Ctrl-Alt-Down), &|s: &Self|SetNoteScroll(s.note_point().saturating_sub(3))),
|
||||
(kexp!(Ctrl-Alt-Left), &|s: &Self|SetTimeScroll(s.time_point().saturating_sub(s.time_zoom().get()))),
|
||||
|
|
@ -72,7 +71,9 @@ impl PhraseEditorModel {
|
|||
//key_pat!(Char('`')) -> ToggleDirection,
|
||||
//// TODO: key_pat!(Char('/')) => // toggle 3plet
|
||||
//// TODO: key_pat!(Char('?')) => // toggle dotted
|
||||
]).handle(self, from.event())
|
||||
];
|
||||
fn to_editor_command (&self, from: &TuiInput) -> Option<PhraseCommand> {
|
||||
event_map!(Self::KEYS).handle(self, from.event())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ impl<'a, const N: usize, E: PartialEq, T, U> EventMap<'a, N, E, T, U> {
|
|||
}
|
||||
|
||||
#[macro_export] macro_rules! kexp {
|
||||
(Ctrl-Alt-$code:ident) => { key_event_expr!($code, KeyModifiers::CONTROL | KeyModifiers::ALT) };
|
||||
(Ctrl-Alt-$code:ident) => { key_event_expr!($code, KeyModifiers::from_bits(0b0000_0110).unwrap()) };
|
||||
(Ctrl-$code:ident) => { key_event_expr!($code, KeyModifiers::CONTROL) };
|
||||
(Alt-$code:ident) => { key_event_expr!($code, KeyModifiers::ALT) };
|
||||
(Shift-$code:ident) => { key_event_expr!($code, KeyModifiers::SHIFT) };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue