Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X.Prompt: Execute keypress when it has an action associated to it #850

Merged
merged 1 commit into from
Dec 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions XMonad/Prompt.hs
Original file line number Diff line number Diff line change
Expand Up @@ -708,25 +708,28 @@ handleMain stroke@(keysym, keystr) = \case
getCurrentCompletions >>= handleCompletionMain Next
| (keymask, keysym) == prevCompKey ->
getCurrentCompletions >>= handleCompletionMain Prev
| otherwise -> unless (isModifier stroke) $ do
setCurrentCompletions Nothing
if keysym == modeKey
then modify setNextMode >> updateWindows
else handleInput keymask
| otherwise -> do
keymap <- gets (promptKeymap . config)
let mbAction = M.lookup (keymask, keysym) keymap
-- Either run when we can insert a valid character, or the
-- pressed key has an action associated to it.
unless (isModifier stroke && isNothing mbAction) $ do
setCurrentCompletions Nothing
if keysym == modeKey
then modify setNextMode >> updateWindows
else handleInput keymask mbAction
event -> handleOther stroke event
where
-- Prompt input handler for the main loop.
handleInput :: KeyMask -> XP ()
handleInput keymask = do
keymap <- gets (promptKeymap . config)
case M.lookup (keymask,keysym) keymap of
Just action -> action >> updateWindows
Nothing -> when (keymask .&. controlMask == 0) $ do
insertString $ utf8Decode keystr
updateWindows
updateHighlightedCompl
complete <- tryAutoComplete
when complete acceptSelection
handleInput :: KeyMask -> Maybe (XP ()) -> XP ()
handleInput keymask = \case
Just action -> action >> updateWindows
Nothing -> when (keymask .&. controlMask == 0) $ do
insertString $ utf8Decode keystr
updateWindows
updateHighlightedCompl
complete <- tryAutoComplete
when complete acceptSelection

-- There are two options to store the completion list during the main loop:
-- * Use the State monad, with 'Nothing' as the initial state.
Expand Down