From 58fcfaadf83cc655e119a292a4eb5dfe701d9574 Mon Sep 17 00:00:00 2001 From: Daniel Schoepe Date: Sat, 31 Oct 2009 00:50:33 +0100 Subject: Add functions to access the current input in X.Prompt Ignore-this: 3f568c1266d85dcaa5722b19bbbd61dd darcs-hash:20091030235033-7f603-2da8ee80df7406b09d279592804adc37f3e14ab2.gz --- XMonad/Prompt.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'XMonad/Prompt.hs') diff --git a/XMonad/Prompt.hs b/XMonad/Prompt.hs index 90e8685..94dc133 100644 --- a/XMonad/Prompt.hs +++ b/XMonad/Prompt.hs @@ -30,6 +30,7 @@ module XMonad.Prompt , quit , killBefore, killAfter, startOfLine, endOfLine , pasteString, moveCursor + , setInput, getInput , moveWord, killWord, deleteString , moveHistory, setSuccess, setDone , Direction1D(..) @@ -247,6 +248,15 @@ command = W.focus . commandHistory setCommand :: String -> XPState -> XPState setCommand xs s = s { commandHistory = (commandHistory s) { W.focus = xs }} +-- | Sets the input string to the given value. +setInput :: String -> XP () +setInput = modify . setCommand + +-- | Returns the current input string. Intented for use in custom keymaps +-- where the 'get' or similar can't be used to retrieve it. +getInput :: XP String +getInput = gets command + -- | 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@ -- cgit v1.2.3