mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
X.H.Modal: Remove Keys
type alias
This was only used in three places throughout the module and is sort of non-standard terminology, hence it might confuse users. Talking about functions of type XConfig Layout -> M.Map (ButtonMask, KeySym) (X ()) is relatively standard in other modules as well, so it's probably best to remove the type alias for it.
This commit is contained in:
parent
865c63a361
commit
4734551c76
@ -117,7 +117,7 @@ import XMonad.Util.Parser ( runParser )
|
|||||||
--
|
--
|
||||||
-- - @[(String, X ())]@, or
|
-- - @[(String, X ())]@, or
|
||||||
--
|
--
|
||||||
-- - @XConfig Layout -> M.Map (ButtonMask, KeySym) (X ())@).
|
-- - @XConfig Layout -> M.Map (ButtonMask, KeySym) (X ())@.
|
||||||
--
|
--
|
||||||
-- The former—accessible via 'mkKeysEz'—is how specifying keys work with
|
-- The former—accessible via 'mkKeysEz'—is how specifying keys work with
|
||||||
-- "XMonad.Util.EZConfig", while the latter is more geared towards how
|
-- "XMonad.Util.EZConfig", while the latter is more geared towards how
|
||||||
@ -135,21 +135,17 @@ import XMonad.Util.Parser ( runParser )
|
|||||||
|
|
||||||
-- --< Types >-- {{{
|
-- --< Types >-- {{{
|
||||||
|
|
||||||
-- | Internally, we represent keys as the usual function type:
|
|
||||||
-- @XConfig Layout -> M.Map (ButtonMask, KeySym) (X ())@.
|
|
||||||
type Keys = XConfig Layout -> M.Map (ButtonMask, KeySym) (X ())
|
|
||||||
|
|
||||||
-- | From a list of 'XMonad.Util.EZConfig'-style bindings, generate a
|
-- | From a list of 'XMonad.Util.EZConfig'-style bindings, generate a
|
||||||
-- key representation.
|
-- key representation.
|
||||||
--
|
--
|
||||||
-- >>> mkKeysEz [("h", xmessage "Hello, world!")]
|
-- >>> mkKeysEz [("h", xmessage "Hello, world!")]
|
||||||
mkKeysEz :: [(String, X ())] -> Keys
|
mkKeysEz :: [(String, X ())] -> (XConfig Layout -> M.Map (ButtonMask, KeySym) (X ()))
|
||||||
mkKeysEz = flip mkKeymap
|
mkKeysEz = flip mkKeymap
|
||||||
|
|
||||||
-- | The mode type. Use 'mode' or 'modeWithExit' to create modes.
|
-- | The mode type. Use 'mode' or 'modeWithExit' to create modes.
|
||||||
data Mode = Mode
|
data Mode = Mode
|
||||||
{ label :: !String
|
{ label :: !String
|
||||||
, boundKeys :: !Keys
|
, boundKeys :: !(XConfig Layout -> M.Map (ButtonMask, KeySym) (X ()))
|
||||||
}
|
}
|
||||||
|
|
||||||
-- | Newtype for the extensible config.
|
-- | Newtype for the extensible config.
|
||||||
@ -213,14 +209,14 @@ modal modes = XC.once
|
|||||||
|
|
||||||
-- | Create a 'Mode' from the given binding to 'exitMode', label and
|
-- | Create a 'Mode' from the given binding to 'exitMode', label and
|
||||||
-- keybindings.
|
-- keybindings.
|
||||||
modeWithExit :: String -> String -> Keys -> Mode
|
modeWithExit :: String -> String -> (XConfig Layout -> M.Map (KeyMask, KeySym) (X ())) -> Mode
|
||||||
modeWithExit exitKey mlabel keys = Mode mlabel $ \cnf ->
|
modeWithExit exitKey mlabel keys = Mode mlabel $ \cnf ->
|
||||||
let exit = fromMaybe (0, xK_Escape) $ runParser (parseKeyCombo cnf) exitKey
|
let exit = fromMaybe (0, xK_Escape) $ runParser (parseKeyCombo cnf) exitKey
|
||||||
in M.insert exit exitMode (keys cnf)
|
in M.insert exit exitMode (keys cnf)
|
||||||
|
|
||||||
-- | Create a 'Mode' from the given label and keybindings. Sets the
|
-- | Create a 'Mode' from the given label and keybindings. Sets the
|
||||||
-- @escape@ key to 'exitMode'.
|
-- @escape@ key to 'exitMode'.
|
||||||
mode :: String -> Keys -> Mode
|
mode :: String -> (XConfig Layout -> M.Map (KeyMask, KeySym) (X ())) -> Mode
|
||||||
mode = modeWithExit "<Escape>"
|
mode = modeWithExit "<Escape>"
|
||||||
|
|
||||||
-- | Set the current 'Mode' based on its label.
|
-- | Set the current 'Mode' based on its label.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user