use crate::*; impl Handle for Plugin { fn handle (&mut self, from: &TuiInput) -> Perhaps { 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) } } }