XMonad.Prompt

xmonad-contrib-0.18.1: Community-maintained extensions for xmonad

Copyright | (C) 2007 Andrea Rossato 2015 Evgeny Kurnevsky 2015 Sibi Prabakaran 2018 Yclept Nemo
License | BSD3
Maintainer | Spencer Janssen <spencerjanssen@gmail.com>
Stability | unstable
Portability | unportable
Safe Haskell | None
Language | Haskell2010

XMonad.Prompt

Contents

- Usage
- X Utilities
- Other Utilities
- `nextCompletion` implementations
- List utilities
- History filters
- Types

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)
- mkXPromptWithModes :: [XPType] -> XPConfig -> X ()
- def :: Default a => a
- amberXPConfig :: XPConfig
- greenXPConfig :: XPConfig
- type XPMode = XPType
- data XPType = XPrompt p => XPT p
- data XPColor = XPColor {
  - bgNormal :: String
  - fgNormal :: String
  - bgHighlight :: String
  - fgHighlight :: String
  - border :: String
  }
- data XPPosition
  - = Top
  - | Bottom
  - | CenteredAt {
    - xpCenterY :: Rational
    - xpWidth :: Rational
    }
- data XPConfig = XPC {
  - font :: String
  - bgColor :: String
  - fgColor :: String
  - bgHLight :: String
  - fgHLight :: String
  - borderColor :: String
  - promptBorderWidth :: !Dimension
  - position :: XPPosition
  - alwaysHighlight :: !Bool
  - height :: !Dimension
  - maxComplRows :: Maybe Dimension
  - maxComplColumns :: Maybe Dimension
  - historySize :: !Int
  - historyFilter :: [String] -> [String]
  - promptKeymap :: Map (KeyMask, KeySym) (XP ())
  - completionKey :: (KeyMask, KeySym)
  - prevCompletionKey :: (KeyMask, KeySym)
  - changeModeKey :: KeySym
  - defaultText :: String
  - autoComplete :: Maybe Int
  - showCompletionOnTab :: Bool
  - complCaseSensitivity :: ComplCaseSensitivity
  - searchPredicate :: String -> String -> Bool
  - defaultPrompter :: String -> String
  - sorter :: String -> [String] -> [String]
  }
- class XPrompt t where
  - showXPrompt :: t -> String
  - nextCompletion :: t -> String -> [String] -> String
  - commandToComplete :: t -> String -> String
  - completionToCommand :: t -> String -> String
  - completionFunction :: t -> ComplFunction
  - modeAction :: t -> String -> String -> X ()
- type XP = StateT XPState IO
- defaultXPKeymap :: Map (KeyMask, KeySym) (XP ())
- defaultXPKeymap' :: (Char -> Bool) -> Map (KeyMask, KeySym) (XP ())
- emacsLikeXPKeymap :: Map (KeyMask, KeySym) (XP ())
- emacsLikeXPKeymap' :: (Char -> Bool) -> Map (KeyMask, KeySym) (XP ())
- vimLikeXPKeymap :: Map (KeyMask, KeySym) (XP ())
- vimLikeXPKeymap' :: (XPColor -> XPColor) -> (String -> String) -> (String -> String) -> (Char -> Bool) -> Map (KeyMask, KeySym) (XP ())
- quit :: XP ()
- promptSubmap :: XP () -> Map (KeyMask, KeySym) (XP ()) -> XP ()
- promptBuffer :: (String -> String -> (Bool, Bool)) -> XP String
- toHeadChar :: Direction1D -> String -> XP ()
- bufferOne :: String -> String -> (Bool, Bool)
- killBefore :: XP ()
- killAfter :: XP ()
- startOfLine :: XP ()
- endOfLine :: XP ()
- insertString :: String -> XP ()
- pasteString :: XP ()
- pasteString' :: (String -> String) -> XP ()
- clipCursor :: XP ()
- moveCursor :: Direction1D -> XP ()
- moveCursorClip :: Direction1D -> XP ()
- setInput :: String -> XP ()
- getInput :: XP String
- getOffset :: XP Int
- defaultColor :: XPConfig -> XPColor
- modifyColor :: (XPColor -> XPColor) -> XP ()
- setColor :: XPColor -> XP ()
- resetColor :: XP ()
- setBorderColor :: String -> XPColor -> XPColor
- modifyPrompter :: ((String -> String) -> String -> String) -> XP ()
- setPrompter :: (String -> String) -> XP ()
- resetPrompter :: XP ()
- selectedCompletion :: XPState -> String
- setCurrentCompletions :: Maybe [String] -> XP ()
- getCurrentCompletions :: XP (Maybe [String])
- moveWord :: Direction1D -> XP ()
- moveWord' :: (Char -> Bool) -> Direction1D -> XP ()
- killWord :: Direction1D -> XP ()
- killWord' :: (Char -> Bool) -> Direction1D -> XP ()
- changeWord :: (Char -> Bool) -> XP ()
- deleteString :: Direction1D -> XP ()
- moveHistory :: (Stack String -> Stack String) -> XP ()
- setSuccess :: Bool -> XP ()
- setDone :: Bool -> XP ()
- setModeDone :: Bool -> XP ()
- data Direction1D
  - = Next
  - | Prev
- type ComplFunction = String -> IO [String]
- data ComplCaseSensitivity
  - = CaseSensitive
  - | CaseInSensitive
- mkUnmanagedWindow :: Display -> Screen -> Window -> Position -> Position -> Dimension -> Dimension -> IO Window
- fillDrawable :: Display -> Drawable -> GC -> Pixel -> Pixel -> Dimension -> Dimension -> Dimension -> IO ()
- mkComplFunFromList :: XPConfig -> [String] -> String -> IO [String]
- mkComplFunFromList' :: XPConfig -> [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]
- historyCompletion :: XPConfig -> X ComplFunction
- historyCompletionP :: XPConfig -> (String -> Bool) -> X ComplFunction
- deleteAllDuplicates :: [String] -> [String]
- deleteConsecutive :: [String] -> [String]
- data HistoryMatches
- initMatches :: (Functor m, MonadIO m) => m HistoryMatches
- historyUpMatching :: HistoryMatches -> XP ()
- historyDownMatching :: HistoryMatches -> XP ()
- data XPState

# 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 () #

Creates a prompt given:

- a prompt type, instance of the `XPrompt` class.
- a prompt configuration (`def` 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) #

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 `Input` module.

mkXPromptWithModes :: [XPType] -> XPConfig -> X () #

Creates a prompt with multiple modes given:

- A non-empty list of modes
- A prompt configuration

The created prompt allows to switch between modes with `changeModeKey` in `conf`. The modes are instances of XPrompt. See XMonad.Actions.Launcher for more details

The argument supplied to the action to execute is always the current highlighted item, that means that this prompt overrides the value `alwaysHighlight` for its configuration to True.

def :: Default a => a #

The default value for this type.

amberXPConfig :: XPConfig #

greenXPConfig :: XPConfig #

type XPMode = XPType #

data XPType #

Constructors

XPrompt p => XPT p |

#### Instances

Instances details

Show XPType # |
Instance details Defined in XMonad.Prompt Methods showsPrec :: Int -> XPType -> ShowS # show :: XPType -> String # showList :: [XPType] -> ShowS #
XPrompt XPType # |
Instance details Defined in XMonad.Prompt Methods showXPrompt :: XPType -> String # nextCompletion :: XPType -> String -> [String] -> String # commandToComplete :: XPType -> String -> String # completionToCommand :: XPType -> String -> String # completionFunction :: XPType -> ComplFunction # modeAction :: XPType -> String -> String -> X () #

data XPColor #

Constructors

XPColor |
Fields bgNormal :: String Background color fgNormal :: String Font color bgHighlight :: String Background color of a highlighted completion entry fgHighlight :: String Font color of a highlighted completion entry border :: String Border color

#### Instances

Instances details

Default XPColor # |
Instance details Defined in XMonad.Prompt Methods def :: XPColor #

data XPPosition #

Constructors

Top |
Bottom |
CenteredAt | Prompt will be placed in the center horizontally and in the certain place of screen vertically. If it's in the upper part of the screen, completion window will be placed below (like in `Top`) and otherwise above (like in `Bottom`)
Fields xpCenterY :: Rational Rational between 0 and 1, giving y coordinate of center of the prompt relative to the screen height. xpWidth :: Rational Rational between 0 and 1, giving width of the prompt relative to the screen width.

#### Instances

Instances details

Read XPPosition # |
Instance details Defined in XMonad.Prompt Methods readsPrec :: Int -> ReadS XPPosition # readList :: ReadS [XPPosition] # readPrec :: ReadPrec XPPosition # readListPrec :: ReadPrec [XPPosition] #
Show XPPosition # |
Instance details Defined in XMonad.Prompt Methods showsPrec :: Int -> XPPosition -> ShowS # show :: XPPosition -> String # showList :: [XPPosition] -> ShowS #

data XPConfig #

Constructors

XPC |
Fields font :: String Font. For TrueType fonts, use something like `"xft:Hack:pixelsize=1"`. Alternatively, use X Logical Font Description, i.e. something like `"-*-dejavu sans mono-medium-r-normal--*-80-*-*-*-*-iso10646-1"`. bgColor :: String Background color fgColor :: String Font color bgHLight :: String Background color of a highlighted completion entry fgHLight :: String Font color of a highlighted completion entry borderColor :: String Border color promptBorderWidth :: !Dimension Border width position :: XPPosition Position: `Top`, `Bottom`, or `CenteredAt` alwaysHighlight :: !Bool Always highlight an item, overriden to True with multiple modes height :: !Dimension Window height maxComplRows :: Maybe Dimension Just x: maximum number of rows to show in completion window maxComplColumns :: Maybe Dimension Just x: maximum number of columns to show in completion window historySize :: !Int The 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 :: (KeyMask, KeySym) Key to trigger forward completion prevCompletionKey :: (KeyMask, KeySym) Key to trigger backward completion changeModeKey :: KeySym Key to change mode (when the prompt has multiple modes) defaultText :: String The text by default in the prompt line autoComplete :: Maybe Int Just x: if only one completion remains, auto-select it, and delay by x microseconds showCompletionOnTab :: Bool Only show list of completions when Tab was pressed complCaseSensitivity :: ComplCaseSensitivity Perform completion in a case-sensitive manner searchPredicate :: String -> String -> Bool Given the typed string and a possible completion, is the completion valid? defaultPrompter :: String -> String Modifies the prompt given by `showXPrompt` 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).

#### Instances

Instances details

Default XPConfig # |
Instance details Defined in XMonad.Prompt Methods def :: XPConfig #

class XPrompt t where #

A class for an abstract prompt. In order for your data type to be a valid prompt you _must_ make it an instance of this class.

The minimal complete definition is just `showXPrompt`, i.e. the name of the prompt. This string will be displayed in the command line window (before the cursor).

As an example of a complete `XPrompt` instance definition, we can look at the `Shell` prompt from XMonad.Prompt.Shell:

        data Shell = Shell

        instance XPrompt Shell where
             showXPrompt Shell = "Run: "

Minimal complete definition

showXPrompt

Methods

showXPrompt :: t -> String #

This method is used to print the string to be displayed in the command line window.

nextCompletion :: t -> String -> [String] -> String #

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. This function is not used when in multiple modes (because alwaysHighlight in XPConfig is True)

commandToComplete :: t -> String -> String #

This method is used to generate the string to be passed to the completion function.

completionToCommand :: t -> String -> String #

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.

completionFunction :: t -> ComplFunction #

When the prompt has multiple modes, this is the function used to generate the autocompletion list. The argument passed to this function is given by `commandToComplete` The default implementation shows an error message.

modeAction :: t -> String -> String -> X () #

When the prompt has multiple modes (created with mkXPromptWithModes), this function is called when the user picks an item from the autocompletion list. The first argument is the prompt (or mode) on which the item was picked The first string argument is the autocompleted item's text. The second string argument is the query made by the user (written in the prompt's buffer). See XMonadActionsLauncher.hs for a usage example.

#### Instances

Instances details

XPrompt WSGPrompt # |
Instance details Defined in XMonad.Actions.DynamicWorkspaceGroups Methods showXPrompt :: WSGPrompt -> String # nextCompletion :: WSGPrompt -> String -> [String] -> String # commandToComplete :: WSGPrompt -> String -> String # completionToCommand :: WSGPrompt -> String -> String # completionFunction :: WSGPrompt -> ComplFunction # modeAction :: WSGPrompt -> String -> String -> X () #
XPrompt Search # |
Instance details Defined in XMonad.Actions.Search Methods showXPrompt :: Search -> String # nextCompletion :: Search -> String -> [String] -> String # commandToComplete :: Search -> String -> String # completionToCommand :: Search -> String -> String # completionFunction :: Search -> ComplFunction # modeAction :: Search -> String -> String -> X () #
XPrompt TagPrompt # |
Instance details Defined in XMonad.Actions.TagWindows Methods showXPrompt :: TagPrompt -> String # nextCompletion :: TagPrompt -> String -> [String] -> String # commandToComplete :: TagPrompt -> String -> String # completionToCommand :: TagPrompt -> String -> String # completionFunction :: TagPrompt -> ComplFunction # modeAction :: TagPrompt -> String -> String -> X () #
XPrompt XPType # |
Instance details Defined in XMonad.Prompt Methods showXPrompt :: XPType -> String # nextCompletion :: XPType -> String -> [String] -> String # commandToComplete :: XPType -> String -> String # completionToCommand :: XPType -> String -> String # completionFunction :: XPType -> ComplFunction # modeAction :: XPType -> String -> String -> X () #
XPrompt AppPrompt # |
Instance details Defined in XMonad.Prompt.AppLauncher Methods showXPrompt :: AppPrompt -> String # nextCompletion :: AppPrompt -> String -> [String] -> String # commandToComplete :: AppPrompt -> String -> String # completionToCommand :: AppPrompt -> String -> String # completionFunction :: AppPrompt -> ComplFunction # modeAction :: AppPrompt -> String -> String -> X () #
XPrompt AppendFile # |
Instance details Defined in XMonad.Prompt.AppendFile Methods showXPrompt :: AppendFile -> String # nextCompletion :: AppendFile -> String -> [String] -> String # commandToComplete :: AppendFile -> String -> String # completionToCommand :: AppendFile -> String -> String # completionFunction :: AppendFile -> ComplFunction # modeAction :: AppendFile -> String -> String -> X () #
XPrompt EnterPrompt # |
Instance details Defined in XMonad.Prompt.ConfirmPrompt Methods showXPrompt :: EnterPrompt -> String # nextCompletion :: EnterPrompt -> String -> [String] -> String # commandToComplete :: EnterPrompt -> String -> String # completionToCommand :: EnterPrompt -> String -> String # completionFunction :: EnterPrompt -> ComplFunction # modeAction :: EnterPrompt -> String -> String -> X () #
XPrompt DirExec # |
Instance details Defined in XMonad.Prompt.DirExec Methods showXPrompt :: DirExec -> String # nextCompletion :: DirExec -> String -> [String] -> String # commandToComplete :: DirExec -> String -> String # completionToCommand :: DirExec -> String -> String # completionFunction :: DirExec -> ComplFunction # modeAction :: DirExec -> String -> String -> X () #
XPrompt Dir # |
Instance details Defined in XMonad.Prompt.Directory Methods showXPrompt :: Dir -> String # nextCompletion :: Dir -> String -> [String] -> String # commandToComplete :: Dir -> String -> String # completionToCommand :: Dir -> String -> String # completionFunction :: Dir -> ComplFunction # modeAction :: Dir -> String -> String -> X () #
XPrompt InputPrompt # |
Instance details Defined in XMonad.Prompt.Input Methods showXPrompt :: InputPrompt -> String # nextCompletion :: InputPrompt -> String -> [String] -> String # commandToComplete :: InputPrompt -> String -> String # completionToCommand :: InputPrompt -> String -> String # completionFunction :: InputPrompt -> ComplFunction # modeAction :: InputPrompt -> String -> String -> X () #
XPrompt Man # |
Instance details Defined in XMonad.Prompt.Man Methods showXPrompt :: Man -> String # nextCompletion :: Man -> String -> [String] -> String # commandToComplete :: Man -> String -> String # completionToCommand :: Man -> String -> String # completionFunction :: Man -> ComplFunction # modeAction :: Man -> String -> String -> X () #
XPrompt OrgMode # |
Instance details Defined in XMonad.Prompt.OrgMode Methods showXPrompt :: OrgMode -> String # nextCompletion :: OrgMode -> String -> [String] -> String # commandToComplete :: OrgMode -> String -> String # completionToCommand :: OrgMode -> String -> String # completionFunction :: OrgMode -> ComplFunction # modeAction :: OrgMode -> String -> String -> X () #
XPrompt RunOrRaisePrompt # |
Instance details Defined in XMonad.Prompt.RunOrRaise Methods showXPrompt :: RunOrRaisePrompt -> String # nextCompletion :: RunOrRaisePrompt -> String -> [String] -> String # commandToComplete :: RunOrRaisePrompt -> String -> String # completionToCommand :: RunOrRaisePrompt -> String -> String # completionFunction :: RunOrRaisePrompt -> ComplFunction # modeAction :: RunOrRaisePrompt -> String -> String -> X () #
XPrompt Shell # |
Instance details Defined in XMonad.Prompt.Shell Methods showXPrompt :: Shell -> String # nextCompletion :: Shell -> String -> [String] -> String # commandToComplete :: Shell -> String -> String # completionToCommand :: Shell -> String -> String # completionFunction :: Shell -> ComplFunction # modeAction :: Shell -> String -> String -> X () #
XPrompt Ssh # |
Instance details Defined in XMonad.Prompt.Ssh Methods showXPrompt :: Ssh -> String # nextCompletion :: Ssh -> String -> [String] -> String # commandToComplete :: Ssh -> String -> String # completionToCommand :: Ssh -> String -> String # completionFunction :: Ssh -> ComplFunction # modeAction :: Ssh -> String -> String -> X () #
XPrompt ThemePrompt # |
Instance details Defined in XMonad.Prompt.Theme Methods showXPrompt :: ThemePrompt -> String # nextCompletion :: ThemePrompt -> String -> [String] -> String # commandToComplete :: ThemePrompt -> String -> String # completionToCommand :: ThemePrompt -> String -> String # completionFunction :: ThemePrompt -> ComplFunction # modeAction :: ThemePrompt -> String -> String -> X () #
XPrompt WindowPrompt # |
Instance details Defined in XMonad.Prompt.Window Methods showXPrompt :: WindowPrompt -> String # nextCompletion :: WindowPrompt -> String -> [String] -> String # commandToComplete :: WindowPrompt -> String -> String # completionToCommand :: WindowPrompt -> String -> String # completionFunction :: WindowPrompt -> ComplFunction # modeAction :: WindowPrompt -> String -> String -> X () #
XPrompt Wor # |
Instance details Defined in XMonad.Prompt.Workspace Methods showXPrompt :: Wor -> String # nextCompletion :: Wor -> String -> [String] -> String # commandToComplete :: Wor -> String -> String # completionToCommand :: Wor -> String -> String # completionFunction :: Wor -> ComplFunction # modeAction :: Wor -> String -> String -> X () #
XPrompt XMonad # |
Instance details Defined in XMonad.Prompt.XMonad Methods showXPrompt :: XMonad -> String # nextCompletion :: XMonad -> String -> [String] -> String # commandToComplete :: XMonad -> String -> String # completionToCommand :: XMonad -> String -> String # completionFunction :: XMonad -> ComplFunction # modeAction :: XMonad -> String -> String -> X () #
XPrompt Zsh # |
Instance details Defined in XMonad.Prompt.Zsh Methods showXPrompt :: Zsh -> String # nextCompletion :: Zsh -> String -> [String] -> String # commandToComplete :: Zsh -> String -> String # completionToCommand :: Zsh -> String -> String # completionFunction :: Zsh -> ComplFunction # modeAction :: Zsh -> String -> String -> X () #

type XP = StateT XPState IO #

defaultXPKeymap :: Map (KeyMask, KeySym) (XP ()) #

Default key bindings for prompts. Click on the "Source" link to the right to see the complete list. See also `defaultXPKeymap'`.

defaultXPKeymap' :: (Char -> Bool) -> Map (KeyMask, KeySym) (XP ()) #

A variant of `defaultXPKeymap` which lets you specify a custom predicate for identifying non-word characters, which affects all the word-oriented commands (move/kill word). The default is `isSpace`. For example, by default a path like `foo/bar/baz` would be considered as a single word. You could use a predicate like `(\c -> isSpace c || c == '/')` to move through or delete components of the path one at a time.

emacsLikeXPKeymap :: Map (KeyMask, KeySym) (XP ()) #

A keymap with many emacs-like key bindings. Click on the "Source" link to the right to see the complete list. See also `emacsLikeXPKeymap'`.

emacsLikeXPKeymap' :: (Char -> Bool) -> Map (KeyMask, KeySym) (XP ()) #

A variant of `emacsLikeXPKeymap` which lets you specify a custom predicate for identifying non-word characters, which affects all the word-oriented commands (move/kill word). The default is `isSpace`. For example, by default a path like `foo/bar/baz` would be considered as a single word. You could use a predicate like `(\c -> isSpace c || c == '/')` to move through or delete components of the path one at a time.

vimLikeXPKeymap :: Map (KeyMask, KeySym) (XP ()) #

Vim-ish key bindings. Click on the "Source" link to the right to see the complete list. See also `vimLikeXPKeymap'`.

vimLikeXPKeymap' #

Arguments

:: (XPColor -> XPColor) | Modifies the prompt color when entering normal mode. The default is `setBorderColor "grey22"` - same color as the default background color.
-> (String -> String) | Prompter to use in normal mode. The default of `id` balances `defaultPrompter` but `("[n] " ++)` is a good alternate with `defaultPrompter` as `("[i] " ++)`.
-> (String -> String) | Filter applied to the X Selection before pasting. The default is `id` but `filter isPrint` is a good alternate.
-> (Char -> Bool) | Predicate identifying non-word characters. The default is `isSpace`. See the documentation of other keymaps for alternates.
-> Map (KeyMask, KeySym) (XP ()) |

A variant of `vimLikeXPKeymap` with customizable aspects:

quit :: XP () #

Quit.

promptSubmap :: XP () -> Map (KeyMask, KeySym) (XP ()) -> XP () #

Initiate a prompt sub-map event loop. Submaps are intended to provide alternate keybindings. Accepts a default action and a mapping from key combinations to actions. If no entry matches, the default action is run.

promptBuffer :: (String -> String -> (Bool, Bool)) -> XP String #

Initiate a prompt input buffer event loop. Input is sent to a buffer and bypasses the prompt. The provided function is given the existing buffer and the input keystring. The first field of the result determines whether the input loop continues (if `True`). The second field determines whether the input is appended to the buffer, or dropped (if `False`). If the loop is to stop without keeping input - that is, `(False,False)` - the event is prepended to the event buffer to be processed by the parent loop. This allows loop to process both fixed and indeterminate inputs.

Result given `(continue,keep)`:

- cont and keep

  - grow input buffer

- stop and keep

  - grow input buffer
  - stop loop

- stop and drop

  - buffer event
  - stop loop

- cont and drop

  - do nothing

toHeadChar :: Direction1D -> String -> XP () #

Move the cursor in the given direction to the first instance of the first character of the given string, assuming the string is not empty. The starting cursor character is not considered, and the cursor is placed over the matching character.

bufferOne :: String -> String -> (Bool, Bool) #

Predicate instructing `promptBuffer` to get (and keep) a single non-empty `KeyEvent`.

killBefore :: XP () #

Kill the portion of the command before the cursor

killAfter :: XP () #

Kill the portion of the command including and after the cursor

startOfLine :: XP () #

Put the cursor at the start of line

endOfLine :: XP () #

Put the cursor at the end of line

insertString :: String -> XP () #

Insert a character at the cursor position

pasteString :: XP () #

Insert the current X selection string at the cursor position. The X selection is not modified.

pasteString' :: (String -> String) -> XP () #

A variant of `pasteString` which allows modifying the X selection before pasting.

clipCursor :: XP () #

Ensure the cursor remains over the command by shifting left if necessary.

moveCursor :: Direction1D -> XP () #

Move the cursor one position.

moveCursorClip :: Direction1D -> XP () #

Move the cursor one position, but not beyond the command.

setInput :: String -> XP () #

Sets the input string to the given value.

getInput :: XP String #

Returns the current input string. Intended for use in custom keymaps where `get` or similar can't be used to retrieve it.

getOffset :: XP Int #

Returns the offset of the current input string. Intended for use in custom keys where `get` or similar can't be used to retrieve it.

defaultColor :: XPConfig -> XPColor #

Accessor encapsulating disparate color fields of `XPConfig` into an `XPColor` (the configuration provides default values).

modifyColor :: (XPColor -> XPColor) -> XP () #

Modify the prompt colors.

setColor :: XPColor -> XP () #

Set the prompt colors.

resetColor :: XP () #

Reset the prompt colors to those from `XPConfig`.

setBorderColor :: String -> XPColor -> XPColor #

Set the prompt border color.

modifyPrompter :: ((String -> String) -> String -> String) -> XP () #

Modify the prompter, i.e. for chaining prompters.

setPrompter :: (String -> String) -> XP () #

Set the prompter.

resetPrompter :: XP () #

Reset the prompter to the one from `XPConfig`.

selectedCompletion :: XPState -> String #

Return the selected completion, i.e. the `String` we actually act upon after the user confirmed their selection (by pressing `Enter`).

setCurrentCompletions :: Maybe [String] -> XP () #

Set the current completion list, or `Nothing` to invalidate the current completions.

getCurrentCompletions :: XP (Maybe [String]) #

Get the current completion list.

moveWord :: Direction1D -> XP () #

Move the cursor one word, using `isSpace` as the default predicate for non-word characters. See `moveWord'`.

moveWord' :: (Char -> Bool) -> Direction1D -> XP () #

Given a direction, move the cursor to just before the next (predicate,not-predicate) character transition. This means a (not-word,word) transition should be followed by a `moveCursorClip` action. Always considers the character under the current cursor position. This means a (word,not-word) transition should be preceded by a `moveCursorClip` action. Calculated as the length of consecutive non-predicate characters starting from the cursor position, plus the length of subsequent consecutive predicate characters, plus when moving backwards the distance of the cursor beyond the input. Reduced by one to avoid jumping off either end of the input, when present.

Use these identities to retain the pre-0.14 behavior:

        (oldMoveWord' p Prev) = (moveCursor Prev >> moveWord' p Prev)

        (oldMoveWord' p Next) = (moveWord' p Next >> moveCursor Next)

killWord :: Direction1D -> XP () #

Kill the next/previous word, using `isSpace` as the default predicate for non-word characters. See `killWord'`.

killWord' :: (Char -> Bool) -> Direction1D -> XP () #

Kill the next/previous word, given a predicate to identify non-word characters. First delete any consecutive non-word characters; then delete consecutive word characters, stopping just before the next non-word character.

For example, by default (using `killWord`) a path like `foo/bar/baz` would be deleted in its entirety. Instead you can use something like `killWord' (\c -> isSpace c || c == '/')` to delete the path one component at a time.

changeWord :: (Char -> Bool) -> XP () #

From Vim's `:help cw`:

- Special case: When the cursor is in a word, "cw" and "cW" do not include the white space after a word, they only change up to the end of the word.

deleteString :: Direction1D -> XP () #

Remove a character at the cursor position

moveHistory :: (Stack String -> Stack String) -> XP () #

Set the prompt's input to an entry further up or further down the history stack. Use `Stack` functions from `StackSet`, i.e. `focusUp'` or `focusDown'`.

setSuccess :: Bool -> XP () #

Set `True` to save the prompt's entry to history and run it via the provided action.

setDone :: Bool -> XP () #

Set `True` to leave all event loops, no matter how nested.

setModeDone :: Bool -> XP () #

Set `True` to leave the current event loop, i.e. submaps.

data Direction1D #

One-dimensional directions:

Constructors

Next |
Prev |

#### Instances

Instances details

Read Direction1D # |
Instance details Defined in XMonad.Util.Types Methods readsPrec :: Int -> ReadS Direction1D # readList :: ReadS [Direction1D] # readPrec :: ReadPrec Direction1D # readListPrec :: ReadPrec [Direction1D] #
Show Direction1D # |
Instance details Defined in XMonad.Util.Types Methods showsPrec :: Int -> Direction1D -> ShowS # show :: Direction1D -> String # showList :: [Direction1D] -> ShowS #
Eq Direction1D # |
Instance details Defined in XMonad.Util.Types Methods (==) :: Direction1D -> Direction1D -> Bool # (/=) :: Direction1D -> Direction1D -> Bool #

type ComplFunction = String -> IO [String] #

data ComplCaseSensitivity #

Constructors

CaseSensitive |
CaseInSensitive |

# X Utilities

mkUnmanagedWindow :: Display -> Screen -> Window -> Position -> Position -> Dimension -> Dimension -> IO Window #

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 () #

Fills a `Drawable` with a rectangle and a border

# Other Utilities

mkComplFunFromList :: XPConfig -> [String] -> String -> IO [String] #

This function takes a list of possible completions and returns a completions function to be used with `mkXPrompt`

mkComplFunFromList' :: XPConfig -> [String] -> String -> IO [String] #

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] -> String #

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] -> String #

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 -> String #

Gets the last word of a string or the whole string if formed by only one word

skipLastWord :: String -> String #

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]] #

Deprecated: Use XMonad.Prelude.chunksOf instead.

Given a maximum length, splits a list into sublists

breakAtSpace :: String -> (String, String) #

uniqSort :: Ord a => [a] -> [a] #

Sort a list and remove duplicates. Like `deleteAllDuplicates`, but trades off laziness and stability for efficiency.

historyCompletion :: XPConfig -> X ComplFunction #

`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 the XMonad cache directory.

historyCompletionP :: XPConfig -> (String -> Bool) -> X ComplFunction #

Like `historyCompletion` but only uses history data from Prompts whose name satisfies the given predicate.

# History filters

deleteAllDuplicates :: [String] -> [String] #

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.

deleteConsecutive :: [String] -> [String] #

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.

data HistoryMatches #

initMatches :: (Functor m, MonadIO m) => m HistoryMatches #

Initializes a new HistoryMatches structure to be passed to historyUpMatching

historyUpMatching :: HistoryMatches -> XP () #

Retrieve the next history element that starts with the current input. Pass it the result of initMatches when creating the prompt. Example:

    ..
    ((modMask,xK_p), shellPrompt . myPrompt =<< initMatches)
    ..
    myPrompt ref = def
      { promptKeymap = M.union [((0,xK_Up), historyUpMatching ref)
                               ,((0,xK_Down), historyDownMatching ref)]
                               (promptKeymap def)
      , .. }

historyDownMatching :: HistoryMatches -> XP () #

Retrieve the next history element that starts with the current input. Pass it the result of initMatches when creating the prompt. Example:

    ..
    ((modMask,xK_p), shellPrompt . myPrompt =<< initMatches)
    ..
    myPrompt ref = def
      { promptKeymap = M.union [((0,xK_Up), historyUpMatching ref)
                               ,((0,xK_Down), historyDownMatching ref)]
                               (promptKeymap def)
      , .. }

# Types

data XPState #