module XMonad.Prompt.Directory (
directoryPrompt,
directoryMultipleModes,
directoryMultipleModes',
Dir
) where
import XMonad.Prelude ( sort )
import XMonad
import XMonad.Prompt
import XMonad.Prompt.Shell ( compgenDirectories )
data Dir = Dir String ComplCaseSensitivity (String -> X ())
instance XPrompt Dir where
showXPrompt :: Dir -> String
showXPrompt (Dir String
x ComplCaseSensitivity
_ String -> X ()
_) = String
x
completionFunction :: Dir -> ComplFunction
completionFunction (Dir String
_ ComplCaseSensitivity
csn String -> X ()
_) = ComplCaseSensitivity -> ComplFunction
getDirCompl ComplCaseSensitivity
csn
modeAction :: Dir -> String -> String -> X ()
modeAction (Dir String
_ ComplCaseSensitivity
_ String -> X ()
f) String
buf String
auto =
let dir :: String
dir = if forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
auto then String
buf else String
auto
in String -> X ()
f String
dir
directoryPrompt :: XPConfig -> String -> (String -> X ()) -> X ()
directoryPrompt :: XPConfig -> String -> (String -> X ()) -> X ()
directoryPrompt XPConfig
c String
prom String -> X ()
f = forall p.
XPrompt p =>
p -> XPConfig -> ComplFunction -> (String -> X ()) -> X ()
mkXPrompt (String -> ComplCaseSensitivity -> (String -> X ()) -> Dir
Dir String
prom ComplCaseSensitivity
csn String -> X ()
f) XPConfig
c (ComplCaseSensitivity -> ComplFunction
getDirCompl ComplCaseSensitivity
csn) String -> X ()
f
where csn :: ComplCaseSensitivity
csn = XPConfig -> ComplCaseSensitivity
complCaseSensitivity XPConfig
c
directoryMultipleModes :: String
-> (String -> X ())
-> XPType
directoryMultipleModes :: String -> (String -> X ()) -> XPType
directoryMultipleModes = ComplCaseSensitivity -> String -> (String -> X ()) -> XPType
directoryMultipleModes' ComplCaseSensitivity
CaseSensitive
directoryMultipleModes' :: ComplCaseSensitivity
-> String
-> (String -> X ())
-> XPType
directoryMultipleModes' :: ComplCaseSensitivity -> String -> (String -> X ()) -> XPType
directoryMultipleModes' ComplCaseSensitivity
csn String
p String -> X ()
f = forall p. XPrompt p => p -> XPType
XPT (String -> ComplCaseSensitivity -> (String -> X ()) -> Dir
Dir String
p ComplCaseSensitivity
csn String -> X ()
f)
getDirCompl :: ComplCaseSensitivity -> String -> IO [String]
getDirCompl :: ComplCaseSensitivity -> ComplFunction
getDirCompl ComplCaseSensitivity
csn String
s = forall a. Ord a => [a] -> [a]
sort forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> Bool) -> [a] -> [a]
filter String -> Bool
notboring forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> [String]
lines forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ComplCaseSensitivity -> String -> IO String
compgenDirectories ComplCaseSensitivity
csn String
s
notboring :: String -> Bool
notboring :: String -> Bool
notboring (Char
'.':Char
'.':String
_) = Bool
True
notboring (Char
'.':String
_) = Bool
False
notboring String
_ = Bool
True