Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/clipboard.lisp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
(in-package :lem-core)

(defun wsl-p ()
"Return t when we are using WSL."
(zerop (nth-value 2 (uiop:run-program '("which" "clip.exe") :ignore-error-status t))))

(defun sbcl-2.0.0-or-later-p ()
"Return t when we are using SBCL 2.0.0 or later."
(and (string-equal "sbcl" (lisp-implementation-type))
(let ((version (mapcar #'parse-integer
(uiop:split-string (lisp-implementation-version)
Expand All @@ -18,20 +20,28 @@
#-darwin (not (wsl-p))))

(defmacro with-enable-clipboard (value &body body)
"Execute BODY with clipboard enabled/disabled.

Argument VALUE is a boolean, and it will be set to enable/disable the clipboard."
`(let ((*enable-clipboard-p* ,value))
,@body))

(defun enable-clipboard ()
"Enable clipboard."
(setf *enable-clipboard-p* t))

(defun disable-clipboard ()
"Disable clipboard."
(setf *enable-clipboard-p* nil))

(defun enable-clipboard-p ()
"Return t if clipboard is enabled."
*enable-clipboard-p*)

(defun copy-to-clipboard (string)
"Save STRING to clipboard, so it lives on top of the stack."
(lem-if:clipboard-copy (implementation) string))

(defun get-clipboard-data ()
"Return the clipboard data."
(lem-if:clipboard-paste (implementation)))