Correctly check completionKey field in XMonad.Prompt

This commit is contained in:
Daniel Schoepe
2009-09-28 09:32:15 +00:00
parent bc00f63b79
commit 2bebf54795

View File

@@ -353,22 +353,23 @@ handle _ _ = return ()
-- completion event handler -- completion event handler
completionHandle :: [String] -> KeyStroke -> Event -> XP () completionHandle :: [String] -> KeyStroke -> Event -> XP ()
completionHandle c (ks,_) (KeyEvent {ev_event_type = t}) completionHandle c ks@(sym,_) (KeyEvent { ev_event_type = t, ev_state = m }) = do
| t == keyPress && ks == xK_Tab = do complKey <- gets $ completionKey . config
st <- get case () of
let updateState l = do let new_command = nextCompletion (xptype st) (command st) l () | t == keyPress && sym == complKey ->
modify $ \s -> setCommand new_command $ s { offset = length new_command } do
updateWins l = do redrawWindows l st <- get
eventLoop (completionHandle l) let updateState l =
case c of let new_command = nextCompletion (xptype st) (command st) l
[] -> updateWindows >> eventLoop handle in modify $ \s -> setCommand new_command $ s { offset = length new_command }
[x] -> updateState [x] >> getCompletions >>= updateWins updateWins l = redrawWindows l >>
l -> updateState l >> updateWins l eventLoop (completionHandle l)
-- key release case c of
| t == keyRelease && ks == xK_Tab = eventLoop (completionHandle c) [] -> updateWindows >> eventLoop handle
-- other keys [x] -> updateState [x] >> getCompletions >>= updateWins
completionHandle _ ks (KeyEvent {ev_event_type = t, ev_state = m}) l -> updateState l >> updateWins l
| t == keyPress = keyPressHandle m ks | t == keyRelease && sym == complKey -> eventLoop (completionHandle c)
| otherwise -> keyPressHandle m ks -- some other key, handle it normally
-- some other event: go back to main loop -- some other event: go back to main loop
completionHandle _ k e = handle k e completionHandle _ k e = handle k e