wip: running interface in separate or combined mode

also disassociating render functions from state structs
This commit is contained in:
🪞👃🪞 2024-05-28 22:13:20 +03:00
parent f9218e887a
commit d6bf840a1f
31 changed files with 905 additions and 532 deletions

58
src/sequencer/handle.rs Normal file
View 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(())
}