20 new errors rear their ugly heads

This commit is contained in:
🪞👃🪞 2024-09-05 23:19:53 +03:00
parent 92d747ba2a
commit e7f2284e5e
8 changed files with 167 additions and 174 deletions

View file

@ -28,3 +28,5 @@ pub trait ExitableComponent<E>: Exit + Component<E> where E: Engine {
Box::new(self) Box::new(self)
} }
} }
impl<E: Engine, C: Component<E> + Exit> ExitableComponent<E> for C {}

View file

@ -41,28 +41,28 @@ pub fn handle_keymap <T> (
#[macro_export] macro_rules! key { #[macro_export] macro_rules! key {
($code:pat) => { ($code:pat) => {
crossterm::event::Event::Key(crossterm::event::KeyEvent { TuiEvent::Input(crossterm::event::Event::Key(crossterm::event::KeyEvent {
code: $code, code: $code,
modifiers: crossterm::event::KeyModifiers::NONE, modifiers: crossterm::event::KeyModifiers::NONE,
kind: crossterm::event::KeyEventKind::Press, kind: crossterm::event::KeyEventKind::Press,
state: crossterm::event::KeyEventState::NONE state: crossterm::event::KeyEventState::NONE
}) }))
}; };
(Ctrl-$code:pat) => { (Ctrl-$code:pat) => {
crossterm::event::Event::Key(crossterm::event::KeyEvent { TuiEvent::Input(crossterm::event::Event::Key(crossterm::event::KeyEvent {
code: $code, code: $code,
modifiers: crossterm::event::KeyModifiers::CONTROL, modifiers: crossterm::event::KeyModifiers::CONTROL,
kind: crossterm::event::KeyEventKind::Press, kind: crossterm::event::KeyEventKind::Press,
state: crossterm::event::KeyEventState::NONE state: crossterm::event::KeyEventState::NONE
}) }))
}; };
(Alt-$code:pat) => { (Alt-$code:pat) => {
crossterm::event::Event::Key(crossterm::event::KeyEvent { TuiEvent::Input(crossterm::event::Event::Key(crossterm::event::KeyEvent {
code: $code, code: $code,
modifiers: crossterm::event::KeyModifiers::ALT, modifiers: crossterm::event::KeyModifiers::ALT,
kind: crossterm::event::KeyEventKind::Press, kind: crossterm::event::KeyEventKind::Press,
state: crossterm::event::KeyEventState::NONE state: crossterm::event::KeyEventState::NONE
}) }))
} }
} }

View file

@ -22,7 +22,7 @@ pub struct LV2Plugin {
} }
impl LV2Plugin { impl LV2Plugin {
pub fn from_edn <'e, E: Engine> (args: &[Edn<'e>]) -> Usually<JackDevice<E>> { pub fn from_edn <'e> (args: &[Edn<'e>]) -> Usually<JackDevice<Tui>> {
let mut name = String::new(); let mut name = String::new();
let mut path = String::new(); let mut path = String::new();
edn!(edn in args { edn!(edn in args {

View file

@ -3,7 +3,6 @@ use crate::*;
impl Handle<Tui> for Track<Tui> { impl Handle<Tui> for Track<Tui> {
fn handle (&mut self, from: &Tui) -> Perhaps<bool> { fn handle (&mut self, from: &Tui) -> Perhaps<bool> {
match from.event() { match from.event() {
TuiEvent::Input(key) => match key {
//, NONE, "chain_cursor_up", "move cursor up", || { //, NONE, "chain_cursor_up", "move cursor up", || {
key!(KeyCode::Up) => { key!(KeyCode::Up) => {
Ok(Some(true)) Ok(Some(true))
@ -34,8 +33,6 @@ impl Handle<Tui> for Track<Tui> {
Ok(Some(true)) Ok(Some(true))
}, },
_ => Ok(None) _ => Ok(None)
},
_ => Ok(None)
} }
} }
} }

View file

@ -10,7 +10,6 @@ impl Handle<Tui> for Arranger<Tui> {
return Ok(result) return Ok(result)
} }
match from.event() { match from.event() {
TuiEvent::Input(key) => match key {
// mode_switch: switch the display mode // mode_switch: switch the display mode
key!(KeyCode::Char('`')) => { key!(KeyCode::Char('`')) => {
self.mode.to_next(); self.mode.to_next();
@ -57,7 +56,7 @@ impl Handle<Tui> for Arranger<Tui> {
self.phrase_next(); self.phrase_next();
Ok(Some(true)) Ok(Some(true))
}, },
// increment: use next clip here // decrement: use previous next clip here
key!(KeyCode::Char(',')) => { key!(KeyCode::Char(',')) => {
self.phrase_prev(); self.phrase_prev();
Ok(Some(true)) Ok(Some(true))
@ -93,8 +92,6 @@ impl Handle<Tui> for Arranger<Tui> {
Ok(Some(true)) Ok(Some(true))
}, },
_ => Ok(None) _ => Ok(None)
},
_ => Ok(None)
} }
} }
} }

View file

@ -3,7 +3,7 @@ include!("lib.rs");
use tek_core::clap::{self, Parser}; use tek_core::clap::{self, Parser};
pub fn main () -> Usually<()> { pub fn main () -> Usually<()> {
tek_core::run(Arc::new(RwLock::new(crate::ArrangerStandalone::from_args()?)))?; Tui::run(Arc::new(RwLock::new(crate::ArrangerStandalone::from_args()?)))?;
Ok(()) Ok(())
} }
@ -75,25 +75,26 @@ impl ArrangerStandalone {
} }
} }
impl Render for ArrangerStandalone { impl Render<Tui> for ArrangerStandalone {
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> { fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
let area = to.area();
let sequencer = self.arranger.sequencer(); let sequencer = self.arranger.sequencer();
let result = Split::down() let result = Split::down()
.add_ref(&self.transport) .add_ref(&self.transport)
.add_ref(&self.arranger) .add_ref(&self.arranger)
.add_ref(&sequencer) .add_ref(&sequencer)
//.focus(Some(self.focus)) //.focus(Some(self.focus))
.render(buf, area)?; .render(to)?;
if let Some(ref modal) = self.arranger.modal { if let Some(ref modal) = self.arranger.modal {
fill_bg(buf, area, Nord::bg_lo(false, false)); to.fill_bg(area, Nord::bg_lo(false, false));
fill_fg(buf, area, Nord::bg_hi(false, false)); to.fill_fg(area, Nord::bg_hi(false, false));
modal.render(buf, area)?; modal.render(to)?;
} }
Ok(result) Ok(result)
} }
} }
impl Handle for ArrangerStandalone { impl Handle<Tui> for ArrangerStandalone {
fn handle (&mut self, e: &AppEvent) -> Usually<bool> { fn handle (&mut self, e: &AppEvent) -> Usually<bool> {
match e { match e {
AppEvent::Input(Event::Key(KeyEvent { code: KeyCode::Char(' '), .. })) => { AppEvent::Input(Event::Key(KeyEvent { code: KeyCode::Char(' '), .. })) => {

View file

@ -2,48 +2,45 @@ use crate::*;
impl Handle<Tui> for Sequencer { impl Handle<Tui> for Sequencer {
fn handle (&mut self, from: &Tui) -> Perhaps<bool> { fn handle (&mut self, from: &Tui) -> Perhaps<bool> {
handle_keymap(self, &from.event(), KEYMAP_SEQUENCER) match from.event() {
// NONE, "seq_cursor_up", "move cursor up", |sequencer: &mut Sequencer| {
key!(KeyCode::Up) => {
match self.entered {
true => { self.note_axis.point_dec(); },
false => { self.note_axis.start_dec(); },
}
Ok(Some(true))
},
// NONE, "seq_cursor_down", "move cursor down", |self: &mut Sequencer| {
key!(KeyCode::Down) => {
match self.entered {
true => { self.note_axis.point_inc(); },
false => { self.note_axis.start_inc(); },
}
Ok(Some(true))
},
// NONE, "seq_cursor_left", "move cursor up", |self: &mut Sequencer| {
key!(KeyCode::Left) => {
match self.entered {
true => { self.time_axis.point_dec(); },
false => { self.time_axis.start_dec(); },
}
Ok(Some(true))
},
// NONE, "seq_cursor_right", "move cursor up", |self: &mut Sequencer| {
key!(KeyCode::Right) => {
match self.entered {
true => { self.time_axis.point_inc(); },
false => { self.time_axis.start_inc(); },
}
Ok(Some(true))
},
// NONE, "seq_mode_switch", "switch the display mode", |self: &mut Sequencer| {
key!(KeyCode::Char('`')) => {
self.mode = !self.mode;
Ok(Some(true))
},
_ => Ok(None)
}
} }
} }
/// Key bindings for phrase editor.
pub const KEYMAP_SEQUENCER: &'static [KeyBinding<Sequencer>] = keymap!(Sequencer {
[Up, NONE, "seq_cursor_up", "move cursor up", |sequencer: &mut Sequencer| {
match sequencer.entered {
true => { sequencer.note_axis.point_dec(); },
false => { sequencer.note_axis.start_dec(); },
}
Ok(true)
}],
[Down, NONE, "seq_cursor_down", "move cursor down", |sequencer: &mut Sequencer| {
match sequencer.entered {
true => { sequencer.note_axis.point_inc(); },
false => { sequencer.note_axis.start_inc(); },
}
Ok(true)
}],
[Left, NONE, "seq_cursor_left", "move cursor up", |sequencer: &mut Sequencer| {
match sequencer.entered {
true => { sequencer.time_axis.point_dec(); },
false => { sequencer.time_axis.start_dec(); },
}
Ok(true)
}],
[Right, NONE, "seq_cursor_right", "move cursor up", |sequencer: &mut Sequencer| {
match sequencer.entered {
true => { sequencer.time_axis.point_inc(); },
false => { sequencer.time_axis.start_inc(); },
}
Ok(true)
}],
[Char('`'), NONE, "seq_mode_switch", "switch the display mode", |sequencer: &mut Sequencer| {
sequencer.mode = !sequencer.mode;
Ok(true)
}],
/*
[Char('a'), NONE, "note_add", "Add note", note_add],
[Char('z'), NONE, "note_del", "Delete note", note_del],
[CapsLock, NONE, "advance", "Toggle auto advance", nop],
[Char('w'), NONE, "rest", "Advance by note duration", nop],
*/
});

View file

@ -1,6 +1,5 @@
//! Phrase editor. //! Phrase editor.
include!("lib.rs"); include!("lib.rs");
pub fn main () -> Usually<()> { pub fn main () -> Usually<()> {
tek_core::run(Arc::new(RwLock::new(crate::Sequencer::from_args())))?; Tui::run(Arc::new(RwLock::new(crate::Sequencer::from_args()))).map(|_|())
Ok(())
} }