mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-08-28 12:56:57 +02:00
parent
4fcbcdda86
commit
a126d98f3c
1 changed files with 11 additions and 14 deletions
|
|
@ -46,15 +46,12 @@ pub fn config_add <'a> (config: &'a Config, dsl: &'a str) -> UsuallyRef<'a, &'a
|
|||
pub fn modes_add <'a> (modes: &Modes, expr: &'a str) -> UsuallyRef<'a, ()> {
|
||||
let name = expr.head()?.ok_or("mode: missing name")?;
|
||||
let body = expr.tail()?.ok_or("mode: missing body")?;
|
||||
modes.0.write().unwrap().insert(
|
||||
name.into(),
|
||||
Arc::new(body.each(
|
||||
Mode::default(),
|
||||
move|mut mode: Mode, item: &str|{
|
||||
mode_add(&mut mode, item)?;
|
||||
Ok(mode)
|
||||
}
|
||||
)?));
|
||||
let mode = Mode::default();
|
||||
let mode = body.each(mode, move|mut submode: Mode, item: &str|{
|
||||
mode_add(&mut submode, &item);
|
||||
Ok(submode)
|
||||
})?;
|
||||
modes.0.write().unwrap().insert(name.into(), Arc::new(mode));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -78,15 +75,15 @@ pub fn mode_add <'a> (mode: &'a mut Mode, dsl: &'a str) -> PerhapsRef<'a, &'a mu
|
|||
let tail = expr.tail()?.map(|x|x.trim()).unwrap_or("");
|
||||
match head {
|
||||
"mode" => {
|
||||
let head = tail.head()?.ok_or("mode: missing name")?;
|
||||
let body = tail.tail()?.ok_or("mode: missing body")?;
|
||||
let modes = mode.modes.clone();
|
||||
let name = tail.head()?.ok_or("submode: missing name")?;
|
||||
let body = tail.tail()?.ok_or("submode: missing body")?;
|
||||
let submode = Mode::default();
|
||||
let submode = body.each(submode, move|mut submode: Mode, item: &str|{
|
||||
mode_add(&mut submode, &item);
|
||||
Ok(submode)
|
||||
})?;
|
||||
modes.0.write().unwrap().insert(head.into(), Arc::new(submode));
|
||||
let modes = mode.modes.clone();
|
||||
modes.0.write().unwrap().insert(name.into(), Arc::new(submode));
|
||||
mode
|
||||
},
|
||||
"keys" => {
|
||||
|
|
@ -119,7 +116,7 @@ pub fn load_view <'a> (views: &Views, expr: &'a str,) -> UsuallyRef<'a, ()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn load_bind <'a> (binds: &Binds, expr: &'a str) -> Usually<()> {
|
||||
pub fn load_bind <'a> (binds: &Binds, expr: &'a str) -> UsuallyRef<'a, ()> {
|
||||
let name = expr.head()?.ok_or("bind: missing name")?;
|
||||
let body = expr.tail()?.ok_or("bind: missing body")?;
|
||||
binds.write().unwrap().insert(name.into(), {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue