mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-08-28 04:46:42 -04:00
Fix build on many platforms
This commit is contained in:
+4
-4
@@ -9,10 +9,10 @@ import (
|
||||
"github.com/rwinkhart/go-boilerplate/back"
|
||||
)
|
||||
|
||||
// CopyString copies a string to the clipboard.
|
||||
func CopyString(clearClipboardAutomatically bool, copySubject string) error {
|
||||
// CopyBytes copies a byte slice to the clipboard.
|
||||
func CopyBytes(clearClipboardAutomatically bool, copySubject []byte) error {
|
||||
cmd := exec.Command("pbcopy")
|
||||
_ = back.WriteToStdin(cmd, copySubject)
|
||||
_ = back.WriteToStdinAndZeroizeInput(cmd, copySubject)
|
||||
if err := cmd.Run(); err != nil {
|
||||
return errors.New("unable to copy to clipboard: " + err.Error())
|
||||
}
|
||||
@@ -25,6 +25,6 @@ func CopyString(clearClipboardAutomatically bool, copySubject string) error {
|
||||
// getClipCommands returns the commands for pasting and clearing the clipboard contents.
|
||||
func getClipCommands() (*exec.Cmd, *exec.Cmd, error) {
|
||||
cmdClear := exec.Command("pbcopy")
|
||||
_ = back.WriteToStdin(cmdClear, "")
|
||||
_ = back.WriteToStdinAndZeroizeInput(cmdClear, nil)
|
||||
return exec.Command("pbpaste"), cmdClear, nil
|
||||
}
|
||||
|
||||
+4
-4
@@ -9,10 +9,10 @@ import (
|
||||
"github.com/rwinkhart/go-boilerplate/back"
|
||||
)
|
||||
|
||||
// CopyString copies a string to the clipboard.
|
||||
func CopyString(clearClipboardAutomatically bool, copySubject string) error {
|
||||
// CopyBytes copies a byte slice to the clipboard.
|
||||
func CopyBytes(clearClipboardAutomatically bool, copySubject []byte) error {
|
||||
cmd := exec.Command("termux-clipboard-set")
|
||||
_ = back.WriteToStdin(cmd, copySubject)
|
||||
_ = back.WriteToStdinAndZeroizeInput(cmd, copySubject)
|
||||
if err := cmd.Run(); err != nil {
|
||||
return errors.New("unable to copy to clipboard: " + err.Error())
|
||||
}
|
||||
@@ -25,6 +25,6 @@ func CopyString(clearClipboardAutomatically bool, copySubject string) error {
|
||||
// getClipCommands returns the commands for pasting and clearing the clipboard contents.
|
||||
func getClipCommands() (*exec.Cmd, *exec.Cmd, error) {
|
||||
cmdClear := exec.Command("termux-clipboard-set")
|
||||
_ = back.WriteToStdin(cmdClear, "")
|
||||
_ = back.WriteToStdinAndZeroizeInput(cmdClear, nil)
|
||||
return exec.Command("termux-clipboard-get"), cmdClear, nil
|
||||
}
|
||||
|
||||
+4
-4
@@ -9,10 +9,10 @@ import (
|
||||
"github.com/rwinkhart/go-boilerplate/back"
|
||||
)
|
||||
|
||||
// CopyString copies a string to the clipboard.
|
||||
func CopyString(clearClipboardAutomatically bool, copySubject string) error {
|
||||
// CopyBytes copies a byte slice to the clipboard.
|
||||
func CopyBytes(clearClipboardAutomatically bool, copySubject []byte) error {
|
||||
cmd := exec.Command("clip.exe")
|
||||
_ = back.WriteToStdin(cmd, copySubject)
|
||||
_ = back.WriteToStdinAndZeroizeInput(cmd, copySubject)
|
||||
if err := cmd.Run(); err != nil {
|
||||
return errors.New("unable to copy to clipboard: " + err.Error())
|
||||
}
|
||||
@@ -25,6 +25,6 @@ func CopyString(clearClipboardAutomatically bool, copySubject string) error {
|
||||
// getClipCommands returns the commands for pasting and clearing the clipboard contents.
|
||||
func getClipCommands() (*exec.Cmd, *exec.Cmd, error) {
|
||||
clearCMD := exec.Command("clip.exe")
|
||||
_ = back.WriteToStdin(clearCMD, "")
|
||||
_ = back.WriteToStdinAndZeroizeInput(clearCMD, nil)
|
||||
return exec.Command("powershell.exe", "-c", "Get-Clipboard"), clearCMD, nil
|
||||
}
|
||||
|
||||
@@ -5,6 +5,6 @@ package clip
|
||||
// LaunchClearProcess launches the timed clipboard clearing process.
|
||||
// For interactive GUI/TUI implementations, the clipboard clearing process is launched as a goroutine.
|
||||
// copySubject can be omitted to clear the clipboard immediately and unconditionally.
|
||||
func LaunchClearProcess(copySubject string) {
|
||||
func LaunchClearProcess(copySubject []byte) {
|
||||
go ClearProcess(copySubject)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user