mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
cmdsys: HandleKey -> MatchInput
This commit is contained in:
parent
1aaad23691
commit
2b163e9e27
7 changed files with 389 additions and 348 deletions
|
|
@ -1,15 +1,4 @@
|
|||
use crate::*;
|
||||
|
||||
impl Handle<Tui> for TransportToolbar<Tui> {
|
||||
fn handle (&mut self, from: &TuiInput) -> Perhaps<bool> {
|
||||
if let TuiEvent::Input(crossterm::event::Event::Key(event)) = from.event() {
|
||||
let _undo = self.handle_key(event)?;
|
||||
return Ok(Some(true))
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub enum TransportCommand {
|
||||
FocusNext,
|
||||
|
|
@ -27,20 +16,6 @@ pub enum TransportCommand {
|
|||
SetQuant(f64),
|
||||
SetSync(f64),
|
||||
}
|
||||
|
||||
impl HandleKey<TransportCommand> for TransportToolbar<Tui> {
|
||||
const HANDLE_KEY_MAP: &'static [(KeyEvent, TransportCommand)] = &[
|
||||
( key(KeyCode::Char(' ')), TransportCommand::FocusPrev),
|
||||
(shift(key(KeyCode::Char(' '))), TransportCommand::FocusPrev),
|
||||
( key(KeyCode::Left), TransportCommand::FocusPrev),
|
||||
( key(KeyCode::Right), TransportCommand::FocusNext),
|
||||
( key(KeyCode::Char('.')), TransportCommand::Increment),
|
||||
( key(KeyCode::Char(',')), TransportCommand::Decrement),
|
||||
( key(KeyCode::Char('>')), TransportCommand::FineIncrement),
|
||||
( key(KeyCode::Char('<')), TransportCommand::FineDecrement),
|
||||
];
|
||||
}
|
||||
|
||||
impl<E: Engine> Command<TransportToolbar<E>> for TransportCommand {
|
||||
fn run (&self, state: &mut TransportToolbar<E>) -> Perhaps<Self> {
|
||||
match self {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue