From 383e534692fac04a4573942be57061d9da62d89c Mon Sep 17 00:00:00 2001 From: i do not exist Date: Tue, 30 Jun 2026 15:38:56 +0300 Subject: [PATCH] restruct: 3e --- src/app.rs | 36 +++++++++++++++++++----------------- tengri | 2 +- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/app.rs b/src/app.rs index c198381d..58057bf4 100644 --- a/src/app.rs +++ b/src/app.rs @@ -402,6 +402,8 @@ namespace!(App: Option { symbol = |app| { ":editor/pitch" => Some((app.editor().as_ref().map(|e|e.get_note_pos()).unwrap() as u8).into()) }; }); +namespace!(App: Option { symbol = |app| {}; }); + namespace!(App: Option { 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 for App { - fn interpret_expr <'a> (&'a self, to: &mut Tui, lang: &'a impl Expression) -> Usually<()> { - app_interpret_expr(self, to, lang) +impl Interpret> for App { + fn interpret_expr <'a> (&'a self, to: &mut Tui, lang: &'a impl Expression) -> Usually> { + 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> { + 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> { + 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> { 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 { diff --git a/tengri b/tengri index 4e6c62a7..347151f7 160000 --- a/tengri +++ b/tengri @@ -1 +1 @@ -Subproject commit 4e6c62a7f1edd9e173065afbb8e9cf897baa2ead +Subproject commit 347151f7fcc2f0500de2c293d5d83b79f1e833d9