Copyright | (C) 2015 Antoine Beaupré |
---|---|
License | BSD3 |
Maintainer | Antoine Beaupré <anarcat@debian.org> |
Stability | unstable |
Portability | unportable |
Safe Haskell | None |
Language | Haskell2010 |
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 () Source #
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.
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
()
class XPrompt t where Source #
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: "
showXPrompt :: t -> String Source #
This method is used to print the string to be displayed in the command line window.
Instances
mkComplFunFromList :: XPConfig -> [String] -> String -> IO [String] Source #
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 Source #
Customized XPrompt
prompt that will ask to confirm the given string
Instances
XPrompt EnterPrompt Source # | |
Defined in XMonad.Prompt.ConfirmPrompt 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 # |