diff --git a/crates/app/src/model.rs b/crates/app/src/model.rs index ebd4b52d..0b095118 100644 --- a/crates/app/src/model.rs +++ b/crates/app/src/model.rs @@ -327,16 +327,16 @@ pub struct Configuration { /// Description of configuration pub info: Option>, /// View definition - pub view: TokenIter<'static>, + pub view: Cst, // Input keymap - pub keys: InputMap<'static, App, AppCommand, TuiIn, TokenIter<'static>>, + pub keys: InputMap, } impl Configuration { pub fn new (path: &impl AsRef, _watch: bool) -> Usually { let text = read_and_leak(path.as_ref())?; - let [name, info, view, keys] = Self::parse(TokenIter::from(text))?; + let [name, info, view, keys] = Self::parse(Cst::from(text))?; Ok(Self { path: path.as_ref().into(), info: info.map(Self::parse_info).flatten(), @@ -346,11 +346,11 @@ impl Configuration { }) } - fn parse (iter: TokenIter) -> Usually<[Option;4]> { - let mut name: Option = None; - let mut info: Option = None; - let mut view: Option = None; - let mut keys: Option = None; + fn parse (iter: Cst) -> Usually<[Option;4]> { + let mut name: Option = None; + let mut info: Option = None; + let mut view: Option = None; + let mut keys: Option = None; for token in iter { match token.value { Value::Exp(_, mut exp) => { @@ -378,7 +378,7 @@ impl Configuration { Ok([name, info, view, keys]) } - fn parse_info (mut iter: TokenIter) -> Option> { + fn parse_info (mut iter: Cst) -> Option> { iter.next().and_then(|x|if let Value::Str(x) = x.value { Some(x.into()) } else { @@ -386,7 +386,7 @@ impl Configuration { }) } - fn parse_name (mut iter: TokenIter) -> Option> { + fn parse_name (mut iter: Cst) -> Option> { iter.next().and_then(|x|if let Value::Str(x) = x.value { Some(x.into()) } else { @@ -394,7 +394,7 @@ impl Configuration { }) } - fn parse_view (iter: Option) -> Usually { + fn parse_view (iter: Option) -> Usually { if let Some(view) = iter { Ok(view) } else { @@ -402,8 +402,8 @@ impl Configuration { } } - fn parse_keys (base: &impl AsRef, iter: Option>) - -> Usually>> + fn parse_keys (base: &impl AsRef, iter: Option) + -> Usually> { if iter.is_none() { return Err(format!("missing keys definition").into()) diff --git a/crates/app/src/view.rs b/crates/app/src/view.rs index efd6d899..2702c49b 100644 --- a/crates/app/src/view.rs +++ b/crates/app/src/view.rs @@ -24,45 +24,47 @@ impl> Content for ErrorBoundary { impl App { pub fn view (model: &Self) -> impl Content + '_ { - ErrorBoundary::new(Ok(Some(Tui::bg(Black, "give or take")))) + ErrorBoundary::new(Ok(Some(Tui::bg(Black, model.view_nil())))) //ErrorBoundary::new(Take::take(model, &mut model.config.view.clone())) //ErrorBoundary::new(Give::give(model, &mut model.config.view.clone())) } } +content!(TuiOut: |self: App| ErrorBoundary::new(Ok(Some(Tui::bg(Black, self.view_nil()))))); + #[tengri_proc::view(TuiOut)] impl App { - //pub fn view_nil (model: &Self) -> impl Content { - //"nil" - //} - //pub fn view_dialog (model: &Self) -> impl Content + use<'_> { - //model.dialog.as_ref().map(|dialog|Bsp::b("", - //Fixed::xy(70, 23, Tui::fg_bg(Rgb(255,255,255), Rgb(16,16,16), Bsp::b( - //Repeat(" "), Outer(true, Style::default().fg(Tui::g(96))) - //.enclose(dialog)))))) - //} - //pub fn view_meters_input (model: &Self) -> impl Content + use<'_> { - //model.project.sampler().map(|s| + pub fn view_nil (&self) -> impl Content + '_ { + "nil" + } + pub fn view_dialog (&self) -> impl Content + use<'_> { + self.dialog.as_ref().map(|dialog|Bsp::b("", + Fixed::xy(70, 23, Tui::fg_bg(Rgb(255,255,255), Rgb(16,16,16), Bsp::b( + Repeat(" "), Outer(true, Style::default().fg(Tui::g(96))) + .enclose(dialog)))))) + } + //pub fn view_meters_input (&self) -> impl Content + use<'_> { + //self.project.sampler().map(|s| //s.view_meters_input()) //} - //pub fn view_meters_output (model: &Self) -> impl Content + use<'_> { - //model.project.sampler().map(|s| + //pub fn view_meters_output (&self) -> impl Content + use<'_> { + //self.project.sampler().map(|s| //s.view_meters_output()) //} - //pub fn view_history (model: &Self) -> impl Content { - //Fixed::y(1, Fill::x(Align::w(FieldH(model.color, - //format!("History ({})", model.history.len()), - //model.history.last().map(|last|Fill::x(Align::w(format!("{:?}", last.0)))))))) + //pub fn view_history (&self) -> impl Content { + //Fixed::y(1, Fill::x(Align::w(FieldH(self.color, + //format!("History ({})", self.history.len()), + //self.history.last().map(|last|Fill::x(Align::w(format!("{:?}", last.0)))))))) //} - //pub fn view_status_h2 (model: &Self) -> impl Content { - //model.update_clock(); - //let theme = model.color; - //let clock = model.clock(); + //pub fn view_status_h2 (&self) -> impl Content { + //self.update_clock(); + //let theme = self.color; + //let clock = self.clock(); //let playing = clock.is_rolling(); //let cache = clock.view_cache.clone(); - ////let selection = model.selection().describe(model.tracks(), model.scenes()); - //let hist_len = model.history.len(); - //let hist_last = model.history.last(); + ////let selection = self.selection().describe(self.tracks(), self.scenes()); + //let hist_len = self.history.len(); + //let hist_last = self.history.last(); //Fixed::y(2, Stack::east(move|add: &mut dyn FnMut(&dyn Render)|{ //add(&Fixed::x(5, Tui::bg(if playing { Rgb(0, 128, 0) } else { Rgb(128, 64, 0) }, //Either::new(false, // TODO @@ -97,8 +99,8 @@ impl App { ////hist_last.map(|last|Fill::x(Align::w(format!("{:?}", last.0))))))), ////"" ////)); - //////if let Some(last) = model.history.last() { - //////add(&FieldV(theme, format!("History ({})", model.history.len()), + //////if let Some(last) = self.history.last() { + //////add(&FieldV(theme, format!("History ({})", self.history.len()), //////Fill::x(Align::w(format!("{:?}", last.0))))); //////} //} diff --git a/deps/tengri b/deps/tengri index 31e84bf5..21832453 160000 --- a/deps/tengri +++ b/deps/tengri @@ -1 +1 @@ -Subproject commit 31e84bf5b3a44fb0b51f853f135109ea184ace84 +Subproject commit 21832453d9554752a77278385446518744baeee8