clippard (empty) → 0.1.0
raw patch · 4 files changed
+69/−0 lines, 4 filesdep +Clipboarddep +basedep +processsetup-changed
Dependencies added: Clipboard, base, process
Files
- LICENSE +7/−0
- Setup.hs +2/−0
- clippard.cabal +23/−0
- src/System/Clippard.hs +37/−0
+ LICENSE view
@@ -0,0 +1,7 @@+Copyright (c) 2012 Anthony Grimes++Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ clippard.cabal view
@@ -0,0 +1,23 @@+-- Initial clippard.cabal generated by cabal init. For further +-- documentation, see http://haskell.org/cabal/users-guide/++name: clippard+version: 0.1.0+synopsis: A simple Haskell library for copying text to the clipboard in a cross-platform way.+-- description: +homepage: https://github.com/Raynes/clippard+license: MIT+license-file: LICENSE+author: Anthony Grimes+maintainer: i@raynes.me+-- copyright: +category: System+build-type: Simple+cabal-version: >=1.8++library+ hs-source-dirs: src+ other-modules: System.Clippard+ if os(windows)+ build-depends: Clipboard ==2.2.0.1+ build-depends: base >=4.5 && < 4.7, process >=1.1.0
+ src/System/Clippard.hs view
@@ -0,0 +1,37 @@+{-# LANGUAGE CPP #-}+-- | A simple library fro copying to the clipboard.+module System.Clippard (paste) where++import System.Process+import System.Info (os)+import System.IO (hPutStr, hClose)+# if mingw32_HOST_OS+import System.Clipboard (setClipboardString) +#endif ++pasteOSX :: String -> IO ()+pasteOSX text = do+ (inp, _, _, _) <- runInteractiveCommand "pbcopy"+ hPutStr inp text+ hClose inp++pasteLinux :: String -> IO ()+pasteLinux text = do+ (inp, _, _, _) <- runInteractiveCommand "xclip"+ hPutStr inp text+ hClose inp++# ifdef mingw32_HOST_OS+pasteWindows :: String -> IO ()+pasteWindows = setClipboardString+# endif++-- | Paste text to the command-line. Automagically determines operating system.+paste :: String -> IO ()+paste =+ case os of+ "darwin" -> pasteOSX+ "linux" -> pasteLinux+# ifdef mingw32_HOST_OS+ _ -> pasteWindows+# endif