mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-08-28 04:46:58 +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, ()> {
|
pub fn modes_add <'a> (modes: &Modes, expr: &'a str) -> UsuallyRef<'a, ()> {
|
||||||
let name = expr.head()?.ok_or("mode: missing name")?;
|
let name = expr.head()?.ok_or("mode: missing name")?;
|
||||||
let body = expr.tail()?.ok_or("mode: missing body")?;
|
let body = expr.tail()?.ok_or("mode: missing body")?;
|
||||||
modes.0.write().unwrap().insert(
|
let mode = Mode::default();
|
||||||
name.into(),
|
let mode = body.each(mode, move|mut submode: Mode, item: &str|{
|
||||||
Arc::new(body.each(
|
mode_add(&mut submode, &item);
|
||||||
Mode::default(),
|
Ok(submode)
|
||||||
move|mut mode: Mode, item: &str|{
|
})?;
|
||||||
mode_add(&mut mode, item)?;
|
modes.0.write().unwrap().insert(name.into(), Arc::new(mode));
|
||||||
Ok(mode)
|
|
||||||
}
|
|
||||||
)?));
|
|
||||||
Ok(())
|
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("");
|
let tail = expr.tail()?.map(|x|x.trim()).unwrap_or("");
|
||||||
match head {
|
match head {
|
||||||
"mode" => {
|
"mode" => {
|
||||||
let head = tail.head()?.ok_or("mode: missing name")?;
|
let name = tail.head()?.ok_or("submode: missing name")?;
|
||||||
let body = tail.tail()?.ok_or("mode: missing body")?;
|
let body = tail.tail()?.ok_or("submode: missing body")?;
|
||||||
let modes = mode.modes.clone();
|
|
||||||
let submode = Mode::default();
|
let submode = Mode::default();
|
||||||
let submode = body.each(submode, move|mut submode: Mode, item: &str|{
|
let submode = body.each(submode, move|mut submode: Mode, item: &str|{
|
||||||
mode_add(&mut submode, &item);
|
mode_add(&mut submode, &item);
|
||||||
Ok(submode)
|
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
|
mode
|
||||||
},
|
},
|
||||||
"keys" => {
|
"keys" => {
|
||||||
|
|
@ -119,7 +116,7 @@ pub fn load_view <'a> (views: &Views, expr: &'a str,) -> UsuallyRef<'a, ()> {
|
||||||
Ok(())
|
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 name = expr.head()?.ok_or("bind: missing name")?;
|
||||||
let body = expr.tail()?.ok_or("bind: missing body")?;
|
let body = expr.tail()?.ok_or("bind: missing body")?;
|
||||||
binds.write().unwrap().insert(name.into(), {
|
binds.write().unwrap().insert(name.into(), {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue