Remove mobile clipboard management (this should be the responsibility of the GUI toolkit)

This commit is contained in:
2025-11-13 21:58:37 -05:00
parent 80cf65775a
commit 8d1dd48035
11 changed files with 13 additions and 76 deletions
-36
View File
@@ -1,36 +0,0 @@
//go:build (android && !termux) || ios
package clip
import (
"strings"
"time"
"github.com/rwinkhart/go-boilerplate/back"
"golang.design/x/clipboard"
)
// ClipClearProcess clears the clipboard after 30 seconds if the clipboard contents have not changed.
// assignedContents can be omitted to clear the clipboard immediately and unconditionally.
func ClipClearProcess(assignedContents string) error {
clearClipboard := func() {
clipboard.Write(clipboard.FmtText, []byte(""))
back.Exit(0)
}
// if assignedContents is empty, clear the clipboard immediately and unconditionally
if assignedContents == "" {
clearClipboard()
return nil
}
// wait 30 seconds before checking clipboard contents
time.Sleep(30 * time.Second)
newContents := clipboard.Read(clipboard.FmtText)
if assignedContents == strings.TrimRight(string(newContents), "\r\n") {
clearClipboard()
}
return nil
}
+2 -2
View File
@@ -10,14 +10,14 @@ import (
)
// CopyString copies a string to the clipboard.
func CopyString(continuous bool, copySubject string) error {
func CopyString(clearClipboardAutomatically bool, copySubject string) error {
cmd := exec.Command("pbcopy")
_ = back.WriteToStdin(cmd, copySubject)
err := cmd.Run()
if err != nil {
return errors.New("unable to copy to clipboard: " + err.Error())
}
if !continuous {
if clearClipboardAutomatically {
LaunchClipClearProcess(copySubject)
}
return nil
-16
View File
@@ -1,16 +0,0 @@
//go:build (android && !termux) || ios
package clip
import (
"golang.design/x/clipboard"
)
// CopyString copies a string to the clipboard.
func CopyString(continuous bool, copySubject string) error {
clipboard.Write(clipboard.FmtText, []byte(copySubject))
if !continuous {
LaunchClipClearProcess(copySubject)
}
return nil
}
+2 -2
View File
@@ -10,14 +10,14 @@ import (
)
// CopyString copies a string to the clipboard.
func CopyString(continuous bool, copySubject string) error {
func CopyString(clearClipboardAutomatically bool, copySubject string) error {
cmd := exec.Command("termux-clipboard-set")
_ = back.WriteToStdin(cmd, copySubject)
err := cmd.Run()
if err != nil {
return errors.New("unable to copy to clipboard: " + err.Error())
}
if !continuous {
if clearClipboardAutomatically {
LaunchClipClearProcess(copySubject)
}
return nil
+2 -2
View File
@@ -11,7 +11,7 @@ import (
)
// CopyString copies a string to the clipboard.
func CopyString(continuous bool, copySubject string) error {
func CopyString(clearClipboardAutomatically bool, copySubject string) error {
// determine whether to use wl-copy (Wayland) or xclip (X11)
var envSet, isWayland bool // track whether environment variables are set
var cmdCopy *exec.Cmd
@@ -29,7 +29,7 @@ func CopyString(continuous bool, copySubject string) error {
if err != nil {
return errors.New("unable to copy to clipboard: " + err.Error())
}
if !continuous {
if clearClipboardAutomatically {
LaunchClipClearProcess(copySubject, isWayland)
}
return nil
+2 -2
View File
@@ -10,13 +10,13 @@ import (
)
// CopyString copies a string to the clipboard.
func CopyString(continuous bool, copySubject string) error {
func CopyString(clearClipboardAutomatically bool, copySubject string) error {
cmd := exec.Command("powershell.exe", "-c", fmt.Sprintf("echo '%s' | Set-Clipboard", strings.ReplaceAll(copySubject, "'", "''")))
err := cmd.Run()
if err != nil {
return errors.New("unable to copy to clipboard: " + err.Error())
}
if !continuous {
if clearClipboardAutomatically {
LaunchClipClearProcess(copySubject)
}
return nil
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build (windows || darwin || android || ios || termux || wsl) && !interactive
//go:build (windows || wsl || (darwin && !ios) || (android && termux)) && !interactive
package clip
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build (windows || darwin || android || ios || termux || wsl) && interactive
//go:build (windows || wsl || (darwin && !ios) || (android && termux)) && interactive
package clip