From 121a2737885a7d99cbf1392921412871cd3767ea Mon Sep 17 00:00:00 2001 From: unspeaker Date: Tue, 29 Jul 2025 17:04:24 +0300 Subject: [PATCH 1/3] wip: 1e ! --- crates/app/src/model.rs | 57 ++++++++++++++++++++++++----------------- deps/tengri | 2 +- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/crates/app/src/model.rs b/crates/app/src/model.rs index 113ec3b4..f360bca5 100644 --- a/crates/app/src/model.rs +++ b/crates/app/src/model.rs @@ -335,29 +335,40 @@ pub struct Configuration { impl Configuration { pub fn from_path (path: &impl AsRef, _watch: bool) -> Usually { - let mut config = Self::default(); - config.path = path.as_ref().into(); - let mut dsl = read_and_leak(path.as_ref())?; - while let Some(mut exp) = dsl.exp_next()? { - match exp.exp_head()?.key()? { - Some("name") => match exp.text()? { - Some(name) => config.name = Some(name.into()), - _ => return Err(format!("missing name definition").into()) - }, - Some("info") => match exp.text()? { - Some(info) => config.info = Some(info.into()), - _ => return Err(format!("missing info definition").into()) - }, - Some("keys") => match exp.text()? { - Some(keys) => config.keys = EventMap::from_dsl(keys)?, - _ => return Err(format!("missing keys definition").into()) - }, - Some("view") => match exp.exp_tail()? { - Some(tail) => config.view = tail.src().into(), - _ => return Err(format!("missing view definition").into()) - }, - Some(k) => return Err(format!("(e3) unexpected key {k:?} in {exp:?}").into()), - None => return Err(format!("(e2) unexpected exp {exp:?}").into()), + let mut config = Self { path: path.as_ref().into(), ..Default::default() }; + let mut dsl = read_and_leak(path.as_ref())?; + let mut head = dsl.head()?; + let mut tail = dsl.tail()?; + loop { + if let Some(exp) = head.exp()? { + match exp.head()?.key()? { + Some("name") => match exp.tail()?.text()? { + Some(name) => config.name = Some(name.into()), + _ => return Err(format!("missing name definition").into()) + }, + Some("info") => match exp.tail()?.text()? { + Some(info) => config.info = Some(info.into()), + _ => return Err(format!("missing info definition").into()) + }, + Some("keys") => match exp.tail()? { + Some(keys) => config.keys = EventMap::from_dsl(&mut &keys)?, + _ => return Err(format!("missing keys definition").into()) + }, + Some("view") => match exp.tail()? { + Some(tail) => config.view = tail.src().into(), + _ => return Err(format!("missing view definition").into()) + }, + Some(k) => return Err(format!("(e3) unexpected key {k:?} in {exp:?}").into()), + None => return Err(format!("(e2) unexpected exp {exp:?}").into()), + } + } else { + break + } + if let Some(next) = tail { + head = next.head()?; + tail = next.tail()?; + } else { + break } } Ok(config) diff --git a/deps/tengri b/deps/tengri index 360b404b..16969aeb 160000 --- a/deps/tengri +++ b/deps/tengri @@ -1 +1 @@ -Subproject commit 360b404b69abb1ec4e0e9959667e08d4b99c6131 +Subproject commit 16969aeb64a61a6c9819e7533e435ee2d693dddd From f60dd2185a9aeb9859f046a9f7c7f0c3982ff788 Mon Sep 17 00:00:00 2001 From: unspeaker Date: Tue, 29 Jul 2025 17:09:46 +0300 Subject: [PATCH 2/3] nil it runs again --- crates/app/src/model.rs | 8 ++++---- deps/tengri | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/app/src/model.rs b/crates/app/src/model.rs index f360bca5..d757b431 100644 --- a/crates/app/src/model.rs +++ b/crates/app/src/model.rs @@ -337,8 +337,8 @@ impl Configuration { pub fn from_path (path: &impl AsRef, _watch: bool) -> Usually { let mut config = Self { path: path.as_ref().into(), ..Default::default() }; let mut dsl = read_and_leak(path.as_ref())?; - let mut head = dsl.head()?; - let mut tail = dsl.tail()?; + let mut head: Option> = dsl.head()?.map(Into::into); + let mut tail: Option> = dsl.tail()?.map(Into::into); loop { if let Some(exp) = head.exp()? { match exp.head()?.key()? { @@ -365,8 +365,8 @@ impl Configuration { break } if let Some(next) = tail { - head = next.head()?; - tail = next.tail()?; + head = next.head()?.map(Into::into); + tail = next.tail()?.map(Into::into); } else { break } diff --git a/deps/tengri b/deps/tengri index 16969aeb..9f7d0efd 160000 --- a/deps/tengri +++ b/deps/tengri @@ -1 +1 @@ -Subproject commit 16969aeb64a61a6c9819e7533e435ee2d693dddd +Subproject commit 9f7d0efda5a71dfbb55c55dbff32c348b55dd870 From 9e147cda69845e368fd8eb39dc8d258dc68dacbc Mon Sep 17 00:00:00 2001 From: unspeaker Date: Tue, 29 Jul 2025 22:07:16 +0300 Subject: [PATCH 3/3] wip: let's add a main menu --- crates/app/src/view.rs | 9 ++++++++- deps/tengri | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/app/src/view.rs b/crates/app/src/view.rs index 2702c49b..75fef228 100644 --- a/crates/app/src/view.rs +++ b/crates/app/src/view.rs @@ -24,7 +24,7 @@ impl> Content for ErrorBoundary { impl App { pub fn view (model: &Self) -> impl Content + '_ { - ErrorBoundary::new(Ok(Some(Tui::bg(Black, model.view_nil())))) + ErrorBoundary::new(Ok(Some(Tui::bg(Black, model.view_menu())))) //ErrorBoundary::new(Take::take(model, &mut model.config.view.clone())) //ErrorBoundary::new(Give::give(model, &mut model.config.view.clone())) } @@ -37,6 +37,13 @@ impl App { pub fn view_nil (&self) -> impl Content + '_ { "nil" } + pub fn view_menu (&self) -> impl Content + use<'_> { + Stack::south(|add: &mut dyn FnMut(&dyn Render)|{ + add(&Tui::bold(true, "tek")); + add(&""); + add(&"+ new session"); + }) + } 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( diff --git a/deps/tengri b/deps/tengri index 9f7d0efd..85c30538 160000 --- a/deps/tengri +++ b/deps/tengri @@ -1 +1 @@ -Subproject commit 9f7d0efda5a71dfbb55c55dbff32c348b55dd870 +Subproject commit 85c305385bc08ef805afb113f677c510027a7234