mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-09 00:11:52 -07:00
Prompt: haddock fixes only
This commit is contained in:
@@ -19,8 +19,6 @@ module XMonad.Prompt
|
|||||||
mkXPrompt
|
mkXPrompt
|
||||||
, mkXPromptWithReturn
|
, mkXPromptWithReturn
|
||||||
, defaultXPConfig
|
, defaultXPConfig
|
||||||
, mkComplFunFromList
|
|
||||||
, mkComplFunFromList'
|
|
||||||
, XPType (..)
|
, XPType (..)
|
||||||
, XPPosition (..)
|
, XPPosition (..)
|
||||||
, XPConfig (..)
|
, XPConfig (..)
|
||||||
@@ -32,8 +30,12 @@ module XMonad.Prompt
|
|||||||
, fillDrawable
|
, fillDrawable
|
||||||
-- * Other Utilities
|
-- * Other Utilities
|
||||||
-- $utils
|
-- $utils
|
||||||
, getNextCompletion
|
, mkComplFunFromList
|
||||||
|
, mkComplFunFromList'
|
||||||
|
-- * @nextCompletion@ implementations
|
||||||
, getNextOfLastWord
|
, getNextOfLastWord
|
||||||
|
, getNextCompletion
|
||||||
|
-- * List utilities
|
||||||
, getLastWord
|
, getLastWord
|
||||||
, skipLastWord
|
, skipLastWord
|
||||||
, splitInSubListsAt
|
, splitInSubListsAt
|
||||||
@@ -134,15 +136,17 @@ class XPrompt t where
|
|||||||
nextCompletion t c l = getNextOfLastWord t c l
|
nextCompletion t c l = getNextOfLastWord t c l
|
||||||
|
|
||||||
-- | If the prompt is using 'getNextOfLastWord' for implementing
|
-- | If the prompt is using 'getNextOfLastWord' for implementing
|
||||||
-- 'nextCompletion' (the default implementation), this is used to
|
-- 'nextCompletion' (the default implementation), this method is
|
||||||
-- generate the string to be passed to the completion function.
|
-- used to generate the string to be passed to the completion
|
||||||
|
-- function.
|
||||||
commandToComplete :: t -> String -> String
|
commandToComplete :: t -> String -> String
|
||||||
commandToComplete _ c = getLastWord c
|
commandToComplete _ c = getLastWord c
|
||||||
|
|
||||||
-- | If the prompt is using 'getNextOfLastWord' for implementing
|
-- | If the prompt is using 'getNextOfLastWord' for implementing
|
||||||
-- 'nextCompletion' (the default implementation), this is used to
|
-- 'nextCompletion' (the default implementation), this method is
|
||||||
-- generate the string to compare each completion with the
|
-- used to process each completion in order to generate the string
|
||||||
-- command presently in the command line.
|
-- that will be compared with the command presently displayed in
|
||||||
|
-- the command line.
|
||||||
completionToCommand :: t -> String -> String
|
completionToCommand :: t -> String -> String
|
||||||
completionToCommand _ c = c
|
completionToCommand _ c = c
|
||||||
|
|
||||||
@@ -718,6 +722,25 @@ mkComplFunFromList' l [] = return l
|
|||||||
mkComplFunFromList' l s =
|
mkComplFunFromList' l s =
|
||||||
return $ filter (\x -> take (length s) x == s) l
|
return $ filter (\x -> take (length s) x == s) l
|
||||||
|
|
||||||
|
|
||||||
|
-- | Given the prompt type, the command line and the completion list,
|
||||||
|
-- return the next completion in the list for the last word of the
|
||||||
|
-- command line. This is the default 'nextCompletion' implementation.
|
||||||
|
getNextOfLastWord :: XPrompt t => t -> String -> [String] -> String
|
||||||
|
getNextOfLastWord t c l = skipLastWord c ++ completionToCommand t (l !! ni)
|
||||||
|
where ni = case commandToComplete t c `elemIndex` map (completionToCommand t) l of
|
||||||
|
Just i -> if i >= length l - 1 then 0 else i + 1
|
||||||
|
Nothing -> 0
|
||||||
|
|
||||||
|
-- | An alternative 'nextCompletion' implementation: given a command
|
||||||
|
-- and a completion list, get the next completion in the list matching
|
||||||
|
-- the whole command line.
|
||||||
|
getNextCompletion :: String -> [String] -> String
|
||||||
|
getNextCompletion c l = l !! idx
|
||||||
|
where idx = case c `elemIndex` l of
|
||||||
|
Just i -> if i >= length l - 1 then 0 else i + 1
|
||||||
|
Nothing -> 0
|
||||||
|
|
||||||
-- Lift an IO action into the XP
|
-- Lift an IO action into the XP
|
||||||
io :: IO a -> XP a
|
io :: IO a -> XP a
|
||||||
io = liftIO
|
io = liftIO
|
||||||
@@ -732,22 +755,6 @@ splitInSubListsAt _ [] = []
|
|||||||
splitInSubListsAt i x = f : splitInSubListsAt i rest
|
splitInSubListsAt i x = f : splitInSubListsAt i rest
|
||||||
where (f,rest) = splitAt i x
|
where (f,rest) = splitAt i x
|
||||||
|
|
||||||
-- | Given a command and a completion list, get the next completion in
|
|
||||||
-- the list.
|
|
||||||
getNextCompletion :: String -> [String] -> String
|
|
||||||
getNextCompletion c l = l !! idx
|
|
||||||
where idx = case c `elemIndex` l of
|
|
||||||
Just i -> if i >= length l - 1 then 0 else i + 1
|
|
||||||
Nothing -> 0
|
|
||||||
|
|
||||||
-- | Given a completion and a list of possible completions, returns the
|
|
||||||
-- the next completion in the list
|
|
||||||
getNextOfLastWord :: XPrompt t => t -> String -> [String] -> String
|
|
||||||
getNextOfLastWord t c l = skipLastWord c ++ completionToCommand t (l !! ni)
|
|
||||||
where ni = case commandToComplete t c `elemIndex` map (completionToCommand t) l of
|
|
||||||
Just i -> if i >= length l - 1 then 0 else i + 1
|
|
||||||
Nothing -> 0
|
|
||||||
|
|
||||||
-- | Gets the last word of a string or the whole string if formed by
|
-- | Gets the last word of a string or the whole string if formed by
|
||||||
-- only one word
|
-- only one word
|
||||||
getLastWord :: String -> String
|
getLastWord :: String -> String
|
||||||
|
Reference in New Issue
Block a user