From b39dfa1917746972210f7f56a3a68bb5db132c26 Mon Sep 17 00:00:00 2001 From: Anders Engstrom Date: Sun, 18 Jan 2009 15:29:33 +0000 Subject: [PATCH] submapDefault Add support for a default action to take when the entered key does not match any entry. --- XMonad/Actions/Submap.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/XMonad/Actions/Submap.hs b/XMonad/Actions/Submap.hs index b9bd219a..8e267210 100644 --- a/XMonad/Actions/Submap.hs +++ b/XMonad/Actions/Submap.hs @@ -15,7 +15,8 @@ module XMonad.Actions.Submap ( -- * Usage -- $usage - submap + submap, + submapDefault ) where import XMonad hiding (keys) @@ -57,7 +58,11 @@ For detailed instructions on editing your key bindings, see -- corresponding action, or does nothing if the key is not found in -- the map. submap :: M.Map (KeyMask, KeySym) (X ()) -> X () -submap keys = do +submap keys = submapDefault (return ()) keys + +-- | Like 'submap', but executes a default action if the key did not match. +submapDefault :: X () -> M.Map (KeyMask, KeySym) (X ()) -> X () +submapDefault def keys = do XConf { theRoot = root, display = d } <- ask io $ grabKeyboard d root False grabModeAsync grabModeAsync currentTime @@ -73,4 +78,4 @@ submap keys = do io $ ungrabKeyboard d currentTime m' <- cleanMask m - whenJust (M.lookup (m', s) keys) id + maybe def id (M.lookup (m', s) keys)