clipboard #14

Merged
sashakoshka merged 17 commits from clipboard into main 2023-03-30 19:45:29 -06:00
2 changed files with 11 additions and 16 deletions
Showing only changes of commit 02a27447b9 - Show all commits

View File

@ -1,13 +1,13 @@
package elements
import "io"
import "image"
import "git.tebibyte.media/sashakoshka/tomo/data"
// Window represents a top-level container generated by the currently running
// backend. It can contain a single element. It is hidden by default, and must
// be explicitly shown with the Show() method.
type Window interface {
Parent
// Adopt sets the root element of the window. There can only be one of
// these at one time.
Adopt (Element)
@ -27,6 +27,15 @@ type Window interface {
// NewModal creates a new modal dialog window.
NewModal (width, height int) (window Window, err error)
// Copy puts data into the clipboard.
Copy (data.Data)
// Paste requests the data currently in the clipboard. When the data is
// available, it is sent on the returned channel. If there is no data on
// the clipboard matching the requested mime type, the channel will be
// sent nil.
Paste (accept data.Mime) <- chan io.Reader
// Show shows the window. The window starts off hidden, so this must be
// called after initial setup to make sure it is visible.

14
tomo.go
View File

@ -4,7 +4,6 @@ import "os"
import "io"
import "path/filepath"
import "git.tebibyte.media/sashakoshka/tomo/dirs"
import "git.tebibyte.media/sashakoshka/tomo/data"
import "git.tebibyte.media/sashakoshka/tomo/theme"
import "git.tebibyte.media/sashakoshka/tomo/config"
import "git.tebibyte.media/sashakoshka/tomo/elements"
@ -47,19 +46,6 @@ func NewWindow (width, height int) (window elements.MainWindow, err error) {
return backend.NewWindow(width, height)
}
// Copy puts data into the clipboard.
func Copy (data data.Data) {
assertBackend()
backend.Copy(data)
}
// Paste returns the data currently in the clipboard. This method may
// return nil.
func Paste (accept []data.Mime) (data.Data) {
assertBackend()
return backend.Paste(accept)
}
// SetTheme sets the theme of all open windows.
func SetTheme (theme theme.Theme) {
backend.SetTheme(theme)