menu works lol
Some checks are pending
/ build (push) Waiting to run

This commit is contained in:
🪞👃🪞 2025-08-24 01:44:18 +03:00
parent cfd19062fd
commit 559d2fc4a1
7 changed files with 125 additions and 72 deletions

View file

@ -124,33 +124,28 @@ impl Mode<Arc<str>> {
modes.write().unwrap().insert(name.as_ref().into(), Arc::new(mode));
Ok(())
}
pub fn load_one (&mut self, item: impl Dsl) -> Usually<()> {
Ok(if let Ok(Some(key)) = item.expr().head() {
pub fn load_one (&mut self, dsl: impl Dsl) -> Usually<()> {
Ok(if let Ok(Some(expr)) = dsl.expr() && let Ok(Some(key)) = expr.head() {
println!("Mode::load_one: {key} {:?}", expr.tail()?);
let tail = expr.tail()?.map(|x|x.trim()).unwrap_or("");
match key {
"name" => {
self.name.push(item.tail()?.map(|x|x.trim()).unwrap_or("").into())
},
"info" => {
self.info.push(item.tail()?.map(|x|x.trim()).unwrap_or("").into())
},
"keys" => {
item.tail()?.each(|item|{
self.keys.push(item.trim().into());
Ok(())
})?;
},
"self" => if let Some(id) = item.tail()?.head()? {
Self::load_into(&self.modes, &id, &item.tail().tail())?;
"name" => self.name.push(tail.into()),
"info" => self.info.push(tail.into()),
"view" => self.view.push(tail.into()),
"keys" => tail.each(|expr|{self.keys.push(expr.trim().into()); Ok(())})?,
"mode" => if let Some(id) = tail.head()? {
Self::load_into(&self.modes, &id, &tail.tail())?;
} else {
return Err(format!("Mode::load_one: self: incomplete: {item:?}").into());
return Err(format!("Mode::load_one: self: incomplete: {expr:?}").into());
},
_ => {
return Err(format!("Mode::load_one: unexpected expr: {key:?} {tail:?}").into())
},
_ if let Some(src) = item.src()? => self.view.push(src.into()),
_ => {},
};
} else if let Ok(Some(word)) = item.word() {
} else if let Ok(Some(word)) = dsl.word() {
self.view.push(word.into());
} else {
return Err(format!("Mode::load_one: unexpected: {item:?}").into());
return Err(format!("Mode::load_one: unexpected: {dsl:?}").into());
})
}
}