-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
63 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{-# OPTIONS_HADDOCK show-extensions #-} | ||
|
||
-- | | ||
-- Module : Yi.Clip | ||
-- License : GPL-2 | ||
-- Maintainer : [email protected] | ||
-- Stability : experimental | ||
-- Portability : portable | ||
-- | ||
-- A proxy of clipboard. | ||
|
||
module Yi.Clip ( setClipboard | ||
, getClipboard | ||
) | ||
where | ||
|
||
import qualified System.Hclip as H (getClipboard, setClipboard) | ||
import Data.IORef | ||
import System.IO.Unsafe | ||
|
||
import Yi.Types (configDisableSystemClipboard, askCfg) | ||
import Yi.Utils (io) | ||
import Yi.Keymap (YiM) | ||
|
||
clipboard :: IORef String | ||
clipboard = unsafePerformIO $ newIORef "" | ||
|
||
getClipboard' :: IO String | ||
getClipboard' = readIORef clipboard | ||
|
||
setClipboard' :: String -> IO () | ||
setClipboard' = writeIORef clipboard | ||
|
||
getClipboard :: YiM String | ||
getClipboard = do | ||
config <- askCfg | ||
if configDisableSystemClipboard config | ||
then io getClipboard' | ||
else io H.getClipboard | ||
|
||
setClipboard :: String -> YiM () | ||
setClipboard text = do | ||
config <- askCfg | ||
if configDisableSystemClipboard config | ||
then io $ setClipboard' text | ||
else io $ H.setClipboard text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters