xmonad-contrib-0.15: Third party extensions for xmonad

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

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
- defaultXPConfig :: XPConfig
- greenXPConfig :: XPConfig
- type XPMode = XPType
- data XPType = XPrompt p => XPT p
- data XPPosition
  - = Top
  - | Bottom
  - | CenteredAt {
    - xpCenterY :: Rational
    - xpWidth :: Rational
    }
- data XPConfig = XPC {
  - font :: String
  - bgColor :: String
  - fgColor :: String
  - fgHLight :: String
  - bgHLight :: String
  - borderColor :: String
  - promptBorderWidth :: !Dimension
  - position :: XPPosition
  - alwaysHighlight :: !Bool
  - height :: !Dimension
  - maxComplRows :: Maybe Dimension
  - historySize :: !Int
  - historyFilter :: [String] -> [String]
  - promptKeymap :: Map (KeyMask, KeySym) (XP ())
  - completionKey :: (KeyMask, KeySym)
  - changeModeKey :: KeySym
  - defaultText :: String
  - autoComplete :: Maybe Int
  - showCompletionOnTab :: Bool
  - searchPredicate :: String -> String -> Bool
  }
- 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 ())
- quit :: XP ()
- killBefore :: XP ()
- killAfter :: XP ()
- startOfLine :: XP ()
- endOfLine :: XP ()
- insertString :: String -> XP ()
- pasteString :: XP ()
- moveCursor :: Direction1D -> XP ()
- setInput :: String -> XP ()
- getInput :: XP String
- moveWord :: Direction1D -> XP ()
- moveWord' :: (Char -> Bool) -> Direction1D -> XP ()
- killWord :: Direction1D -> XP ()
- killWord' :: (Char -> Bool) -> 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]
- historyCompletion :: ComplFunction
- historyCompletionP :: (String -> Bool) -> 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 () Source #

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

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

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 #

amberXPConfig :: XPConfig Source #

defaultXPConfig :: XPConfig Source #

Deprecated: Use def (from Data.Default, and re-exported from XMonad.Prompt) instead.

greenXPConfig :: XPConfig Source #

type XPMode = XPType Source #

data XPType Source #

Constructors

XPrompt p => XPT p |

Instances

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

data XPPosition Source #

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 relatave to the screen width.

Instances

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

data XPConfig Source #

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

- fgHLight :: String

  Font color of a highlighted completion entry

- bgHLight :: String

  Background 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. This implies having *one* column of autocompletions only.

- height :: !Dimension

  Window height

- maxComplRows :: Maybe Dimension

  Just x: maximum number of rows 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 that should trigger 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

- searchPredicate :: String -> String -> Bool

  Given the typed string and a possible completion, is the completion valid?

Instances

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

class XPrompt t where Source #

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: "

Minimal complete definition

showXPrompt

Methods

showXPrompt :: t -> String Source #

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

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

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

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

completionToCommand :: t -> String -> String Source #

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

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

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

XPrompt XPType Source # |
Instance details Defined in XMonad.Prompt Methods showXPrompt :: XPType -> String Source # nextCompletion :: XPType -> String -> [String] -> String Source # commandToComplete :: XPType -> String -> String Source # completionToCommand :: XPType -> String -> String Source # completionFunction :: XPType -> ComplFunction Source # modeAction :: XPType -> String -> String -> X () Source #
XPrompt XMonad Source # |
Instance details Defined in XMonad.Prompt.XMonad Methods showXPrompt :: XMonad -> String Source # nextCompletion :: XMonad -> String -> [String] -> String Source # commandToComplete :: XMonad -> String -> String Source # completionToCommand :: XMonad -> String -> String Source # completionFunction :: XMonad -> ComplFunction Source # modeAction :: XMonad -> String -> String -> X () Source #
XPrompt Wor Source # |
Instance details Defined in XMonad.Prompt.Workspace Methods showXPrompt :: Wor -> String Source # nextCompletion :: Wor -> String -> [String] -> String Source # commandToComplete :: Wor -> String -> String Source # completionToCommand :: Wor -> String -> String Source # completionFunction :: Wor -> ComplFunction Source # modeAction :: Wor -> String -> String -> X () Source #
XPrompt Ssh Source # |
Instance details Defined in XMonad.Prompt.Ssh Methods showXPrompt :: Ssh -> String Source # nextCompletion :: Ssh -> String -> [String] -> String Source # commandToComplete :: Ssh -> String -> String Source # completionToCommand :: Ssh -> String -> String Source # completionFunction :: Ssh -> ComplFunction Source # modeAction :: Ssh -> String -> String -> X () Source #
XPrompt Shell Source # |
Instance details Defined in XMonad.Prompt.Shell Methods showXPrompt :: Shell -> String Source # nextCompletion :: Shell -> String -> [String] -> String Source # commandToComplete :: Shell -> String -> String Source # completionToCommand :: Shell -> String -> String Source # completionFunction :: Shell -> ComplFunction Source # modeAction :: Shell -> String -> String -> X () Source #
XPrompt WindowPrompt Source # |

Instance details

Defined in XMonad.Prompt.Window

Methods

showXPrompt :: WindowPrompt -> String Source #

nextCompletion :: WindowPrompt -> String -> [String] -> String Source #

commandToComplete :: WindowPrompt -> String -> String Source #

completionToCommand :: WindowPrompt -> String -> String Source #

completionFunction :: WindowPrompt -> ComplFunction Source #

modeAction :: WindowPrompt -> String -> String -> X () Source #

XPrompt RunOrRaisePrompt Source # |

Instance details

Defined in XMonad.Prompt.RunOrRaise

Methods

showXPrompt :: RunOrRaisePrompt -> String Source #

nextCompletion :: RunOrRaisePrompt -> String -> [String] -> String Source #

commandToComplete :: RunOrRaisePrompt -> String -> String Source #

completionToCommand :: RunOrRaisePrompt -> String -> String Source #

completionFunction :: RunOrRaisePrompt -> ComplFunction Source #

modeAction :: RunOrRaisePrompt -> String -> String -> X () Source #

XPrompt Man Source # |
Instance details Defined in XMonad.Prompt.Man Methods showXPrompt :: Man -> String Source # nextCompletion :: Man -> String -> [String] -> String Source # commandToComplete :: Man -> String -> String Source # completionToCommand :: Man -> String -> String Source # completionFunction :: Man -> ComplFunction Source # modeAction :: Man -> String -> String -> X () Source #
XPrompt InputPrompt Source # |

Instance details

Defined in XMonad.Prompt.Input

Methods

showXPrompt :: InputPrompt -> String Source #

nextCompletion :: InputPrompt -> String -> [String] -> String Source #

commandToComplete :: InputPrompt -> String -> String Source #

completionToCommand :: InputPrompt -> String -> String Source #

completionFunction :: InputPrompt -> ComplFunction Source #

modeAction :: InputPrompt -> String -> String -> X () Source #

XPrompt Dir Source # |
Instance details Defined in XMonad.Prompt.Directory Methods showXPrompt :: Dir -> String Source # nextCompletion :: Dir -> String -> [String] -> String Source # commandToComplete :: Dir -> String -> String Source # completionToCommand :: Dir -> String -> String Source # completionFunction :: Dir -> ComplFunction Source # modeAction :: Dir -> String -> String -> X () Source #
XPrompt DirExec Source # |
Instance details Defined in XMonad.Prompt.DirExec Methods showXPrompt :: DirExec -> String Source # nextCompletion :: DirExec -> String -> [String] -> String Source # commandToComplete :: DirExec -> String -> String Source # completionToCommand :: DirExec -> String -> String Source # completionFunction :: DirExec -> ComplFunction Source # modeAction :: DirExec -> String -> String -> X () Source #
XPrompt EnterPrompt Source # |

Instance details

Defined in XMonad.Prompt.ConfirmPrompt

Methods

showXPrompt :: EnterPrompt -> String Source #

nextCompletion :: EnterPrompt -> String -> [String] -> String Source #

commandToComplete :: EnterPrompt -> String -> String Source #

completionToCommand :: EnterPrompt -> String -> String Source #

completionFunction :: EnterPrompt -> ComplFunction Source #

modeAction :: EnterPrompt -> String -> String -> X () Source #

XPrompt AppendFile Source # |

Instance details

Defined in XMonad.Prompt.AppendFile

Methods

showXPrompt :: AppendFile -> String Source #

nextCompletion :: AppendFile -> String -> [String] -> String Source #

commandToComplete :: AppendFile -> String -> String Source #

completionToCommand :: AppendFile -> String -> String Source #

completionFunction :: AppendFile -> ComplFunction Source #

modeAction :: AppendFile -> String -> String -> X () Source #

XPrompt AppPrompt Source # |

Instance details

Defined in XMonad.Prompt.AppLauncher

Methods

showXPrompt :: AppPrompt -> String Source #

nextCompletion :: AppPrompt -> String -> [String] -> String Source #

commandToComplete :: AppPrompt -> String -> String Source #

completionToCommand :: AppPrompt -> String -> String Source #

completionFunction :: AppPrompt -> ComplFunction Source #

modeAction :: AppPrompt -> String -> String -> X () Source #

XPrompt TagPrompt Source # |

Instance details

Defined in XMonad.Actions.TagWindows

Methods

showXPrompt :: TagPrompt -> String Source #

nextCompletion :: TagPrompt -> String -> [String] -> String Source #

commandToComplete :: TagPrompt -> String -> String Source #

completionToCommand :: TagPrompt -> String -> String Source #

completionFunction :: TagPrompt -> ComplFunction Source #

modeAction :: TagPrompt -> String -> String -> X () Source #

XPrompt WSGPrompt Source # |

Instance details

Defined in XMonad.Actions.DynamicWorkspaceGroups

Methods

showXPrompt :: WSGPrompt -> String Source #

nextCompletion :: WSGPrompt -> String -> [String] -> String Source #

commandToComplete :: WSGPrompt -> String -> String Source #

completionToCommand :: WSGPrompt -> String -> String Source #

completionFunction :: WSGPrompt -> ComplFunction Source #

modeAction :: WSGPrompt -> String -> String -> X () Source #

XPrompt Search Source # |
Instance details Defined in XMonad.Actions.Search Methods showXPrompt :: Search -> String Source # nextCompletion :: Search -> String -> [String] -> String Source # commandToComplete :: Search -> String -> String Source # completionToCommand :: Search -> String -> String Source # completionFunction :: Search -> ComplFunction Source # modeAction :: Search -> String -> String -> X () Source #
XPrompt ThemePrompt Source # |

Instance details

Defined in XMonad.Prompt.Theme

Methods

showXPrompt :: ThemePrompt -> String Source #

nextCompletion :: ThemePrompt -> String -> [String] -> String Source #

commandToComplete :: ThemePrompt -> String -> String Source #

completionToCommand :: ThemePrompt -> String -> String Source #

completionFunction :: ThemePrompt -> ComplFunction Source #

modeAction :: ThemePrompt -> String -> String -> X () Source #

type XP = StateT XPState IO Source #

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

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

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

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

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.

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

insertString :: String -> XP () Source #

Insert a character at the cursor position

pasteString :: XP () Source #

Insert the current X selection string at the cursor position.

moveCursor :: Direction1D -> XP () Source #

move the cursor one position

setInput :: String -> XP () Source #

Sets the input string to the given value.

getInput :: XP String Source #

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

moveWord :: Direction1D -> XP () Source #

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

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

Move the cursor one word, given a predicate to identify non-word characters. First move past any consecutive non-word characters; then move to just before the next non-word character.

killWord :: Direction1D -> XP () Source #

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

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

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.

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 |

Instances

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

type ComplFunction = String -> IO [String] Source #

# X Utilities

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

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

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

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

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

skipLastWord :: String -> String Source #

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.

historyCompletion :: ComplFunction Source #

`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 :: (String -> Bool) -> ComplFunction Source #

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

# History filters

deleteAllDuplicates :: [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.

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.

data HistoryMatches Source #

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

Initializes a new HistoryMatches structure to be passed to historyUpMatching

historyUpMatching :: HistoryMatches -> XP () Source #

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

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