Add xgbsel as dependency

This commit is contained in:
Sasha Koshka 2024-07-21 13:06:09 -04:00
parent 39a591e732
commit 19ca3e821a
3 changed files with 29 additions and 0 deletions

1
go.mod
View File

@ -6,6 +6,7 @@ require (
git.tebibyte.media/tomo/tomo v0.38.0
git.tebibyte.media/tomo/typeset v0.7.1
git.tebibyte.media/tomo/xgbkb v1.0.1
git.tebibyte.media/tomo/xgbsel/v2 v2.0.0-alpha.1
github.com/jezek/xgb v1.1.1
github.com/jezek/xgbutil v0.0.0-20231116234834-47f30c120111
golang.org/x/image v0.11.0

2
go.sum
View File

@ -5,6 +5,8 @@ git.tebibyte.media/tomo/typeset v0.7.1 h1:aZrsHwCG5ZB4f5CruRFsxLv5ezJUCFUFsQJJso
git.tebibyte.media/tomo/typeset v0.7.1/go.mod h1:PwDpSdBF3l/EzoIsa2ME7QffVVajnTHZN6l3MHEGe1g=
git.tebibyte.media/tomo/xgbkb v1.0.1 h1:b3HDUopjdQp1MZrb5Vpil4bOtk3NnNXtfQW27Blw2kE=
git.tebibyte.media/tomo/xgbkb v1.0.1/go.mod h1:P5Du0yo5hUsojchW08t+Mds0XPIJXwMi733ZfklzjRw=
git.tebibyte.media/tomo/xgbsel/v2 v2.0.0-alpha.1 h1:B9Z2UZzfHlZZUbKiz3WFOSMUgVO5FvH0bYQ1m0cC0dk=
git.tebibyte.media/tomo/xgbsel/v2 v2.0.0-alpha.1/go.mod h1:NIyIbAPQQbevOKDmkKRgIUizEcPFMYCR4unj/mvvXcA=
github.com/BurntSushi/freetype-go v0.0.0-20160129220410-b763ddbfe298 h1:1qlsVAQJXZHsaM8b6OLVo6muQUQd4CwkH/D3fnnbHXA=
github.com/BurntSushi/freetype-go v0.0.0-20160129220410-b763ddbfe298/go.mod h1:D+QujdIlUNfa0igpNMk6UIvlb6C252URs4yupRUV4lQ=
github.com/BurntSushi/graphics-go v0.0.0-20160129215708-b43f31a4a966 h1:lTG4HQym5oPKjL7nGs+csTgiDna685ZXjxijkne828g=

26
x/selection.go Normal file
View File

@ -0,0 +1,26 @@
package x
import "io"
import "strings"
import "git.tebibyte.media/tomo/xgbsel/v2"
import "git.tebibyte.media/tomo/tomo/data"
type selectionData struct {
data data.Data
}
func (this selectionData) Convert (target xgbsel.Target) (io.ReadSeekCloser, bool) {
mimeStr, _ := target.ToMime()
ty, subty, _ := strings.Cut(string(mimeStr), "/")
mime := data.M(ty, subty)
stream, ok := this.data[mime]
stream.Seek(0, io.SeekStart)
return stream, ok
}
func (this selectionData) Supported () (targets []xgbsel.Target) {
for mime := range this.data {
targets = append(targets, xgbsel.MimeToTargets(mime.String())...)
}
return targets
}