From 81ca0f17b593c755c986e9dedf39c242bece0b67 Mon Sep 17 00:00:00 2001 From: Anders Engstrom Date: Sun, 18 Jan 2009 16:29:33 +0100 Subject: submapDefault Ignore-this: c8958d47eb584a7de04a81eb087f05d1 Add support for a default action to take when the entered key does not match any entry. darcs-hash:20090118152933-8978f-3d45f6e5605f9d50a3c45814e6ef0337c0e5432f.gz --- XMonad/Actions/Submap.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'XMonad/Actions/Submap.hs') diff --git a/XMonad/Actions/Submap.hs b/XMonad/Actions/Submap.hs index b9bd219..8e26721 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) -- cgit v1.2.3