module XMonad.Util.CustomKeys (
customKeys
, customKeysFrom
) where
import XMonad
import XMonad.Prelude ((<&>))
import Control.Monad.Reader
import qualified Data.Map as M
customKeys :: (XConfig Layout -> [(KeyMask, KeySym)])
-> (XConfig Layout -> [((KeyMask, KeySym), X ())])
-> XConfig Layout -> M.Map (KeyMask, KeySym) (X ())
customKeys :: (XConfig Layout -> [(KeyMask, KeySym)])
-> (XConfig Layout -> [((KeyMask, KeySym), X ())])
-> XConfig Layout
-> Map (KeyMask, KeySym) (X ())
customKeys = XConfig (Choose Tall (Choose (Mirror Tall) Full))
-> (XConfig Layout -> [(KeyMask, KeySym)])
-> (XConfig Layout -> [((KeyMask, KeySym), X ())])
-> XConfig Layout
-> Map (KeyMask, KeySym) (X ())
forall (l :: * -> *).
XConfig l
-> (XConfig Layout -> [(KeyMask, KeySym)])
-> (XConfig Layout -> [((KeyMask, KeySym), X ())])
-> XConfig Layout
-> Map (KeyMask, KeySym) (X ())
customKeysFrom XConfig (Choose Tall (Choose (Mirror Tall) Full))
forall a. Default a => a
def
customKeysFrom :: XConfig l
-> (XConfig Layout -> [(KeyMask, KeySym)])
-> (XConfig Layout -> [((KeyMask, KeySym), X ())])
-> XConfig Layout -> M.Map (KeyMask, KeySym) (X ())
customKeysFrom :: XConfig l
-> (XConfig Layout -> [(KeyMask, KeySym)])
-> (XConfig Layout -> [((KeyMask, KeySym), X ())])
-> XConfig Layout
-> Map (KeyMask, KeySym) (X ())
customKeysFrom XConfig l
conf = (Reader (XConfig Layout) (Map (KeyMask, KeySym) (X ()))
-> XConfig Layout -> Map (KeyMask, KeySym) (X ())
forall r a. Reader r a -> r -> a
runReader (Reader (XConfig Layout) (Map (KeyMask, KeySym) (X ()))
-> XConfig Layout -> Map (KeyMask, KeySym) (X ()))
-> ((XConfig Layout -> [((KeyMask, KeySym), X ())])
-> Reader (XConfig Layout) (Map (KeyMask, KeySym) (X ())))
-> (XConfig Layout -> [((KeyMask, KeySym), X ())])
-> XConfig Layout
-> Map (KeyMask, KeySym) (X ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) (((XConfig Layout -> [((KeyMask, KeySym), X ())])
-> Reader (XConfig Layout) (Map (KeyMask, KeySym) (X ())))
-> (XConfig Layout -> [((KeyMask, KeySym), X ())])
-> XConfig Layout
-> Map (KeyMask, KeySym) (X ()))
-> ((XConfig Layout -> [(KeyMask, KeySym)])
-> (XConfig Layout -> [((KeyMask, KeySym), X ())])
-> Reader (XConfig Layout) (Map (KeyMask, KeySym) (X ())))
-> (XConfig Layout -> [(KeyMask, KeySym)])
-> (XConfig Layout -> [((KeyMask, KeySym), X ())])
-> XConfig Layout
-> Map (KeyMask, KeySym) (X ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XConfig l
-> (XConfig Layout -> [(KeyMask, KeySym)])
-> (XConfig Layout -> [((KeyMask, KeySym), X ())])
-> Reader (XConfig Layout) (Map (KeyMask, KeySym) (X ()))
forall (l :: * -> *).
XConfig l
-> (XConfig Layout -> [(KeyMask, KeySym)])
-> (XConfig Layout -> [((KeyMask, KeySym), X ())])
-> Reader (XConfig Layout) (Map (KeyMask, KeySym) (X ()))
customize XConfig l
conf
customize :: XConfig l
-> (XConfig Layout -> [(KeyMask, KeySym)])
-> (XConfig Layout -> [((KeyMask, KeySym), X ())])
-> Reader (XConfig Layout) (M.Map (KeyMask, KeySym) (X ()))
customize :: XConfig l
-> (XConfig Layout -> [(KeyMask, KeySym)])
-> (XConfig Layout -> [((KeyMask, KeySym), X ())])
-> Reader (XConfig Layout) (Map (KeyMask, KeySym) (X ()))
customize XConfig l
conf XConfig Layout -> [(KeyMask, KeySym)]
ds XConfig Layout -> [((KeyMask, KeySym), X ())]
is = (XConfig Layout -> Map (KeyMask, KeySym) (X ()))
-> Reader (XConfig Layout) (Map (KeyMask, KeySym) (X ()))
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks (XConfig l -> XConfig Layout -> Map (KeyMask, KeySym) (X ())
forall (l :: * -> *).
XConfig l -> XConfig Layout -> Map (KeyMask, KeySym) (X ())
keys XConfig l
conf) Reader (XConfig Layout) (Map (KeyMask, KeySym) (X ()))
-> (Map (KeyMask, KeySym) (X ())
-> Reader (XConfig Layout) (Map (KeyMask, KeySym) (X ())))
-> Reader (XConfig Layout) (Map (KeyMask, KeySym) (X ()))
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (XConfig Layout -> [(KeyMask, KeySym)])
-> Map (KeyMask, KeySym) (X ())
-> Reader (XConfig Layout) (Map (KeyMask, KeySym) (X ()))
forall r (m :: * -> *) a b.
(MonadReader r m, Ord a) =>
(r -> [a]) -> Map a b -> m (Map a b)
delete XConfig Layout -> [(KeyMask, KeySym)]
ds Reader (XConfig Layout) (Map (KeyMask, KeySym) (X ()))
-> (Map (KeyMask, KeySym) (X ())
-> Reader (XConfig Layout) (Map (KeyMask, KeySym) (X ())))
-> Reader (XConfig Layout) (Map (KeyMask, KeySym) (X ()))
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (XConfig Layout -> [((KeyMask, KeySym), X ())])
-> Map (KeyMask, KeySym) (X ())
-> Reader (XConfig Layout) (Map (KeyMask, KeySym) (X ()))
forall r (m :: * -> *) a b.
(MonadReader r m, Ord a) =>
(r -> [(a, b)]) -> Map a b -> m (Map a b)
insert XConfig Layout -> [((KeyMask, KeySym), X ())]
is
delete :: (MonadReader r m, Ord a) => (r -> [a]) -> M.Map a b -> m (M.Map a b)
delete :: (r -> [a]) -> Map a b -> m (Map a b)
delete r -> [a]
dels Map a b
kmap = (r -> [a]) -> m [a]
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks r -> [a]
dels m [a] -> ([a] -> Map a b) -> m (Map a b)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (a -> Map a b -> Map a b) -> Map a b -> [a] -> Map a b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr a -> Map a b -> Map a b
forall k a. Ord k => k -> Map k a -> Map k a
M.delete Map a b
kmap
insert :: (MonadReader r m, Ord a) =>
(r -> [(a, b)]) -> M.Map a b -> m (M.Map a b)
insert :: (r -> [(a, b)]) -> Map a b -> m (Map a b)
insert r -> [(a, b)]
ins Map a b
kmap = (r -> [(a, b)]) -> m [(a, b)]
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks r -> [(a, b)]
ins m [(a, b)] -> ([(a, b)] -> Map a b) -> m (Map a b)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> ((a, b) -> Map a b -> Map a b) -> Map a b -> [(a, b)] -> Map a b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr ((a -> b -> Map a b -> Map a b) -> (a, b) -> Map a b -> Map a b
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry a -> b -> Map a b -> Map a b
forall k a. Ord k => k -> a -> Map k a -> Map k a
M.insert) Map a b
kmap