diff options
author | Joachim Breitner <mail@joachim-breitner.de> | 2008-09-08 12:57:58 +0200 |
---|---|---|
committer | Joachim Breitner <mail@joachim-breitner.de> | 2008-09-08 12:57:58 +0200 |
commit | 1cd0ebdaca3088943f844b31f31f54ea8788aff5 (patch) | |
tree | cf5cb9efc50ae5c9f6a57d715c8433b39c80a213 /XMonad | |
parent | b7018a531333501e4b55dcb520e95ccf5eae6488 (diff) | |
download | XMonadContrib-1cd0ebdaca3088943f844b31f31f54ea8788aff5.tar.gz XMonadContrib-1cd0ebdaca3088943f844b31f31f54ea8788aff5.tar.xz XMonadContrib-1cd0ebdaca3088943f844b31f31f54ea8788aff5.zip |
XPrompt: Add showCompletionOnTab option
This patch partially implements
http://code.google.com/p/xmonad/issues/detail?id!5
It adds a XPConfig option that, if enabled, hides the completion window
until the user presses Tab once. Default behaviour is preserved.
TODO: If Tab causes a unique completion, continue to hide the completion
window.
darcs-hash:20080908105758-23c07-0d014c22f15e853d2a918d53788274374eaf4dca.gz
Diffstat (limited to '')
-rw-r--r-- | XMonad/Prompt.hs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/XMonad/Prompt.hs b/XMonad/Prompt.hs index 7e3254b..53c9024 100644 --- a/XMonad/Prompt.hs +++ b/XMonad/Prompt.hs @@ -83,6 +83,7 @@ data XPState = , complWin :: Maybe Window , complWinDim :: Maybe ComplWindowDim , completionFunction :: String -> IO [String] + , showComplWin :: Bool , gcon :: !GC , fontS :: !XMonadFont , xptype :: !XPType @@ -105,6 +106,7 @@ data XPConfig = , historySize :: !Int -- ^ The number of history entries to be saved , defaultText :: String -- ^ The text by default in the prompt line , autoComplete :: Maybe Int -- ^ Just x: if only one completion remains, auto-select it, + , showCompletionOnTab :: Bool -- ^ Only show list of completions when Tab was pressed -- and delay by x microseconds } deriving (Show, Read) @@ -175,6 +177,7 @@ defaultXPConfig = , historySize = 256 , defaultText = [] , autoComplete = Nothing + , showCompletionOnTab = False } type ComplFunction = String -> IO [String] @@ -189,6 +192,7 @@ initState d rw w s compl gc fonts pt h c = , complWin = Nothing , complWinDim = Nothing , completionFunction = compl + , showComplWin = not (showCompletionOnTab c) , gcon = gc , fontS = fonts , xptype = XPT pt @@ -276,6 +280,7 @@ eventLoop action = do handle :: KeyStroke -> Event -> XP () handle k@(ks,_) e@(KeyEvent {ev_event_type = t}) | t == keyPress && ks == xK_Tab = do + modify $ \s -> s { showComplWin = True } c <- getCompletions completionHandle c k e handle ks (KeyEvent {ev_event_type = t, ev_state = m}) @@ -636,7 +641,7 @@ redrawComplWin compl = do let recreate = do destroyComplWin w <- createComplWin nwi drawComplWin w compl - if (compl /= [] ) + if (compl /= [] && showComplWin st) then case complWin st of Just w -> case complWinDim st of Just wi -> if nwi == wi -- complWinDim did not change @@ -816,4 +821,4 @@ historyCompletion = \x -> liftM (filter $ isInfixOf x) readHistoryIO -- 'getHistory' is uselessly of the type "XP [String]". readHistoryIO :: IO [String] readHistoryIO = do (hist,_) <- readHistory - return $ map command_history hist
\ No newline at end of file + return $ map command_history hist |