restruct: 3e

This commit is contained in:
i do not exist 2026-06-30 15:38:56 +03:00
parent 1e9a491b0c
commit 383e534692
2 changed files with 20 additions and 18 deletions

View file

@ -402,6 +402,8 @@ namespace!(App: Option<u7> { symbol = |app| {
":editor/pitch" => Some((app.editor().as_ref().map(|e|e.get_note_pos()).unwrap() as u8).into())
}; });
namespace!(App: Option<u16> { symbol = |app| {}; });
namespace!(App: Option<usize> { symbol = |app| {
":selected/scene" => app.selection().scene(),
":selected/track" => app.selection().track(),
@ -428,24 +430,26 @@ impl<'a> Namespace<'a, AppCommand> for App {
});
}
impl Interpret<Tui, ()> for App {
fn interpret_expr <'a> (&'a self, to: &mut Tui, lang: &'a impl Expression) -> Usually<()> {
app_interpret_expr(self, to, lang)
impl Interpret<Tui, XYWH<u16>> for App {
fn interpret_expr <'a> (&'a self, to: &mut Tui, lang: &'a impl Expression) -> Usually<XYWH<u16>> {
tek_expr(self, to, lang)
}
fn interpret_word <'a> (&'a self, to: &mut Tui, lang: &'a impl Expression) -> Usually<()> {
app_interpret_word(self, to, lang)
fn interpret_word <'a> (&'a self, to: &mut Tui, lang: &'a impl Expression) -> Usually<XYWH<u16>> {
tek_word(self, to, lang)
}
}
fn app_interpret_expr (state: &App, to: &mut Tui, lang: &impl Expression) -> Usually<()> {
if eval_view(state, to, lang)? || eval_view_tui(state, to, lang)? {
Ok(())
fn tek_expr (state: &App, to: &mut Tui, lang: &impl Expression) -> Usually<XYWH<u16>> {
if let Some(area) = eval_view(state, to, lang)? {
Ok(area)
} else if let Some(area) = eval_view_tui(state, to, lang)? {
Ok(area)
} else {
Err(format!("App::interpret_expr: unexpected: {lang:?}").into())
}
}
fn app_interpret_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usually<()> {
fn tek_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usually<XYWH<u16>> {
let mut frags = dsl.src()?.unwrap().split("/");
match frags.next() {
@ -482,12 +486,11 @@ fn app_interpret_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usua
let selected = selected;
Some(wh_full(thunk(move|to: &mut Tui|{
for (index, MenuItem(item, _)) in items.0.iter().enumerate() {
to.place(&y_push((2 * index) as u16,
fg_bg(
if *selected == index { Rgb(240,200,180) } else { Rgb(200, 200, 200) },
if *selected == index { Rgb(80, 80, 50) } else { Rgb(30, 30, 30) },
h_exact(2, origin_n(w_full(item)))
)));
y_push((2 * index) as u16,fg_bg(
if *selected == index { Rgb(240,200,180) } else { Rgb(200, 200, 200) },
if *selected == index { Rgb(80, 80, 50) } else { Rgb(30, 30, 30) },
h_exact(2, origin_n(w_full(item)))
)).draw(to);
}
Ok(to.area().into())
})))
@ -566,8 +569,7 @@ fn app_interpret_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usua
},
_ => unreachable!()
};
Ok(())
}
}
impl HasTrackScroll for App {