mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-03 21:51:52 -07:00
Generalize XSelection functions to MonadIO
This commit is contained in:
@@ -57,8 +57,8 @@ import XMonad.Util.Run (safeSpawn, unsafeSpawn)
|
|||||||
|
|
||||||
-- | Returns a String corresponding to the current mouse selection in X; if there is none, an empty string is returned. Note that this is
|
-- | Returns a String corresponding to the current mouse selection in X; if there is none, an empty string is returned. Note that this is
|
||||||
-- really only reliable for ASCII text and currently escapes or otherwise mangles more complex UTF-8 characters.
|
-- really only reliable for ASCII text and currently escapes or otherwise mangles more complex UTF-8 characters.
|
||||||
getSelection :: IO String
|
getSelection :: MonadIO m => m String
|
||||||
getSelection = do
|
getSelection = io $ do
|
||||||
dpy <- openDisplay ""
|
dpy <- openDisplay ""
|
||||||
let dflt = defaultScreen dpy
|
let dflt = defaultScreen dpy
|
||||||
rootw <- rootWindow dpy dflt
|
rootw <- rootWindow dpy dflt
|
||||||
@@ -80,8 +80,8 @@ getSelection = do
|
|||||||
else destroyWindow dpy win >> return ""
|
else destroyWindow dpy win >> return ""
|
||||||
|
|
||||||
-- | Set the current X Selection to a given String.
|
-- | Set the current X Selection to a given String.
|
||||||
putSelection :: String -> IO ()
|
putSelection :: MonadIO m => String -> m ()
|
||||||
putSelection text = do
|
putSelection text = io $ do
|
||||||
dpy <- openDisplay ""
|
dpy <- openDisplay ""
|
||||||
let dflt = defaultScreen dpy
|
let dflt = defaultScreen dpy
|
||||||
rootw <- rootWindow dpy dflt
|
rootw <- rootWindow dpy dflt
|
||||||
|
Reference in New Issue
Block a user