diff options
| author | Teddy Wing | 2018-10-03 16:17:18 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2018-10-03 16:17:18 +0200 | 
| commit | 0dad180d2f64e3260a1c71551dc4d8e6d027a171 (patch) | |
| tree | 89002bfdd857015f54da37e691a082a4b87e79a1 /src | |
| parent | 76100132d1d855bb3ecaf4fc73354e7414ef7c19 (diff) | |
| download | dome-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')
| -rw-r--r-- | src/parser.rs | 55 | 
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 => {}, +        }      }  } | 
