aboutsummaryrefslogtreecommitdiffstats
path: root/src/parser.rs
diff options
context:
space:
mode:
authorTeddy Wing2018-10-03 16:17:18 +0200
committerTeddy Wing2018-10-03 16:17:18 +0200
commit0dad180d2f64e3260a1c71551dc4d8e6d027a171 (patch)
tree89002bfdd857015f54da37e691a082a4b87e79a1 /src/parser.rs
parent76100132d1d855bb3ecaf4fc73354e7414ef7c19 (diff)
downloaddome-key-map-0dad180d2f64e3260a1c71551dc4d8e6d027a171.tar.bz2
parse_actions(): Parse `Action::Map` for mode maps
Previously I had only implemented it for top-level maps. Get it working for in-mode maps too. Move the parsing code to a function so it can be re-used in both places.
Diffstat (limited to 'src/parser.rs')
-rw-r--r--src/parser.rs55
1 files changed, 30 insertions, 25 deletions
diff --git a/src/parser.rs b/src/parser.rs
index 72dd0bf..38c7ecd 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -163,34 +163,39 @@ impl MapGroup {
pub fn parse_actions(&mut self) {
for map_action in self.maps.values_mut() {
- match map_action.kind {
- MapKind::Map => {
- let action = match map_action.action {
- Action::String(ref s) => {
- let input = State::new(s.as_str());
-
- Some(
- action_map()
- .easy_parse(input)
- .map(|t| t.0)
- .unwrap()
- )
- },
- _ => None,
- };
- if let Some(action) = action {
- map_action.action = action;
- }
- },
- // TODO: Write when we have a command action parser
- MapKind::Command => {},
+ Self::parse_action(map_action);
+ }
+
+ for mode in self.modes.values_mut() {
+ for map_action in mode.values_mut() {
+ Self::parse_action(map_action);
}
}
+ }
- // for mode in self.modes.values() {
- // for map in mode.values_mut() {
- // }
- // }
+ fn parse_action(map_action: &mut MapAction) {
+ match map_action.kind {
+ MapKind::Map => {
+ let action = match map_action.action {
+ Action::String(ref s) => {
+ let input = State::new(s.as_str());
+
+ Some(
+ action_map()
+ .easy_parse(input)
+ .map(|t| t.0)
+ .unwrap()
+ )
+ },
+ _ => None,
+ };
+ if let Some(action) = action {
+ map_action.action = action;
+ }
+ },
+ // TODO: Write when we have a command action parser
+ MapKind::Command => {},
+ }
}
}