Skip to content

Commit

Permalink
pd
Browse files Browse the repository at this point in the history
  • Loading branch information
slotThe committed Dec 16, 2023
1 parent ab382e5 commit 6d2cb2a
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions XMonad/Prompt.hs
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ merely discarded, but passed to the respective application window.
handleMain :: KeyStroke -> Event -> XP ()
handleMain stroke@(keysym, keystr) = \case
KeyEvent{ev_event_type = t, ev_state = m} -> do
trace (show stroke)
(prevCompKey, (compKey, modeKey)) <- gets $
(prevCompletionKey &&& completionKey &&& changeModeKey) . config
keymask <- gets cleanMask <*> pure m
Expand All @@ -708,25 +709,30 @@ 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
trace (show (isJust mbAction))
unless (isModifier stroke && isNothing mbAction) $ do
trace "we 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 -> do
trace "running 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

0 comments on commit 6d2cb2a

Please sign in to comment.