Last active
April 11, 2016 01:32
-
-
Save whamtet/7074148358b7f744dfcb152d3e597c31 to your computer and use it in GitHub Desktop.
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
(import java.awt.datatransfer.StringSelection) | |
(import java.awt.Toolkit) | |
(import java.awt.datatransfer.DataFlavor) | |
(defn to-clipboard [s] | |
(let [ | |
selection (StringSelection. s) | |
clipboard (.getSystemClipboard (Toolkit/getDefaultToolkit))] | |
(.setContents clipboard selection selection))) | |
(defn from-clipboard [] | |
(-> | |
(.getSystemClipboard (Toolkit/getDefaultToolkit)) | |
(.getContents nil) | |
(.getTransferData DataFlavor/stringFlavor))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment