mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
X.Prompt: Factor out how to accept the current selection
This commit is contained in:
parent
635711e994
commit
fb63987ac8
@ -715,7 +715,7 @@ handleInputMain keymask (keysym,keystr) = do
|
|||||||
updateWindows
|
updateWindows
|
||||||
updateHighlightedCompl
|
updateHighlightedCompl
|
||||||
complete <- tryAutoComplete
|
complete <- tryAutoComplete
|
||||||
when complete $ setSuccess True >> setDone True
|
when complete acceptSelection
|
||||||
|
|
||||||
-- There are two options to store the completion list during the main loop:
|
-- There are two options to store the completion list during the main loop:
|
||||||
-- * Use the State monad, with 'Nothing' as the initial state.
|
-- * Use the State monad, with 'Nothing' as the initial state.
|
||||||
@ -968,8 +968,8 @@ defaultXPKeymap' p = M.fromList $
|
|||||||
, (xK_bracketleft, quit)
|
, (xK_bracketleft, quit)
|
||||||
] ++
|
] ++
|
||||||
map (first $ (,) 0)
|
map (first $ (,) 0)
|
||||||
[ (xK_Return, setSuccess True >> setDone True)
|
[ (xK_Return, acceptSelection)
|
||||||
, (xK_KP_Enter, setSuccess True >> setDone True)
|
, (xK_KP_Enter, acceptSelection)
|
||||||
, (xK_BackSpace, deleteString Prev)
|
, (xK_BackSpace, deleteString Prev)
|
||||||
, (xK_Delete, deleteString Next)
|
, (xK_Delete, deleteString Next)
|
||||||
, (xK_Left, moveCursor Prev)
|
, (xK_Left, moveCursor Prev)
|
||||||
@ -1021,8 +1021,8 @@ emacsLikeXPKeymap' p = M.fromList $
|
|||||||
]
|
]
|
||||||
++
|
++
|
||||||
map (first $ (,) 0) -- <key>
|
map (first $ (,) 0) -- <key>
|
||||||
[ (xK_Return, setSuccess True >> setDone True)
|
[ (xK_Return, acceptSelection)
|
||||||
, (xK_KP_Enter, setSuccess True >> setDone True)
|
, (xK_KP_Enter, acceptSelection)
|
||||||
, (xK_BackSpace, deleteString Prev)
|
, (xK_BackSpace, deleteString Prev)
|
||||||
, (xK_Delete, deleteString Next)
|
, (xK_Delete, deleteString Next)
|
||||||
, (xK_Left, moveCursor Prev)
|
, (xK_Left, moveCursor Prev)
|
||||||
@ -1059,8 +1059,8 @@ vimLikeXPKeymap' :: (XPColor -> XPColor)
|
|||||||
-> M.Map (KeyMask,KeySym) (XP ())
|
-> M.Map (KeyMask,KeySym) (XP ())
|
||||||
vimLikeXPKeymap' fromColor promptF pasteFilter notWord = M.fromList $
|
vimLikeXPKeymap' fromColor promptF pasteFilter notWord = M.fromList $
|
||||||
map (first $ (,) 0)
|
map (first $ (,) 0)
|
||||||
[ (xK_Return, setSuccess True >> setDone True)
|
[ (xK_Return, acceptSelection)
|
||||||
, (xK_KP_Enter, setSuccess True >> setDone True)
|
, (xK_KP_Enter, acceptSelection)
|
||||||
, (xK_BackSpace, deleteString Prev)
|
, (xK_BackSpace, deleteString Prev)
|
||||||
, (xK_Delete, deleteString Next)
|
, (xK_Delete, deleteString Next)
|
||||||
, (xK_Left, moveCursor Prev)
|
, (xK_Left, moveCursor Prev)
|
||||||
@ -1166,6 +1166,10 @@ setModeDone b = modify $ \s -> s { modeDone = b }
|
|||||||
|
|
||||||
-- KeyPress and State
|
-- KeyPress and State
|
||||||
|
|
||||||
|
-- | Accept the current selection and exit.
|
||||||
|
acceptSelection :: StateT XPState IO ()
|
||||||
|
acceptSelection = setSuccess True >> setDone True
|
||||||
|
|
||||||
-- | Quit.
|
-- | Quit.
|
||||||
quit :: XP ()
|
quit :: XP ()
|
||||||
quit = flushString >> setSuccess False >> setDone True >> setModeDone True
|
quit = flushString >> setSuccess False >> setDone True >> setModeDone True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user