Debian Codegraph @

clipboard/clipboard_supported_platforms.go

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 //go:build (darwin || linux || windows) && cgo
2 // +build darwin linux windows
3 // +build cgo
4
5 package clipboard
6
7 import (
8 "os"
9
10 "github.com/juju/errors"
11 "golang.design/x/clipboard"
12 )
13
14 var InitErr error = nil
15
16 // init is a wrapper around clipboard.Init, it only exists because
17 // clipboard.Init panics if it was built with CGO_ENABLED=0, but we want just
18 // an error, not a panic; therefore we have this wrapper guarded with build
19 // flags above.
20 func init() {
21 if os.Getenv("NERDLOG_NO_CLIPBOARD") != "" {
22 InitErr = errors.Errorf("clipboard is disabled via NERDLOG_NO_CLIPBOARD env var")
23 return
24 }
25
26 InitErr = errors.Trace(clipboard.Init())
27 }
28
29 // WriteText is a wrapper around clipboard.Write with FmtText; it exists so
30 // that we can avoid compiling it on unsupported platforms (e.g. FreeBSD) and
31 // still have nerdlog working (without clipboard support).
32 func WriteText(value []byte) {
33 clipboard.Write(clipboard.FmtText, value)
34 }