big flat; add midi/audio port handling

This commit is contained in:
facile pop culture reference 2026-07-26 21:49:32 +03:00
parent 66ac2bcbb6
commit c0d6d0174e
16 changed files with 1086 additions and 315 deletions

View file

@ -30,23 +30,37 @@ tui_view!(self: State {
let widget = thunk(move|to: &mut Tui|self.interpret(to, &src));
self.size.of(south(title, north(code, widget)))
});
tui_ns!(self: State, to, src {
match src.src()? {
Some(":foo") => "foo".draw(to),
Some(":bar") => "bar".draw(to),
Some(":foobar") => "FOOBAR".draw(to),
_ => todo!()
impl Interpret<Tui, Color> for State {
fn interpret_expr (&self, to: &mut Tui, expr: &impl Language) -> Usually<Color> {
let expr = expr.expr()?;
match expr.head()? {
Some("g") if let Some(tail) = expr.tail()? => {
Color::new_g(tail.head()?, try_to_u8)
},
Some("rgb") if let Some(tail) = expr.tail()? => {
Color::new_rgb(tail.head()?)
},
_ => Err(format!("not a color").into())
}
}
});
#[derive(Debug)]
enum Action {
/** Increment cursor */ Next,
/** Decrement cursor */ Prev,
}
impl Action {
fn eval (&self, state: &mut State) -> Perhaps<Self> {
use Action::*;
match self { Next => state.next(), Prev => state.prev(), }
impl Interpret<Tui, Option<XYWH<u16>>> for State {
fn interpret_word (&self, to: &mut Tui, sym: &impl Language) -> Perhaps<XYWH<u16>> {
match sym.src()? {
Some(":foo") => "foo".draw(to),
Some(":bar") => "bar".draw(to),
Some(":foobar") => "FOOBAR".draw(to),
_ => todo!()
}
}
fn interpret_expr (&self, to: &mut Tui, src: &impl Expression) -> Perhaps<XYWH<u16>> {
Ok(Some(if let Some(area) = eval_view(self, to, src)? {
area
} else if let Some(area) = eval_view_tui(self, to, src)? {
area
} else {
return Err(format!("App::interpret_expr: unexpected: {src:?}").into())
}))
}
}
impl State {
@ -59,6 +73,17 @@ impl State {
Ok(Some(Action::Next))
}
}
#[derive(Debug)]
enum Action {
/** Increment cursor */ Next,
/** Decrement cursor */ Prev,
}
impl Action {
fn eval (&self, state: &mut State) -> Perhaps<Self> {
use Action::*;
match self { Next => state.next(), Prev => state.prev(), }
}
}
const VIEWS: &'static [&'static str] = &[
stringify! { :foobar },
stringify! { (bg (g 8) :foobar) },