aboutsummaryrefslogtreecommitdiffstats
path: root/Submap.hs
diff options
context:
space:
mode:
authorSpencer Janssen <sjanssen@cse.unl.edu>2007-11-01 21:10:59 +0100
committerSpencer Janssen <sjanssen@cse.unl.edu>2007-11-01 21:10:59 +0100
commit4866f2e367dfcf22a9591231ba40948826a1b438 (patch)
tree7a245caee3f146826b267d773b7eaa80386a818e /Submap.hs
parent47589e1913fb9530481caedb543978a30d4323ea (diff)
downloadXMonadContrib-4866f2e367dfcf22a9591231ba40948826a1b438.tar.gz
XMonadContrib-4866f2e367dfcf22a9591231ba40948826a1b438.tar.xz
XMonadContrib-4866f2e367dfcf22a9591231ba40948826a1b438.zip
Hierarchify
darcs-hash:20071101201059-a5988-fc1f1262bec1b69e13ba18ae7cefeafc8c4471d4.gz
Diffstat (limited to 'Submap.hs')
-rw-r--r--Submap.hs71
1 files changed, 0 insertions, 71 deletions
diff --git a/Submap.hs b/Submap.hs
deleted file mode 100644
index a9a2749..0000000
--- a/Submap.hs
+++ /dev/null
@@ -1,71 +0,0 @@
------------------------------------------------------------------------------
--- |
--- Module : XMonadContrib.Submap
--- Copyright : (c) Jason Creighton <jcreigh@gmail.com>
--- License : BSD3-style (see LICENSE)
---
--- Maintainer : Jason Creighton <jcreigh@gmail.com>
--- Stability : unstable
--- Portability : unportable
---
--- A module that allows the user to create a sub-mapping of keys bindings.
---
------------------------------------------------------------------------------
-
-module XMonadContrib.Submap (
- -- * Usage
- -- $usage
- submap
- ) where
-
-import Control.Monad.Reader
-
-import XMonad
-import XMonad.Operations (cleanMask)
-import Graphics.X11.Xlib
-import Graphics.X11.Xlib.Extras
-import qualified Data.Map as M
-
-{- $usage
-Allows you to create a sub-mapping of keys. Example:
-
-> , ((modMask, xK_a), submap . M.fromList $
-> [ ((0, xK_n), spawn "mpc next")
-> , ((0, xK_p), spawn "mpc prev")
-> , ((0, xK_z), spawn "mpc random")
-> , ((0, xK_space), spawn "mpc toggle")
-> ])
-
-So, for example, to run 'spawn \"mpc next\"', you would hit mod-a (to trigger the
-submapping) and then 'n' to run that action. (0 means \"no modifier\"). You are,
-of course, free to use any combination of modifiers in the submapping. However,
-anyModifier will not work, because that is a special value passed to XGrabKey()
-and not an actual modifier.
--}
-
--- %import XMonadContrib.Submap
--- %keybind , ((modMask, xK_a), submap . M.fromList $
--- %keybind [ ((0, xK_n), spawn "mpc next")
--- %keybind , ((0, xK_p), spawn "mpc prev")
--- %keybind , ((0, xK_z), spawn "mpc random")
--- %keybind , ((0, xK_space), spawn "mpc toggle")
--- %keybind ])
-
-submap :: M.Map (KeyMask, KeySym) (X ()) -> X ()
-submap keys = do
- XConf { theRoot = root, display = d } <- ask
-
- io $ grabKeyboard d root False grabModeAsync grabModeAsync currentTime
-
- (m, s) <- io $ allocaXEvent $ \p -> fix $ \nextkey -> do
- maskEvent d keyPressMask p
- KeyEvent { ev_keycode = code, ev_state = m } <- getEvent p
- keysym <- keycodeToKeysym d code 0
- if isModifierKey keysym
- then nextkey
- else return (m, keysym)
-
- io $ ungrabKeyboard d currentTime
-
- m' <- cleanMask m
- whenJust (M.lookup (m', s) keys) id