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

Copyright | (C) 2015 Antoine Beaupré
License | BSD3
Maintainer | Antoine Beaupré <anarcat@debian.org>
Stability | unstable
Portability | unportable
Safe Haskell | None
Language | Haskell2010

XMonad.Prompt.ConfirmPrompt

Contents

- Usage
- Use case: confirming exit

Description

A module for setting up simple confirmation prompts for keybindings.

Synopsis

- confirmPrompt :: XPConfig -> String -> X () -> X ()
- data XPConfig
- mkXPrompt :: XPrompt p => p -> XPConfig -> ComplFunction -> (String -> X ()) -> X ()
- class XPrompt t where
  - showXPrompt :: t -> String
- mkComplFunFromList :: XPConfig -> [String] -> String -> IO [String]
- data EnterPrompt

# Documentation

confirmPrompt :: XPConfig -> String -> X () -> X () #

Prompt the user to confirm a given action. We offer no completion and simply ask to confirm (ENTER) or cancel (ESCAPE). The actual key handling is done by mkXPrompt.

# Usage

This module makes it easy to add a confirmation prompt for specific actions. Instead of just running the action, a simple confirmation prompt will be created using `Prompt` primitives. The action will then run normally if the user confirms.

data XPConfig #

#### Instances

Instances details

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

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

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

Methods

showXPrompt :: t -> String #

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

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

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

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

# Use case: confirming exit

This should be used something like this:

    ...
    , ((modm , xK_l), confirmPrompt def "exit" $ io (exitWith ExitSuccess))
    ...

data EnterPrompt #

Customized `XPrompt` prompt that will ask to confirm the given string

#### Instances

Instances details

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