From 6d2cb2ad34cbdd279d94097497e86d1a0e7dc7e3 Mon Sep 17 00:00:00 2001 From: Tony Zorman Date: Sat, 16 Dec 2023 14:42:30 +0100 Subject: [PATCH] pd --- XMonad/Prompt.hs | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/XMonad/Prompt.hs b/XMonad/Prompt.hs index 2397ace70f..32fa0ac59c 100644 --- a/XMonad/Prompt.hs +++ b/XMonad/Prompt.hs @@ -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 @@ -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.