mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-21 23:13:48 -07:00
employ the prompt sorter for the window selector
as in https://markmail.org/thread/kgrybzqarqzqiige
This commit is contained in:
committed by
anthraxx
parent
02278e5bbb
commit
6b9fb096d6
@@ -34,6 +34,12 @@
|
|||||||
* `XMonad.Actions.MessageHandling`
|
* `XMonad.Actions.MessageHandling`
|
||||||
Refresh-performing functions updated to better reflect the new `sendMessage`.
|
Refresh-performing functions updated to better reflect the new `sendMessage`.
|
||||||
|
|
||||||
|
* `XMonad.Prompt`
|
||||||
|
|
||||||
|
Added `sorter` to `XPConfig` used to sort the possible completions by how
|
||||||
|
well they match the search string (example: `XMonad.Prompt.FuzzyMatch`).
|
||||||
|
|
||||||
|
|
||||||
## 0.14
|
## 0.14
|
||||||
|
|
||||||
### Breaking Changes
|
### Breaking Changes
|
||||||
|
@@ -156,6 +156,10 @@ data XPConfig =
|
|||||||
, searchPredicate :: String -> String -> Bool
|
, searchPredicate :: String -> String -> Bool
|
||||||
-- ^ Given the typed string and a possible
|
-- ^ Given the typed string and a possible
|
||||||
-- completion, is the completion valid?
|
-- completion, is the completion valid?
|
||||||
|
, sorter :: String -> [String] -> [String]
|
||||||
|
-- ^ Used to sort the possible completions by how well they
|
||||||
|
-- match the search string (see X.P.FuzzyMatch for an
|
||||||
|
-- example).
|
||||||
}
|
}
|
||||||
|
|
||||||
data XPType = forall p . XPrompt p => XPT p
|
data XPType = forall p . XPrompt p => XPT p
|
||||||
@@ -268,6 +272,7 @@ instance Default XPConfig where
|
|||||||
, showCompletionOnTab = False
|
, showCompletionOnTab = False
|
||||||
, searchPredicate = isPrefixOf
|
, searchPredicate = isPrefixOf
|
||||||
, alwaysHighlight = False
|
, alwaysHighlight = False
|
||||||
|
, sorter = const id
|
||||||
}
|
}
|
||||||
{-# DEPRECATED defaultXPConfig "Use def (from Data.Default, and re-exported from XMonad.Prompt) instead." #-}
|
{-# DEPRECATED defaultXPConfig "Use def (from Data.Default, and re-exported from XMonad.Prompt) instead." #-}
|
||||||
defaultXPConfig = def
|
defaultXPConfig = def
|
||||||
@@ -956,8 +961,10 @@ getCompletionFunction st = case operationMode st of
|
|||||||
getCompletions :: XP [String]
|
getCompletions :: XP [String]
|
||||||
getCompletions = do
|
getCompletions = do
|
||||||
s <- get
|
s <- get
|
||||||
io $ getCompletionFunction s (commandToComplete (currentXPMode s) (command s))
|
let q = commandToComplete (currentXPMode s) (command s)
|
||||||
`E.catch` \(SomeException _) -> return []
|
compl = getCompletionFunction s
|
||||||
|
srt = sorter (config s)
|
||||||
|
io $ (srt q <$> compl q) `E.catch` \(SomeException _) -> return []
|
||||||
|
|
||||||
setComplWin :: Window -> ComplWindowDim -> XP ()
|
setComplWin :: Window -> ComplWindowDim -> XP ()
|
||||||
setComplWin w wi =
|
setComplWin w wi =
|
||||||
|
Reference in New Issue
Block a user