Added a little clipboard interface

This commit is contained in:
Sasha Koshka 2023-01-26 14:42:07 -05:00
parent 93019b1b38
commit 14adaa4552
2 changed files with 32 additions and 0 deletions

View File

@ -20,6 +20,13 @@ type Backend interface {
// and returns a struct representing it that fulfills the Window // and returns a struct representing it that fulfills the Window
// interface. // interface.
NewWindow (width, height int) (window Window, err error) NewWindow (width, height int) (window Window, err error)
// Copy puts data in the clipboard.
Copy (data Data)
// Paste returns the data currently in the clipboard. This method may
// return nil.
Paste () (data Data)
} }
// BackendFactory represents a function capable of constructing a backend // BackendFactory represents a function capable of constructing a backend

25
data.go Normal file
View File

@ -0,0 +1,25 @@
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)
}
// Mime represents a MIME type.
type Mime struct {
// Type is the first half of the MIME type, and Subtype is the second
// half. The separating slash is not included in either. For example,
// text/html becomes:
// Mime { Type: "text", Subtype: "html" }
Type, Subtype string
}