diff options
author | Anders Engstrom <ankaan@gmail.com> | 2009-01-18 16:29:33 +0100 |
---|---|---|
committer | Anders Engstrom <ankaan@gmail.com> | 2009-01-18 16:29:33 +0100 |
commit | 81ca0f17b593c755c986e9dedf39c242bece0b67 (patch) | |
tree | f5aae9ce7f2d26c519fe49a432c14d67504253fb /XMonad | |
parent | 5ab6b11181fd48394f439b77646d3fedf868bc60 (diff) | |
download | XMonadContrib-81ca0f17b593c755c986e9dedf39c242bece0b67.tar.gz XMonadContrib-81ca0f17b593c755c986e9dedf39c242bece0b67.tar.xz XMonadContrib-81ca0f17b593c755c986e9dedf39c242bece0b67.zip |
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
Diffstat (limited to 'XMonad')
-rw-r--r-- | XMonad/Actions/Submap.hs | 11 |
1 files changed, 8 insertions, 3 deletions
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) |