adds a weird function to XSelection

This enables you to pass a function of (String -> String) to a selection function to modify the string before executing it.  This way, you can input your own escape routines to make it shell command line safe, and/or do other fancier things.
This commit is contained in:
loupgaroublond
2008-12-22 02:07:30 +00:00
parent f3617e75c5
commit 44b9610906

View File

@@ -20,6 +20,8 @@ module XMonad.Util.XSelection ( -- * Usage
getSelection,
promptSelection,
safePromptSelection,
modifySelectionAndSafePromptSelection,
modifySelectionAndUnsafePromptSelection,
putSelection) where
import Control.Concurrent (forkIO)
@@ -172,3 +174,7 @@ promptSelection, safePromptSelection, unsafePromptSelection :: String -> X ()
promptSelection = unsafePromptSelection
safePromptSelection app = join $ io $ liftM (safeSpawn app) getSelection
unsafePromptSelection app = join $ io $ liftM unsafeSpawn $ fmap (\x -> app ++ " " ++ x) getSelection
modifySelectionAndSafePromptSelection, modifySelectionAndUnsafePromptSelection :: (String -> String) -> String -> X ()
modifySelectionAndSafePromptSelection f app = join $ io $ liftM (safeSpawn app) (fmap f getSelection)
modifySelectionAndUnsafePromptSelection f app = join $ io $ liftM unsafeSpawn $ fmap (\x -> app ++ " " ++ x) (fmap f getSelection)