mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-23 12:18:51 +02:00
Merge pull request #2567 from jesseduffield/bump-clipboard-package
This commit is contained in:
commit
b17c38befd
2
go.mod
2
go.mod
@ -4,7 +4,7 @@ go 1.18
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/OpenPeeDeeP/xdg v1.0.0
|
github.com/OpenPeeDeeP/xdg v1.0.0
|
||||||
github.com/atotto/clipboard v0.1.2
|
github.com/atotto/clipboard v0.1.4
|
||||||
github.com/aybabtme/humanlog v0.4.1
|
github.com/aybabtme/humanlog v0.4.1
|
||||||
github.com/cli/safeexec v1.0.0
|
github.com/cli/safeexec v1.0.0
|
||||||
github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21
|
github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21
|
||||||
|
2
go.sum
2
go.sum
@ -8,6 +8,8 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd
|
|||||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
|
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
|
||||||
github.com/atotto/clipboard v0.1.2 h1:YZCtFu5Ie8qX2VmVTBnrqLSiU9XOWwqNRmdT3gIQzbY=
|
github.com/atotto/clipboard v0.1.2 h1:YZCtFu5Ie8qX2VmVTBnrqLSiU9XOWwqNRmdT3gIQzbY=
|
||||||
github.com/atotto/clipboard v0.1.2/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
|
github.com/atotto/clipboard v0.1.2/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
|
||||||
|
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
|
||||||
|
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
|
||||||
github.com/aybabtme/humanlog v0.4.1 h1:D8d9um55rrthJsP8IGSHBcti9lTb/XknmDAX6Zy8tek=
|
github.com/aybabtme/humanlog v0.4.1 h1:D8d9um55rrthJsP8IGSHBcti9lTb/XknmDAX6Zy8tek=
|
||||||
github.com/aybabtme/humanlog v0.4.1/go.mod h1:B0bnQX4FTSU3oftPMTTPvENCy8LqixLDvYJA9TUCAGo=
|
github.com/aybabtme/humanlog v0.4.1/go.mod h1:B0bnQX4FTSU3oftPMTTPvENCy8LqixLDvYJA9TUCAGo=
|
||||||
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I=
|
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I=
|
||||||
|
42
vendor/github.com/atotto/clipboard/clipboard_plan9.go
generated
vendored
Normal file
42
vendor/github.com/atotto/clipboard/clipboard_plan9.go
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// Copyright 2013 @atotto. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build plan9
|
||||||
|
|
||||||
|
package clipboard
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"io/ioutil"
|
||||||
|
)
|
||||||
|
|
||||||
|
func readAll() (string, error) {
|
||||||
|
f, err := os.Open("/dev/snarf")
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
str, err := ioutil.ReadAll(f)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(str), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeAll(text string) error {
|
||||||
|
f, err := os.OpenFile("/dev/snarf", os.O_WRONLY, 0666)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
_, err = f.Write([]byte(text))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
32
vendor/github.com/atotto/clipboard/clipboard_unix.go
generated
vendored
32
vendor/github.com/atotto/clipboard/clipboard_unix.go
generated
vendored
@ -15,14 +15,17 @@ import (
|
|||||||
const (
|
const (
|
||||||
xsel = "xsel"
|
xsel = "xsel"
|
||||||
xclip = "xclip"
|
xclip = "xclip"
|
||||||
wlcopy = "wl-copy"
|
powershellExe = "powershell.exe"
|
||||||
wlpaste = "wl-paste"
|
clipExe = "clip.exe"
|
||||||
|
wlcopy = "wl-copy"
|
||||||
|
wlpaste = "wl-paste"
|
||||||
termuxClipboardGet = "termux-clipboard-get"
|
termuxClipboardGet = "termux-clipboard-get"
|
||||||
termuxClipboardSet = "termux-clipboard-set"
|
termuxClipboardSet = "termux-clipboard-set"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
Primary bool
|
Primary bool
|
||||||
|
trimDos bool
|
||||||
|
|
||||||
pasteCmdArgs []string
|
pasteCmdArgs []string
|
||||||
copyCmdArgs []string
|
copyCmdArgs []string
|
||||||
@ -33,8 +36,11 @@ var (
|
|||||||
xclipPasteArgs = []string{xclip, "-out", "-selection", "clipboard"}
|
xclipPasteArgs = []string{xclip, "-out", "-selection", "clipboard"}
|
||||||
xclipCopyArgs = []string{xclip, "-in", "-selection", "clipboard"}
|
xclipCopyArgs = []string{xclip, "-in", "-selection", "clipboard"}
|
||||||
|
|
||||||
|
powershellExePasteArgs = []string{powershellExe, "Get-Clipboard"}
|
||||||
|
clipExeCopyArgs = []string{clipExe}
|
||||||
|
|
||||||
wlpasteArgs = []string{wlpaste, "--no-newline"}
|
wlpasteArgs = []string{wlpaste, "--no-newline"}
|
||||||
wlcopyArgs = []string{wlcopy}
|
wlcopyArgs = []string{wlcopy}
|
||||||
|
|
||||||
termuxPasteArgs = []string{termuxClipboardGet}
|
termuxPasteArgs = []string{termuxClipboardGet}
|
||||||
termuxCopyArgs = []string{termuxClipboardSet}
|
termuxCopyArgs = []string{termuxClipboardSet}
|
||||||
@ -44,8 +50,8 @@ var (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if os.Getenv("WAYLAND_DISPLAY") != "" {
|
if os.Getenv("WAYLAND_DISPLAY") != "" {
|
||||||
pasteCmdArgs = wlpasteArgs;
|
pasteCmdArgs = wlpasteArgs
|
||||||
copyCmdArgs = wlcopyArgs;
|
copyCmdArgs = wlcopyArgs
|
||||||
|
|
||||||
if _, err := exec.LookPath(wlcopy); err == nil {
|
if _, err := exec.LookPath(wlcopy); err == nil {
|
||||||
if _, err := exec.LookPath(wlpaste); err == nil {
|
if _, err := exec.LookPath(wlpaste); err == nil {
|
||||||
@ -77,6 +83,16 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pasteCmdArgs = powershellExePasteArgs
|
||||||
|
copyCmdArgs = clipExeCopyArgs
|
||||||
|
trimDos = true
|
||||||
|
|
||||||
|
if _, err := exec.LookPath(clipExe); err == nil {
|
||||||
|
if _, err := exec.LookPath(powershellExe); err == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Unsupported = true
|
Unsupported = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +119,11 @@ func readAll() (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return string(out), nil
|
result := string(out)
|
||||||
|
if trimDos && len(result) > 1 {
|
||||||
|
result = result[:len(result)-2]
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeAll(text string) error {
|
func writeAll(text string) error {
|
||||||
|
45
vendor/github.com/atotto/clipboard/clipboard_windows.go
generated
vendored
45
vendor/github.com/atotto/clipboard/clipboard_windows.go
generated
vendored
@ -7,6 +7,7 @@
|
|||||||
package clipboard
|
package clipboard
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@ -18,12 +19,13 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
user32 = syscall.MustLoadDLL("user32")
|
user32 = syscall.MustLoadDLL("user32")
|
||||||
openClipboard = user32.MustFindProc("OpenClipboard")
|
isClipboardFormatAvailable = user32.MustFindProc("IsClipboardFormatAvailable")
|
||||||
closeClipboard = user32.MustFindProc("CloseClipboard")
|
openClipboard = user32.MustFindProc("OpenClipboard")
|
||||||
emptyClipboard = user32.MustFindProc("EmptyClipboard")
|
closeClipboard = user32.MustFindProc("CloseClipboard")
|
||||||
getClipboardData = user32.MustFindProc("GetClipboardData")
|
emptyClipboard = user32.MustFindProc("EmptyClipboard")
|
||||||
setClipboardData = user32.MustFindProc("SetClipboardData")
|
getClipboardData = user32.MustFindProc("GetClipboardData")
|
||||||
|
setClipboardData = user32.MustFindProc("SetClipboardData")
|
||||||
|
|
||||||
kernel32 = syscall.NewLazyDLL("kernel32")
|
kernel32 = syscall.NewLazyDLL("kernel32")
|
||||||
globalAlloc = kernel32.NewProc("GlobalAlloc")
|
globalAlloc = kernel32.NewProc("GlobalAlloc")
|
||||||
@ -50,19 +52,27 @@ func waitOpenClipboard() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func readAll() (string, error) {
|
func readAll() (string, error) {
|
||||||
|
// LockOSThread ensure that the whole method will keep executing on the same thread from begin to end (it actually locks the goroutine thread attribution).
|
||||||
|
// Otherwise if the goroutine switch thread during execution (which is a common practice), the OpenClipboard and CloseClipboard will happen on two different threads, and it will result in a clipboard deadlock.
|
||||||
|
runtime.LockOSThread()
|
||||||
|
defer runtime.UnlockOSThread()
|
||||||
|
if formatAvailable, _, err := isClipboardFormatAvailable.Call(cfUnicodetext); formatAvailable == 0 {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
err := waitOpenClipboard()
|
err := waitOpenClipboard()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
defer closeClipboard.Call()
|
|
||||||
|
|
||||||
h, _, err := getClipboardData.Call(cfUnicodetext)
|
h, _, err := getClipboardData.Call(cfUnicodetext)
|
||||||
if h == 0 {
|
if h == 0 {
|
||||||
|
_, _, _ = closeClipboard.Call()
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
l, _, err := globalLock.Call(h)
|
l, _, err := globalLock.Call(h)
|
||||||
if l == 0 {
|
if l == 0 {
|
||||||
|
_, _, _ = closeClipboard.Call()
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,21 +80,31 @@ func readAll() (string, error) {
|
|||||||
|
|
||||||
r, _, err := globalUnlock.Call(h)
|
r, _, err := globalUnlock.Call(h)
|
||||||
if r == 0 {
|
if r == 0 {
|
||||||
|
_, _, _ = closeClipboard.Call()
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closed, _, err := closeClipboard.Call()
|
||||||
|
if closed == 0 {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
return text, nil
|
return text, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeAll(text string) error {
|
func writeAll(text string) error {
|
||||||
|
// LockOSThread ensure that the whole method will keep executing on the same thread from begin to end (it actually locks the goroutine thread attribution).
|
||||||
|
// Otherwise if the goroutine switch thread during execution (which is a common practice), the OpenClipboard and CloseClipboard will happen on two different threads, and it will result in a clipboard deadlock.
|
||||||
|
runtime.LockOSThread()
|
||||||
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
err := waitOpenClipboard()
|
err := waitOpenClipboard()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer closeClipboard.Call()
|
|
||||||
|
|
||||||
r, _, err := emptyClipboard.Call(0)
|
r, _, err := emptyClipboard.Call(0)
|
||||||
if r == 0 {
|
if r == 0 {
|
||||||
|
_, _, _ = closeClipboard.Call()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,6 +114,7 @@ func writeAll(text string) error {
|
|||||||
// been allocated using the function with the GMEM_MOVEABLE flag."
|
// been allocated using the function with the GMEM_MOVEABLE flag."
|
||||||
h, _, err := globalAlloc.Call(gmemMoveable, uintptr(len(data)*int(unsafe.Sizeof(data[0]))))
|
h, _, err := globalAlloc.Call(gmemMoveable, uintptr(len(data)*int(unsafe.Sizeof(data[0]))))
|
||||||
if h == 0 {
|
if h == 0 {
|
||||||
|
_, _, _ = closeClipboard.Call()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -104,25 +125,33 @@ func writeAll(text string) error {
|
|||||||
|
|
||||||
l, _, err := globalLock.Call(h)
|
l, _, err := globalLock.Call(h)
|
||||||
if l == 0 {
|
if l == 0 {
|
||||||
|
_, _, _ = closeClipboard.Call()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
r, _, err = lstrcpy.Call(l, uintptr(unsafe.Pointer(&data[0])))
|
r, _, err = lstrcpy.Call(l, uintptr(unsafe.Pointer(&data[0])))
|
||||||
if r == 0 {
|
if r == 0 {
|
||||||
|
_, _, _ = closeClipboard.Call()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
r, _, err = globalUnlock.Call(h)
|
r, _, err = globalUnlock.Call(h)
|
||||||
if r == 0 {
|
if r == 0 {
|
||||||
if err.(syscall.Errno) != 0 {
|
if err.(syscall.Errno) != 0 {
|
||||||
|
_, _, _ = closeClipboard.Call()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
r, _, err = setClipboardData.Call(cfUnicodetext, h)
|
r, _, err = setClipboardData.Call(cfUnicodetext, h)
|
||||||
if r == 0 {
|
if r == 0 {
|
||||||
|
_, _, _ = closeClipboard.Call()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
h = 0 // suppress deferred cleanup
|
h = 0 // suppress deferred cleanup
|
||||||
|
closed, _, err := closeClipboard.Call()
|
||||||
|
if closed == 0 {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -1,7 +1,7 @@
|
|||||||
# github.com/OpenPeeDeeP/xdg v1.0.0
|
# github.com/OpenPeeDeeP/xdg v1.0.0
|
||||||
## explicit
|
## explicit
|
||||||
github.com/OpenPeeDeeP/xdg
|
github.com/OpenPeeDeeP/xdg
|
||||||
# github.com/atotto/clipboard v0.1.2
|
# github.com/atotto/clipboard v0.1.4
|
||||||
## explicit
|
## explicit
|
||||||
github.com/atotto/clipboard
|
github.com/atotto/clipboard
|
||||||
# github.com/aybabtme/humanlog v0.4.1
|
# github.com/aybabtme/humanlog v0.4.1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user