diff --git a/backend.go b/backend.go index 2b018f3..6ad3f70 100644 --- a/backend.go +++ b/backend.go @@ -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 diff --git a/backends/x/x.go b/backends/x/x.go index 10d9ea5..4fafc18 100644 --- a/backends/x/x.go +++ b/backends/x/x.go @@ -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 diff --git a/data.go b/data.go index af1778d..d5da9a3 100644 --- a/data.go +++ b/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" } diff --git a/tomo.go b/tomo.go index 52e93a7..5dc4dde 100644 --- a/tomo.go +++ b/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) }