From 8cf96771dc99212620a7252bca0db340992be3f6 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 24 Sep 2018 15:22:21 +0200 Subject: run_key_action_for_mode(): Deactivate current mode using trigger Enable mode deactivation. If there is a current mode, deactivate it if the trigger pressed is the current mode's trigger. Return a BS `KeyActionResult` just to satisfy the return type requirements of the function. We should really clean this function up and eliminate this return value, but we can't until we move map action key simulator handling into Rust. --- src/cocoa_bridge.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/cocoa_bridge.rs b/src/cocoa_bridge.rs index 11dc1c9..5f6cee7 100644 --- a/src/cocoa_bridge.rs +++ b/src/cocoa_bridge.rs @@ -224,8 +224,15 @@ mode { let map = map_group.maps.get(trigger); let mode = map_group.modes.get(trigger); - if let Some(ref mut in_mode) = state.in_mode { - if let Some(mode) = map_group.modes.get(in_mode) { + if let Some(in_mode) = state.in_mode.clone() { + if let Some(mode) = map_group.modes.get(&in_mode) { + // Deactivate mode by pressing current mode trigger + if &in_mode[..] == trigger { + state.in_mode = None; + + return Some(KeyActionResult::new(ActionKind::Mode)) + } + if let Some(map) = mode.get(trigger) { return match map.kind { MapKind::Map => { -- cgit v1.2.3