mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-11 18:22:16 -07:00
Adds an emacs-like Keymap in XMonad.Prompt
This commit is contained in:
@@ -20,6 +20,7 @@ module XMonad.Prompt
|
|||||||
, mkXPromptWithReturn
|
, mkXPromptWithReturn
|
||||||
, amberXPConfig
|
, amberXPConfig
|
||||||
, defaultXPConfig
|
, defaultXPConfig
|
||||||
|
, emacsLikeXPKeymap
|
||||||
, greenXPConfig
|
, greenXPConfig
|
||||||
, XPType (..)
|
, XPType (..)
|
||||||
, XPPosition (..)
|
, XPPosition (..)
|
||||||
@@ -441,6 +442,42 @@ defaultXPKeymap = M.fromList $
|
|||||||
, (xK_Escape, quit)
|
, (xK_Escape, quit)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
emacsLikeXPKeymap :: M.Map (KeyMask,KeySym) (XP ())
|
||||||
|
emacsLikeXPKeymap = M.fromList $
|
||||||
|
map (first $ (,) controlMask) -- control + <key>
|
||||||
|
[ (xK_z, killBefore) --kill line backwards
|
||||||
|
, (xK_k, killAfter) -- kill line fowards
|
||||||
|
, (xK_a, startOfLine) --move to the beginning of the line
|
||||||
|
, (xK_e, endOfLine) -- move to the end of the line
|
||||||
|
, (xK_d, deleteString Next) -- delete a character foward
|
||||||
|
, (xK_b, moveCursor Prev) -- move cursor forward
|
||||||
|
, (xK_f, moveCursor Next) -- move cursor backward
|
||||||
|
, (xK_BackSpace, killWord Prev) -- kill the previous word
|
||||||
|
, (xK_y, pasteString)
|
||||||
|
, (xK_g, quit)
|
||||||
|
, (xK_bracketleft, quit)
|
||||||
|
] ++
|
||||||
|
map (first $ (,) mod1Mask) -- meta key + <key>
|
||||||
|
[ (xK_BackSpace, killWord Prev)
|
||||||
|
, (xK_f, moveWord Next) -- move a word forward
|
||||||
|
, (xK_b, moveWord Prev) -- move a word backward
|
||||||
|
, (xK_d, killWord Next) -- kill the next word
|
||||||
|
]
|
||||||
|
++
|
||||||
|
map (first $ (,) 0) -- <key>
|
||||||
|
[ (xK_Return, setSuccess True >> setDone True)
|
||||||
|
, (xK_KP_Enter, setSuccess True >> setDone True)
|
||||||
|
, (xK_BackSpace, deleteString Prev)
|
||||||
|
, (xK_Delete, deleteString Next)
|
||||||
|
, (xK_Left, moveCursor Prev)
|
||||||
|
, (xK_Right, moveCursor Next)
|
||||||
|
, (xK_Home, startOfLine)
|
||||||
|
, (xK_End, endOfLine)
|
||||||
|
, (xK_Down, moveHistory W.focusUp')
|
||||||
|
, (xK_Up, moveHistory W.focusDown')
|
||||||
|
, (xK_Escape, quit)
|
||||||
|
]
|
||||||
|
|
||||||
keyPressHandle :: KeyMask -> KeyStroke -> XP ()
|
keyPressHandle :: KeyMask -> KeyStroke -> XP ()
|
||||||
keyPressHandle m (ks,str) = do
|
keyPressHandle m (ks,str) = do
|
||||||
km <- gets (promptKeymap . config)
|
km <- gets (promptKeymap . config)
|
||||||
|
Reference in New Issue
Block a user