mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
64 lines
2.5 KiB
Rust
64 lines
2.5 KiB
Rust
use crate::*;
|
|
impl Handle<Tui> for Plugin<Tui> {
|
|
fn handle (&mut self, from: &TuiInput) -> Perhaps<bool> {
|
|
match from.event() {
|
|
key!(KeyCode::Up) => {
|
|
self.selected = self.selected.saturating_sub(1);
|
|
Ok(Some(true))
|
|
},
|
|
key!(KeyCode::Down) => {
|
|
self.selected = (self.selected + 1).min(match &self.plugin {
|
|
Some(PluginKind::LV2(LV2Plugin { port_list, .. })) => port_list.len() - 1,
|
|
_ => unimplemented!()
|
|
});
|
|
Ok(Some(true))
|
|
},
|
|
key!(KeyCode::PageUp) => {
|
|
self.selected = self.selected.saturating_sub(8);
|
|
Ok(Some(true))
|
|
},
|
|
key!(KeyCode::PageDown) => {
|
|
self.selected = (self.selected + 10).min(match &self.plugin {
|
|
Some(PluginKind::LV2(LV2Plugin { port_list, .. })) => port_list.len() - 1,
|
|
_ => unimplemented!()
|
|
});
|
|
Ok(Some(true))
|
|
},
|
|
key!(KeyCode::Char(',')) => {
|
|
match self.plugin.as_mut() {
|
|
Some(PluginKind::LV2(LV2Plugin { port_list, ref mut instance, .. })) => {
|
|
let index = port_list[self.selected].index;
|
|
if let Some(value) = instance.control_input(index) {
|
|
instance.set_control_input(index, value - 0.01);
|
|
}
|
|
},
|
|
_ => {}
|
|
}
|
|
Ok(Some(true))
|
|
},
|
|
key!(KeyCode::Char('.')) => {
|
|
match self.plugin.as_mut() {
|
|
Some(PluginKind::LV2(LV2Plugin { port_list, ref mut instance, .. })) => {
|
|
let index = port_list[self.selected].index;
|
|
if let Some(value) = instance.control_input(index) {
|
|
instance.set_control_input(index, value + 0.01);
|
|
}
|
|
},
|
|
_ => {}
|
|
}
|
|
Ok(Some(true))
|
|
},
|
|
key!(KeyCode::Char('g')) => {
|
|
match self.plugin {
|
|
Some(PluginKind::LV2(ref mut plugin)) => {
|
|
plugin.ui_thread = Some(run_lv2_ui(LV2PluginUI::new()?)?);
|
|
},
|
|
Some(_) => unreachable!(),
|
|
None => {}
|
|
}
|
|
Ok(Some(true))
|
|
},
|
|
_ => Ok(None)
|
|
}
|
|
}
|
|
}
|