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

2
tengri

@ -1 +1 @@
Subproject commit 4e6c62a7f1edd9e173065afbb8e9cf897baa2ead Subproject commit 347151f7fcc2f0500de2c293d5d83b79f1e833d9