mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
wip: running interface in separate or combined mode
also disassociating render functions from state structs
This commit is contained in:
parent
f9218e887a
commit
d6bf840a1f
31 changed files with 905 additions and 532 deletions
58
src/sequencer/handle.rs
Normal file
58
src/sequencer/handle.rs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
use crate::prelude::*;
|
||||
use super::Sequencer;
|
||||
|
||||
fn handle (
|
||||
state: &mut Sequencer,
|
||||
event: crossterm::event::Event
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
use crossterm::event::{Event, KeyCode, KeyModifiers};
|
||||
if let Event::Key(event) = event {
|
||||
match event.code {
|
||||
KeyCode::Char('c') => {
|
||||
if event.modifiers == KeyModifiers::CONTROL {
|
||||
state.exit = true;
|
||||
}
|
||||
},
|
||||
KeyCode::Char('[') => {
|
||||
if state.duration > 0 {
|
||||
state.duration = state.duration - 1
|
||||
}
|
||||
},
|
||||
KeyCode::Char(']') => {
|
||||
state.duration = state.duration + 1
|
||||
},
|
||||
KeyCode::Down => {
|
||||
state.cursor.1 = if state.cursor.1 >= 3 {
|
||||
0
|
||||
} else {
|
||||
state.cursor.1 + 1
|
||||
}
|
||||
},
|
||||
KeyCode::Up => {
|
||||
state.cursor.1 = if state.cursor.1 == 0 {
|
||||
3
|
||||
} else {
|
||||
state.cursor.1 - 1
|
||||
}
|
||||
},
|
||||
KeyCode::Left => {
|
||||
state.cursor.0 = if state.cursor.0 == 0 {
|
||||
63
|
||||
} else {
|
||||
state.cursor.0 - 1
|
||||
}
|
||||
},
|
||||
KeyCode::Right => {
|
||||
state.cursor.0 = if state.cursor.0 == 63 {
|
||||
0
|
||||
} else {
|
||||
state.cursor.0 + 1
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
println!("{event:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue