Added x clipboard stub

It doesn't do anything yet but boy is it going to
This commit is contained in:
Sasha Koshka 2023-01-26 14:52:43 -05:00
parent 14adaa4552
commit 21c19363dd
3 changed files with 31 additions and 3 deletions

View File

@ -21,7 +21,7 @@ type Backend interface {
// interface.
NewWindow (width, height int) (window Window, err error)
// Copy puts data in the clipboard.
// Copy puts data into the clipboard.
Copy (data Data)
// Paste returns the data currently in the clipboard. This method may

View File

@ -79,6 +79,21 @@ func (backend *Backend) Do (callback func ()) {
backend.doChannel <- callback
}
// Copy puts data into the clipboard. This method is not yet implemented and
// will do nothing!
func (backend *Backend) Copy (data tomo.Data) {
backend.assert()
// TODO
}
// 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) {
backend.assert()
// TODO
return
}
func (backend *Backend) assert () {
if backend == nil { panic("nil backend") }
}

17
tomo.go
View File

@ -24,6 +24,7 @@ func Stop () {
// Do executes the specified callback within the main thread as soon as
// possible. This function can be safely called from other threads.
func Do (callback func ()) {
if backend == nil { panic("no backend is running") }
backend.Do(callback)
}
@ -36,6 +37,18 @@ func NewWindow (width, height int) (window Window, err error) {
err = errors.New("no backend is running.")
return
}
window, err = backend.NewWindow(width, height)
return
return backend.NewWindow(width, height)
}
// Copy puts data into the clipboard.
func Copy (data Data) {
if backend == nil { panic("no backend is running") }
backend.Copy(data)
}
// Paste returns the data currently in the clipboard. This method may
// return nil.
func Paste () (data Data) {
if backend == nil { panic("no backend is running") }
return backend.Paste()
}