mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 03:36:41 +01:00
Compare commits
3 commits
4fbd6ab408
...
9e147cda69
| Author | SHA1 | Date | |
|---|---|---|---|
| 9e147cda69 | |||
| f60dd2185a | |||
| 121a273788 |
3 changed files with 43 additions and 25 deletions
|
|
@ -335,29 +335,40 @@ pub struct Configuration {
|
||||||
|
|
||||||
impl Configuration {
|
impl Configuration {
|
||||||
pub fn from_path (path: &impl AsRef<Path>, _watch: bool) -> Usually<Self> {
|
pub fn from_path (path: &impl AsRef<Path>, _watch: bool) -> Usually<Self> {
|
||||||
let mut config = Self::default();
|
let mut config = Self { path: path.as_ref().into(), ..Default::default() };
|
||||||
config.path = path.as_ref().into();
|
let mut dsl = read_and_leak(path.as_ref())?;
|
||||||
let mut dsl = read_and_leak(path.as_ref())?;
|
let mut head: Option<Arc<str>> = dsl.head()?.map(Into::into);
|
||||||
while let Some(mut exp) = dsl.exp_next()? {
|
let mut tail: Option<Arc<str>> = dsl.tail()?.map(Into::into);
|
||||||
match exp.exp_head()?.key()? {
|
loop {
|
||||||
Some("name") => match exp.text()? {
|
if let Some(exp) = head.exp()? {
|
||||||
Some(name) => config.name = Some(name.into()),
|
match exp.head()?.key()? {
|
||||||
_ => return Err(format!("missing name definition").into())
|
Some("name") => match exp.tail()?.text()? {
|
||||||
},
|
Some(name) => config.name = Some(name.into()),
|
||||||
Some("info") => match exp.text()? {
|
_ => return Err(format!("missing name definition").into())
|
||||||
Some(info) => config.info = Some(info.into()),
|
},
|
||||||
_ => return Err(format!("missing info definition").into())
|
Some("info") => match exp.tail()?.text()? {
|
||||||
},
|
Some(info) => config.info = Some(info.into()),
|
||||||
Some("keys") => match exp.text()? {
|
_ => return Err(format!("missing info definition").into())
|
||||||
Some(keys) => config.keys = EventMap::from_dsl(keys)?,
|
},
|
||||||
_ => return Err(format!("missing keys definition").into())
|
Some("keys") => match exp.tail()? {
|
||||||
},
|
Some(keys) => config.keys = EventMap::from_dsl(&mut &keys)?,
|
||||||
Some("view") => match exp.exp_tail()? {
|
_ => return Err(format!("missing keys definition").into())
|
||||||
Some(tail) => config.view = tail.src().into(),
|
},
|
||||||
_ => return Err(format!("missing view definition").into())
|
Some("view") => match exp.tail()? {
|
||||||
},
|
Some(tail) => config.view = tail.src().into(),
|
||||||
Some(k) => return Err(format!("(e3) unexpected key {k:?} in {exp:?}").into()),
|
_ => return Err(format!("missing view definition").into())
|
||||||
None => return Err(format!("(e2) unexpected exp {exp:?}").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()?.map(Into::into);
|
||||||
|
tail = next.tail()?.map(Into::into);
|
||||||
|
} else {
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(config)
|
Ok(config)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ impl<T: Content<TuiOut>> Content<TuiOut> for ErrorBoundary<TuiOut, T> {
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
pub fn view (model: &Self) -> impl Content<TuiOut> + '_ {
|
pub fn view (model: &Self) -> impl Content<TuiOut> + '_ {
|
||||||
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(Take::take(model, &mut model.config.view.clone()))
|
||||||
//ErrorBoundary::new(Give::give(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<TuiOut> + '_ {
|
pub fn view_nil (&self) -> impl Content<TuiOut> + '_ {
|
||||||
"nil"
|
"nil"
|
||||||
}
|
}
|
||||||
|
pub fn view_menu (&self) -> impl Content<TuiOut> + use<'_> {
|
||||||
|
Stack::south(|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||||
|
add(&Tui::bold(true, "tek"));
|
||||||
|
add(&"");
|
||||||
|
add(&"+ new session");
|
||||||
|
})
|
||||||
|
}
|
||||||
pub fn view_dialog (&self) -> impl Content<TuiOut> + use<'_> {
|
pub fn view_dialog (&self) -> impl Content<TuiOut> + use<'_> {
|
||||||
self.dialog.as_ref().map(|dialog|Bsp::b("",
|
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(
|
Fixed::xy(70, 23, Tui::fg_bg(Rgb(255,255,255), Rgb(16,16,16), Bsp::b(
|
||||||
|
|
|
||||||
2
deps/tengri
vendored
2
deps/tengri
vendored
|
|
@ -1 +1 @@
|
||||||
Subproject commit 360b404b69abb1ec4e0e9959667e08d4b99c6131
|
Subproject commit 85c305385bc08ef805afb113f677c510027a7234
|
||||||
Loading…
Add table
Add a link
Reference in a new issue