aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad
diff options
context:
space:
mode:
authorAdam Vogt <vogt.adam@gmail.com>2015-03-10 19:10:36 +0100
committerAdam Vogt <vogt.adam@gmail.com>2015-03-10 19:10:36 +0100
commit1669ca112fc534833537d8fcf1fac31a443c7aa6 (patch)
treec1b4880aa97d5598eb1df0a674e9f5d6f00996db /XMonad
parent3080d581602127eab35dbe49a85b1e3e719c97ae (diff)
downloadXMonadContrib-1669ca112fc534833537d8fcf1fac31a443c7aa6.tar.gz
XMonadContrib-1669ca112fc534833537d8fcf1fac31a443c7aa6.tar.xz
XMonadContrib-1669ca112fc534833537d8fcf1fac31a443c7aa6.zip
add ConfirmPrompt (Antoine Beaupré)
Ignore-this: 65d74f05e82c66a3ff4f021d19ceb626 darcs-hash:20150310181036-1499c-1b9af832d4eefa7806e03aae86aa72868341e136.gz
Diffstat (limited to 'XMonad')
-rw-r--r--XMonad/Prompt/ConfirmPrompt.hs51
1 files changed, 51 insertions, 0 deletions
diff --git a/XMonad/Prompt/ConfirmPrompt.hs b/XMonad/Prompt/ConfirmPrompt.hs
new file mode 100644
index 0000000..650b62a
--- /dev/null
+++ b/XMonad/Prompt/ConfirmPrompt.hs
@@ -0,0 +1,51 @@
+-----------------------------------------------------------------------------
+-- |
+-- Module : XMonad.Prompt.ConfirmPrompt
+-- Copyright : (C) 2015 Antoine Beaupré
+-- License : BSD3
+--
+-- Maintainer : Antoine Beaupré <anarcat@debian.org>
+-- Stability : unstable
+-- Portability : unportable
+--
+-- A module for setting up simple confirmation prompts for keybindings.
+--
+-----------------------------------------------------------------------------
+module XMonad.Prompt.ConfirmPrompt (confirmPrompt
+ -- * Usage
+ -- $usage
+ , module XMonad.Prompt
+ -- * Use case: confirming exit
+ -- $tip
+ , EnterPrompt
+ ) where
+
+import XMonad (X)
+import XMonad.Prompt (XPConfig, XPrompt, showXPrompt, mkXPrompt, mkComplFunFromList)
+
+{- $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 'XMonad.Prompt' primitives. The action
+will then run normally if the user confirms.
+-}
+
+{- $tip
+This should be used something like this:
+
+> ...
+> , ((modm , xK_l), confirmPrompt defaultXPConfig "exit" $ io (exitWith ExitSuccess))
+> ...
+-}
+
+{- | Customized 'XPrompt' prompt that will ask to confirm the given string -}
+data EnterPrompt = EnterPrompt String
+instance XPrompt EnterPrompt where
+ showXPrompt (EnterPrompt n) = "Confirm " ++ n ++ " (esc/ENTER)"
+
+{- | 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.-}
+confirmPrompt :: XPConfig -> String -> X() -> X()
+confirmPrompt config app func = mkXPrompt (EnterPrompt app) config (mkComplFunFromList []) $ const func