mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
Redefined ComplCaseSensitivity
as a proper sum type. (#509)
This commit is contained in:
parent
336afc82ca
commit
f49e7d653a
@ -491,6 +491,8 @@
|
|||||||
- Added `maxComplColumns` field to `XPConfig`, to limit the number of
|
- Added `maxComplColumns` field to `XPConfig`, to limit the number of
|
||||||
columns in the completion window.
|
columns in the completion window.
|
||||||
|
|
||||||
|
- Redefine `ComplCaseSensitivity` to a proper sum type as opposed to a newtype wrapped around Bool.
|
||||||
|
|
||||||
* `XMonad.Actions.TreeSelect`
|
* `XMonad.Actions.TreeSelect`
|
||||||
|
|
||||||
- Fixed a crash when focusing a new window while the tree select
|
- Fixed a crash when focusing a new window while the tree select
|
||||||
|
@ -62,7 +62,7 @@ import XMonad.StackSet ( tag, currentTag )
|
|||||||
-- If you prefer a prompt with case-insensitive completion:
|
-- If you prefer a prompt with case-insensitive completion:
|
||||||
--
|
--
|
||||||
-- > , ((modm .|. shiftMask, xK_x ),
|
-- > , ((modm .|. shiftMask, xK_x ),
|
||||||
-- changeDir def {complCaseSensitivity = ComplCaseSensitive False})
|
-- changeDir def {complCaseSensitivity = CaseInSensitive})
|
||||||
--
|
--
|
||||||
-- For detailed instruction on editing the key binding see:
|
-- For detailed instruction on editing the key binding see:
|
||||||
--
|
--
|
||||||
|
@ -208,7 +208,7 @@ type ComplFunction = String -> IO [String]
|
|||||||
type XPMode = XPType
|
type XPMode = XPType
|
||||||
data XPOperationMode = XPSingleMode ComplFunction XPType | XPMultipleModes (W.Stack XPType)
|
data XPOperationMode = XPSingleMode ComplFunction XPType | XPMultipleModes (W.Stack XPType)
|
||||||
|
|
||||||
newtype ComplCaseSensitivity = ComplCaseSensitive Bool
|
data ComplCaseSensitivity = CaseSensitive | CaseInSensitive
|
||||||
|
|
||||||
instance Show XPType where
|
instance Show XPType where
|
||||||
show (XPT p) = showXPrompt p
|
show (XPT p) = showXPrompt p
|
||||||
@ -341,7 +341,7 @@ instance Default XPConfig where
|
|||||||
, defaultText = []
|
, defaultText = []
|
||||||
, autoComplete = Nothing
|
, autoComplete = Nothing
|
||||||
, showCompletionOnTab = False
|
, showCompletionOnTab = False
|
||||||
, complCaseSensitivity = ComplCaseSensitive True
|
, complCaseSensitivity = CaseSensitive
|
||||||
, searchPredicate = isPrefixOf
|
, searchPredicate = isPrefixOf
|
||||||
, alwaysHighlight = False
|
, alwaysHighlight = False
|
||||||
, defaultPrompter = id
|
, defaultPrompter = id
|
||||||
|
@ -47,7 +47,7 @@ directoryPrompt c prom f = mkXPrompt (Dir prom csn f) c (getDirCompl csn) f
|
|||||||
directoryMultipleModes :: String -- ^ Prompt.
|
directoryMultipleModes :: String -- ^ Prompt.
|
||||||
-> (String -> X ()) -- ^ Action.
|
-> (String -> X ()) -- ^ Action.
|
||||||
-> XPType
|
-> XPType
|
||||||
directoryMultipleModes = directoryMultipleModes' (ComplCaseSensitive True)
|
directoryMultipleModes = directoryMultipleModes' CaseSensitive
|
||||||
|
|
||||||
-- | Like @directoryMultipleModes@ with a parameter for completion case-sensitivity.
|
-- | Like @directoryMultipleModes@ with a parameter for completion case-sensitivity.
|
||||||
directoryMultipleModes' :: ComplCaseSensitivity -- ^ Completion case sensitivity.
|
directoryMultipleModes' :: ComplCaseSensitivity -- ^ Completion case sensitivity.
|
||||||
|
@ -98,7 +98,7 @@ unsafePrompt c config = mkXPrompt Shell config (getShellCompl [c] $ searchPredic
|
|||||||
where run a = unsafeSpawn $ c ++ " " ++ a
|
where run a = unsafeSpawn $ c ++ " " ++ a
|
||||||
|
|
||||||
getShellCompl :: [String] -> Predicate -> String -> IO [String]
|
getShellCompl :: [String] -> Predicate -> String -> IO [String]
|
||||||
getShellCompl = getShellCompl' (ComplCaseSensitive True)
|
getShellCompl = getShellCompl' CaseSensitive
|
||||||
|
|
||||||
getShellCompl' :: ComplCaseSensitivity -> [String] -> Predicate -> String -> IO [String]
|
getShellCompl' :: ComplCaseSensitivity -> [String] -> Predicate -> String -> IO [String]
|
||||||
getShellCompl' csn cmds p s | s == "" || last s == ' ' = return []
|
getShellCompl' csn cmds p s | s == "" || last s == ' ' = return []
|
||||||
@ -128,8 +128,10 @@ compgen csn actionOpt s = runProcessWithInput "bash" [] $
|
|||||||
complCaseSensitivityCmd csn ++ " ; " ++ compgenCmd actionOpt s
|
complCaseSensitivityCmd csn ++ " ; " ++ compgenCmd actionOpt s
|
||||||
|
|
||||||
complCaseSensitivityCmd :: ComplCaseSensitivity -> String
|
complCaseSensitivityCmd :: ComplCaseSensitivity -> String
|
||||||
complCaseSensitivityCmd (ComplCaseSensitive b) =
|
complCaseSensitivityCmd CaseSensitive =
|
||||||
"bind 'set completion-ignore-case " ++ (if b then "off" else "on") ++ "'"
|
"bind 'set completion-ignore-case off'"
|
||||||
|
complCaseSensitivityCmd CaseInSensitive =
|
||||||
|
"bind 'set completion-ignore-case on'"
|
||||||
|
|
||||||
compgenCmd :: String -> String -> String
|
compgenCmd :: String -> String -> String
|
||||||
compgenCmd actionOpt s = "compgen -A " ++ actionOpt ++ " -- " ++ s ++ "\n"
|
compgenCmd actionOpt s = "compgen -A " ++ actionOpt ++ " -- " ++ s ++ "\n"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user