summaryrefslogtreecommitdiff
path: root/internal/util/clipboard.go
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2024-11-24 01:10:15 -0500
committerGitHub <noreply@github.com>2024-11-24 01:10:15 -0500
commitd92c9c601e1ef8c183562c94141db493de50921f (patch)
tree6caffa28f14f92be4711c91887c83db74f4460af /internal/util/clipboard.go
parentf66e718496fdc5c9a9bac1c281ba8e9f3f825791 (diff)
Remove useless code and implement clipboard functionality (#1)
* Remove dead code * Implement clipboard * Improve Stringer color interfaces
Diffstat (limited to 'internal/util/clipboard.go')
-rw-r--r--internal/util/clipboard.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/util/clipboard.go b/internal/util/clipboard.go
new file mode 100644
index 0000000..4aaf828
--- /dev/null
+++ b/internal/util/clipboard.go
@@ -0,0 +1,18 @@
+package util
+
+import (
+ "log/slog"
+
+ "golang.design/x/clipboard"
+)
+
+// Copies any object that has the Stringer interface to the clipboard
+func Copy(str string) {
+ // Initialize the clipboard
+ if err := clipboard.Init(); err != nil {
+ slog.Error("failed to initialize clipboard", "error", err)
+ return
+ }
+
+ clipboard.Write(clipboard.FmtText, []byte(str))
+}