xmonad-contrib-0.9.1: Third party extensions for xmonadSource codeContentsIndex
XMonad.Prompt
Portabilityunportable
Stabilityunstable
MaintainerSpencer Janssen <spencerjanssen@gmail.com>
Contents
Usage
X Utilities
Other Utilities
nextCompletion implementations
List utilities
History filters
Description
A module for writing graphical prompts for XMonad
Synopsis
mkXPrompt :: XPrompt p => p -> XPConfig -> ComplFunction -> (String -> X ()) -> X ()
mkXPromptWithReturn :: XPrompt p => p -> XPConfig -> ComplFunction -> (String -> X a) -> X (Maybe a)
amberXPConfig :: XPConfig
defaultXPConfig :: XPConfig
greenXPConfig :: XPConfig
data XPType = forall p . XPrompt p => XPT p
data XPPosition
= Top
| Bottom
data XPConfig = XPC {
font :: String
bgColor :: String
fgColor :: String
fgHLight :: String
bgHLight :: String
borderColor :: String
promptBorderWidth :: !Dimension
position :: XPPosition
height :: !Dimension
historySize :: !Int
historyFilter :: [String] -> [String]
promptKeymap :: Map (KeyMask, KeySym) (XP ())
completionKey :: KeySym
defaultText :: String
autoComplete :: Maybe Int
showCompletionOnTab :: Bool
}
class XPrompt t where
showXPrompt :: t -> String
nextCompletion :: t -> String -> [String] -> String
commandToComplete :: t -> String -> String
completionToCommand :: t -> String -> String
type XP = StateT XPState IO
defaultXPKeymap :: Map (KeyMask, KeySym) (XP ())
quit :: XP ()
killBefore :: XP ()
killAfter :: XP ()
startOfLine :: XP ()
endOfLine :: XP ()
pasteString :: XP ()
copyString :: XP ()
moveCursor :: Direction1D -> XP ()
moveWord :: Direction1D -> XP ()
killWord :: Direction1D -> XP ()
deleteString :: Direction1D -> XP ()
moveHistory :: (Stack String -> Stack String) -> XP ()
setSuccess :: Bool -> XP ()
setDone :: Bool -> XP ()
data Direction1D
= Next
| Prev
type ComplFunction = String -> IO [String]
mkUnmanagedWindow :: Display -> Screen -> Window -> Position -> Position -> Dimension -> Dimension -> IO Window
fillDrawable :: Display -> Drawable -> GC -> Pixel -> Pixel -> Dimension -> Dimension -> Dimension -> IO ()
mkComplFunFromList :: [String] -> String -> IO [String]
mkComplFunFromList' :: [String] -> String -> IO [String]
getNextOfLastWord :: XPrompt t => t -> String -> [String] -> String
getNextCompletion :: String -> [String] -> String
getLastWord :: String -> String
skipLastWord :: String -> String
splitInSubListsAt :: Int -> [a] -> [[a]]
breakAtSpace :: String -> (String, String)
uniqSort :: Ord a => [a] -> [a]
decodeInput :: String -> String
encodeOutput :: String -> String
historyCompletion :: ComplFunction
historyCompletionP :: (String -> Bool) -> ComplFunction
deleteAllDuplicates :: [String] -> [String]
deleteConsecutive :: [String] -> [String]
Usage

For usage examples see XMonad.Prompt.Shell, XMonad.Prompt.XMonad or XMonad.Prompt.Ssh

TODO:

  • scrolling the completions that don't fit in the window (?)
mkXPrompt :: XPrompt p => p -> XPConfig -> ComplFunction -> (String -> X ()) -> X ()Source

Creates a prompt given:

  • a prompt type, instance of the XPrompt class.
  • a prompt configuration (defaultXPConfig can be used as a starting point)
  • a completion function (mkComplFunFromList can be used to create a completions function given a list of possible completions)
  • an action to be run: the action must take a string and return X ()
mkXPromptWithReturn :: XPrompt p => p -> XPConfig -> ComplFunction -> (String -> X a) -> X (Maybe a)Source
Same as mkXPrompt, except that the action function can have type String -> X a, for any a, and the final action returned by mkXPromptWithReturn will have type X (Maybe a). Nothing is yielded if the user cancels the prompt (by e.g. hitting Esc or Ctrl-G). For an example of use, see the XMonad.Prompt.Input module.
amberXPConfig :: XPConfigSource
defaultXPConfig :: XPConfigSource
greenXPConfig :: XPConfigSource
data XPType Source
Constructors
forall p . XPrompt p => XPT p
data XPPosition Source
Constructors
Top
Bottom
data XPConfig Source
Constructors
XPC
font :: StringFont
bgColor :: StringBackground color
fgColor :: StringFont color
fgHLight :: StringFont color of a highlighted completion entry
bgHLight :: StringBackground color of a highlighted completion entry
borderColor :: StringBorder color
promptBorderWidth :: !DimensionBorder width
position :: XPPositionPosition: Top or Bottom
height :: !DimensionWindow height
historySize :: !IntThe number of history entries to be saved
historyFilter :: [String] -> [String]a filter to determine which history entries to remember
promptKeymap :: Map (KeyMask, KeySym) (XP ())Mapping from key combinations to actions
completionKey :: KeySymKey that should trigger completion
defaultText :: StringThe text by default in the prompt line
autoComplete :: Maybe IntJust x: if only one completion remains, auto-select it,
showCompletionOnTab :: BoolOnly show list of completions when Tab was pressed and delay by x microseconds
class XPrompt t whereSource

The class prompt types must be an instance of. In order to create a prompt you need to create a data type, without parameters, and make it an instance of this class, by implementing a simple method, showXPrompt, which will be used to print the string to be displayed in the command line window.

This is an example of a XPrompt instance definition:

     instance XPrompt Shell where
          showXPrompt Shell = "Run: "
Methods
showXPrompt :: t -> StringSource
This method is used to print the string to be displayed in the command line window.
nextCompletion :: t -> String -> [String] -> StringSource
This method is used to generate the next completion to be printed in the command line when tab is pressed, given the string presently in the command line and the list of completion.
commandToComplete :: t -> String -> StringSource
This method is used to generate the string to be passed to the completion function.
completionToCommand :: t -> String -> StringSource
This method is used to process each completion in order to generate the string that will be compared with the command presently displayed in the command line. If the prompt is using getNextOfLastWord for implementing nextCompletion (the default implementation), this method is also used to generate, from the returned completion, the string that will form the next command line when tab is pressed.
type XP = StateT XPState IOSource
defaultXPKeymap :: Map (KeyMask, KeySym) (XP ())Source
quit :: XP ()Source
Quit.
killBefore :: XP ()Source
Kill the portion of the command before the cursor
killAfter :: XP ()Source
Kill the portion of the command including and after the cursor
startOfLine :: XP ()Source
Put the cursor at the start of line
endOfLine :: XP ()Source
Put the cursor at the end of line
pasteString :: XP ()Source
Insert the current X selection string at the cursor position.
copyString :: XP ()Source
Copy the currently entered string into the X selection.
moveCursor :: Direction1D -> XP ()Source
move the cursor one position
moveWord :: Direction1D -> XP ()Source
move the cursor one word
killWord :: Direction1D -> XP ()Source
Kill the next/previous word
deleteString :: Direction1D -> XP ()Source
Remove a character at the cursor position
moveHistory :: (Stack String -> Stack String) -> XP ()Source
setSuccess :: Bool -> XP ()Source
setDone :: Bool -> XP ()Source
data Direction1D Source
One-dimensional directions:
Constructors
Next
Prev
type ComplFunction = String -> IO [String]Source
X Utilities
mkUnmanagedWindow :: Display -> Screen -> Window -> Position -> Position -> Dimension -> Dimension -> IO WindowSource
Creates a window with the attribute override_redirect set to True. Windows Managers should not touch this kind of windows.
fillDrawable :: Display -> Drawable -> GC -> Pixel -> Pixel -> Dimension -> Dimension -> Dimension -> IO ()Source
Fills a Drawable with a rectangle and a border
Other Utilities
mkComplFunFromList :: [String] -> String -> IO [String]Source
This function takes a list of possible completions and returns a completions function to be used with mkXPrompt
mkComplFunFromList' :: [String] -> String -> IO [String]Source
This function takes a list of possible completions and returns a completions function to be used with mkXPrompt. If the string is null it will return all completions.
nextCompletion implementations
getNextOfLastWord :: XPrompt t => t -> String -> [String] -> StringSource
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.
getNextCompletion :: String -> [String] -> StringSource
An alternative nextCompletion implementation: given a command and a completion list, get the next completion in the list matching the whole command line.
List utilities
getLastWord :: String -> StringSource
Gets the last word of a string or the whole string if formed by only one word
skipLastWord :: String -> StringSource
Skips the last word of the string, if the string is composed by more then one word. Otherwise returns the string.
splitInSubListsAt :: Int -> [a] -> [[a]]Source
Given a maximum length, splits a list into sublists
breakAtSpace :: String -> (String, String)Source
uniqSort :: Ord a => [a] -> [a]Source
Sort a list and remove duplicates. Like deleteAllDuplicates, but trades off laziness and stability for efficiency.
decodeInput :: String -> StringSource
encodeOutput :: String -> StringSource
historyCompletion :: ComplFunctionSource
historyCompletion provides a canned completion function much like getShellCompl; you pass it to mkXPrompt, and it will make completions work from the query history stored in ~/.xmonad/history.
historyCompletionP :: (String -> Bool) -> ComplFunctionSource
Like historyCompletion but only uses history data from Prompts whose name satisfies the given predicate.
History filters
deleteAllDuplicates :: [String] -> [String]Source
deleteConsecutive :: [String] -> [String]Source
Functions to be used with the historyFilter setting. deleteAllDuplicates will remove all duplicate entries. deleteConsecutive will only remove duplicate elements immediately next to each other.
Produced by Haddock version 2.6.1