Made the clipboard API a bit better
This should work better with the X clipboard system better when I eventually make use of that.
This commit is contained in:
parent
44b9a1e717
commit
2c55824920
@ -22,11 +22,10 @@ type Backend interface {
|
||||
NewWindow (width, height int) (window Window, err error)
|
||||
|
||||
// Copy puts data into the clipboard.
|
||||
Copy (data Data)
|
||||
Copy (Data)
|
||||
|
||||
// Paste returns the data currently in the clipboard. This method may
|
||||
// return nil.
|
||||
Paste () (data Data)
|
||||
// Paste returns the data currently in the clipboard.
|
||||
Paste (accept []Mime) (Data)
|
||||
}
|
||||
|
||||
// BackendFactory represents a function capable of constructing a backend
|
||||
|
@ -88,7 +88,7 @@ func (backend *Backend) Copy (data tomo.Data) {
|
||||
|
||||
// Paste returns the data currently in the clipboard. This method may
|
||||
// return nil. This method is not yet implemented and will do nothing!
|
||||
func (backend *Backend) Paste () (data tomo.Data) {
|
||||
func (backend *Backend) Paste (accept []tomo.Mime) (data tomo.Data) {
|
||||
backend.assert()
|
||||
// TODO
|
||||
return
|
||||
|
19
data.go
19
data.go
@ -2,18 +2,9 @@ package tomo
|
||||
|
||||
import "io"
|
||||
|
||||
// Data represents drag-and-drop, selection, or clipboard data.
|
||||
type Data interface {
|
||||
io.Reader
|
||||
|
||||
// Mime returns the MIME type of the data, such as text/plain,
|
||||
// text/html, image/png, etc.
|
||||
Mime () (mimeType Mime)
|
||||
|
||||
// Convert attempts to convert the data to another MIME type. If the
|
||||
// data could not be converted, it should return an error.
|
||||
Convert (to Mime) (converted Data, err error)
|
||||
}
|
||||
// Data represents arbitrary polymorphic data that can be used for data transfer
|
||||
// between applications.
|
||||
type Data map[Mime] io.ReadCloser
|
||||
|
||||
// Mime represents a MIME type.
|
||||
type Mime struct {
|
||||
@ -23,3 +14,7 @@ type Mime struct {
|
||||
// Mime { Type: "text", Subtype: "html" }
|
||||
Type, Subtype string
|
||||
}
|
||||
|
||||
var MimePlain = Mime { "text", "plain" }
|
||||
|
||||
var MimeFile = Mime { "text", "uri-list" }
|
||||
|
4
tomo.go
4
tomo.go
@ -48,7 +48,7 @@ func Copy (data Data) {
|
||||
|
||||
// Paste returns the data currently in the clipboard. This method may
|
||||
// return nil.
|
||||
func Paste () (data Data) {
|
||||
func Paste (accept []Mime) (Data) {
|
||||
if backend == nil { panic("no backend is running") }
|
||||
return backend.Paste()
|
||||
return backend.Paste(accept)
|
||||
}
|
||||
|
Reference in New Issue
Block a user