aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTeddy Wing2018-09-30 17:01:34 +0200
committerTeddy Wing2018-09-30 17:01:34 +0200
commit55432d2df2c3957b7bd022d163c9cec6b317376e (patch)
treeb78efa32b7c7abef1d7231355266144d83188ead /src
parentaebb4a485695fa1911a1e898e18943c02d22b143 (diff)
downloaddome-key-map-55432d2df2c3957b7bd022d163c9cec6b317376e.tar.bz2
Extract action normal character parsing to a function
Splits up the `action_map()` function and gives the parser a name.
Diffstat (limited to 'src')
-rw-r--r--src/parser.rs22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/parser.rs b/src/parser.rs
index 05d7dd1..d82cdaf 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -207,19 +207,27 @@ where
(
many(
choice!(
- satisfy(|c| c != '<')
- .map(|c|
- KeyboardKeyWithModifiers::new(
- KeyboardKey::Character(Character::new(c)),
- None,
- )
- ),
+ action_character(),
special_key()
)
),
).map(|(keys,)| Action::Map(keys))
}
+fn action_character<I>() -> impl Parser<Input = I, Output = KeyboardKeyWithModifiers>
+where
+ I: Stream<Item = char>,
+ I::Error: ParseError<I::Item, I::Range, I::Position>,
+{
+ satisfy(|c| c != '<')
+ .map(|c|
+ KeyboardKeyWithModifiers::new(
+ KeyboardKey::Character(Character::new(c)),
+ None,
+ )
+ )
+}
+
fn special_key<I>() -> impl Parser<Input = I, Output = KeyboardKeyWithModifiers>
where
I: Stream<Item = char>,