Add a search predicate option to XMonad.Prompt

This commit is contained in:
Mike Lundy 2009-12-21 02:54:08 +00:00
parent 05ed62a455
commit efbcf16cee
2 changed files with 8 additions and 4 deletions

View File

@ -138,7 +138,10 @@ data XPConfig =
, defaultText :: String -- ^ The text by default in the prompt line , defaultText :: String -- ^ The text by default in the prompt line
, autoComplete :: Maybe Int -- ^ Just x: if only one completion remains, auto-select it, , autoComplete :: Maybe Int -- ^ Just x: if only one completion remains, auto-select it,
, showCompletionOnTab :: Bool -- ^ Only show list of completions when Tab was pressed , showCompletionOnTab :: Bool -- ^ Only show list of completions when Tab was pressed
-- and delay by x microseconds -- and delay by x microseconds
, searchPredicate :: String -> String -> Bool
-- ^ Given the typed string and a possible
-- completion, is the completion valid?
} }
data XPType = forall p . XPrompt p => XPT p data XPType = forall p . XPrompt p => XPT p
@ -212,7 +215,9 @@ defaultXPConfig =
, historyFilter = id , historyFilter = id
, defaultText = [] , defaultText = []
, autoComplete = Nothing , autoComplete = Nothing
, showCompletionOnTab = False } , showCompletionOnTab = False
, searchPredicate = isPrefixOf
}
greenXPConfig = defaultXPConfig { fgColor = "green", bgColor = "black" } greenXPConfig = defaultXPConfig { fgColor = "green", bgColor = "black" }
amberXPConfig = defaultXPConfig { fgColor = "#ca8f2d", bgColor = "black", fgHLight = "#eaaf4c" } amberXPConfig = defaultXPConfig { fgColor = "#ca8f2d", bgColor = "black", fgHLight = "#eaaf4c" }

View File

@ -24,7 +24,6 @@ module XMonad.Prompt.Window
) where ) where
import qualified Data.Map as M import qualified Data.Map as M
import Data.List
import qualified XMonad.StackSet as W import qualified XMonad.StackSet as W
import XMonad import XMonad
@ -89,7 +88,7 @@ doPrompt t c = do
bringAction = winAction bringWindow bringAction = winAction bringWindow
bringCopyAction = winAction bringCopyWindow bringCopyAction = winAction bringCopyWindow
compList m s = return . filter (isPrefixOf s) . map fst . M.toList $ m compList m s = return . filter (searchPredicate c s) . map fst . M.toList $ m
-- | Brings a copy of the specified window into the current workspace. -- | Brings a copy of the specified window into the current workspace.