diff --git a/go.mod b/go.mod index 568616a..5e7053f 100644 --- a/go.mod +++ b/go.mod @@ -23,8 +23,10 @@ require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/rivo/uniseg v0.2.0 // indirect github.com/spf13/pflag v1.0.5 // indirect + github.com/tiagomelo/go-clipboard v0.1.2-0.20250126153310-fcc1f95408cf // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect github.com/zclconf/go-cty v1.13.3 // indirect golang.org/x/mod v0.18.0 // indirect diff --git a/go.sum b/go.sum index 3a96455..3eed471 100644 --- a/go.sum +++ b/go.sum @@ -34,6 +34,8 @@ github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzC github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= @@ -51,6 +53,10 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/tiagomelo/go-clipboard v0.1.1 h1:nddQ5DsEnKW0KdzTILhbLpSq3e9y2dkJXEOtsMs6H7A= +github.com/tiagomelo/go-clipboard v0.1.1/go.mod h1:kXtjJBIMimZaGbxmcKZ8+JqK+acSNf5tAJiChlZBOr8= +github.com/tiagomelo/go-clipboard v0.1.2-0.20250126153310-fcc1f95408cf h1:csb/+rmJBAtOP6OP+9soTnwJVuhlUpedjb5dPlNZasY= +github.com/tiagomelo/go-clipboard v0.1.2-0.20250126153310-fcc1f95408cf/go.mod h1:kXtjJBIMimZaGbxmcKZ8+JqK+acSNf5tAJiChlZBOr8= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= diff --git a/lib/ya_darwin.go b/lib/ya_darwin.go deleted file mode 100644 index 39e974e..0000000 --- a/lib/ya_darwin.go +++ /dev/null @@ -1,7 +0,0 @@ -// +build darwin - -package lib - - -func setprimary() { -} diff --git a/lib/ya_unix.go b/lib/ya_unix.go deleted file mode 100644 index 6f05680..0000000 --- a/lib/ya_unix.go +++ /dev/null @@ -1,9 +0,0 @@ -// +build freebsd linux netbsd openbsd solaris dragonfly - -package lib - -import "github.com/atotto/clipboard" - -func setprimary() { - clipboard.Primary = true -} diff --git a/lib/ya_windows.go b/lib/ya_windows.go deleted file mode 100644 index 75cecfe..0000000 --- a/lib/ya_windows.go +++ /dev/null @@ -1,7 +0,0 @@ -// +build windows - -package lib - - -func setprimary() { -} diff --git a/lib/yank.go b/lib/yank.go index 7f4d755..39265d3 100644 --- a/lib/yank.go +++ b/lib/yank.go @@ -21,7 +21,7 @@ import ( "log" "strings" - "github.com/atotto/clipboard" + "github.com/tiagomelo/go-clipboard/clipboard" "github.com/tlinden/tablizer/cfg" ) @@ -43,8 +43,8 @@ func yankColumns(conf cfg.Config, data *Tabdata) { } if len(yank) > 0 { - setprimary() - if err := clipboard.WriteAll(strings.Join(yank, " ")); err != nil { + cb := clipboard.New(clipboard.ClipboardOptions{Primary: true}) + if err := cb.CopyText(strings.Join(yank, " ")); err != nil { log.Fatalln("error writing string to clipboard:", err) } } diff --git a/lib/yank_test.go b/lib/yank_test.go index b1c057a..748104b 100644 --- a/lib/yank_test.go +++ b/lib/yank_test.go @@ -22,7 +22,7 @@ import ( "fmt" "testing" - "github.com/atotto/clipboard" + "github.com/tiagomelo/go-clipboard/clipboard" "github.com/tlinden/tablizer/cfg" ) @@ -40,6 +40,8 @@ var yanktests = []struct { } func DISABLED_TestYankColumns(t *testing.T) { + cb := clipboard.New() + for _, testdata := range yanktests { testname := fmt.Sprintf("yank-%s-filter-%s", testdata.name, testdata.filter) @@ -56,7 +58,7 @@ func DISABLED_TestYankColumns(t *testing.T) { var writer bytes.Buffer printData(&writer, conf, &data) - got, err := clipboard.ReadAll() // hangs indefinetly + got, err := cb.PasteText() if err != nil { t.Errorf("failed to fetch yanked text from clipboard") }