// +build clipboard all package main import "golang.design/x/clipboard" const clipboardIsOn = true var clipLib = vars{ "get-clipboard": func(a ...expression) expression { if clipboardErr != nil { return false } return string(clipboard.Read(clipboard.FmtText)) }, "set-clipboard": func(a ...expression) expression { if clipboardErr != nil { return false } if len(a) == 0 { return exception("'set-clipboard' expected a value to add to the clipboard, no value was given") } s := String(a[0], false) clipboard.Write(clipboard.FmtText, []byte(s)) return s }, "clipboard-available?": func(a ...expression) expression { if clipboardErr != nil { return false } return true }, } var clipUsageStrings = map[string]string{ "clipboard-available?": "(clipboard-available?) => bool\n\nReports whether clipboard access is available", "get-clipboard": "(get-clipboard) => string|#f\n\nRetrieves the string held in the current main system clipboard. This will not work as expected when run on a remote machine, as it relates to the clipboard of the system where the interpreter is being run. Returns the string held in the clipboard or #f if the clipboard was not available (see: `clipboard-available?`)", "set-clipboard": "(set-clipboard [value]) => string|#f\n\nSets the system clipboard to contain the string representation of the given value. Returns the string representation of the value or #f if the clipboard is not available (see: `clipboard-available?`)", }