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
completionHandle :: [String] -> KeyStroke -> Event -> XP ()
completionHandle c (ks,_) (KeyEvent {ev_event_type = t})
| t == keyPress && ks == xK_Tab = do
completionHandle c ks@(sym,_) (KeyEvent { ev_event_type = t, ev_state = m }) = do
complKey <- gets $ completionKey . config
case () of
() | t == keyPress && sym == complKey ->
do
st <- get
let updateState l = do let new_command = nextCompletion (xptype st) (command st) l
modify $ \s -> setCommand new_command $ s { offset = length new_command }
updateWins l = do redrawWindows l
let updateState l =
let new_command = nextCompletion (xptype st) (command st) l
in modify $ \s -> setCommand new_command $ s { offset = length new_command }
updateWins l = redrawWindows l >>
eventLoop (completionHandle l)
case c of
[] -> updateWindows >> eventLoop handle
[x] -> updateState [x] >> getCompletions >>= updateWins
l -> updateState l >> updateWins l
-- key release
| t == keyRelease && ks == xK_Tab = eventLoop (completionHandle c)
-- other keys
completionHandle _ ks (KeyEvent {ev_event_type = t, ev_state = m})
| 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
completionHandle _ k e = handle k e