From ebbab5970303e2bc0c335c72fc04ad57ed8ffc16 Mon Sep 17 00:00:00 2001 From: Carlos Lopez-Camey Date: Sat, 21 Apr 2012 03:23:35 +0200 Subject: Adds an emacs-like Keymap in XMonad.Prompt Ignore-this: f281b8ad01f3d21055e2d6de79af2d79 darcs-hash:20120421012335-95218-fe138a3d499fd0d956f3c61037cc4a07211a9daf.gz --- XMonad/Prompt.hs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'XMonad/Prompt.hs') diff --git a/XMonad/Prompt.hs b/XMonad/Prompt.hs index d835b78..7679b95 100644 --- a/XMonad/Prompt.hs +++ b/XMonad/Prompt.hs @@ -20,6 +20,7 @@ module XMonad.Prompt , mkXPromptWithReturn , amberXPConfig , defaultXPConfig + , emacsLikeXPKeymap , greenXPConfig , XPType (..) , XPPosition (..) @@ -441,6 +442,42 @@ defaultXPKeymap = M.fromList $ , (xK_Escape, quit) ] +emacsLikeXPKeymap :: M.Map (KeyMask,KeySym) (XP ()) +emacsLikeXPKeymap = M.fromList $ + map (first $ (,) controlMask) -- control + + [ (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 + + [ (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) -- + [ (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 m (ks,str) = do km <- gets (promptKeymap . config) -- cgit v1.2.3