mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 10:25:37 +00:00
io/input,io/clipboard: [API] replace WriteOp with command
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+10
-10
@@ -3,6 +3,8 @@
|
||||
package clipboard
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"gioui.org/internal/ops"
|
||||
"gioui.org/io/event"
|
||||
"gioui.org/op"
|
||||
@@ -13,25 +15,23 @@ type Event struct {
|
||||
Text string
|
||||
}
|
||||
|
||||
// WriteCmd copies Text to the clipboard.
|
||||
type WriteCmd struct {
|
||||
Type string
|
||||
Data io.ReadCloser
|
||||
}
|
||||
|
||||
// ReadOp requests the text of the clipboard, delivered to
|
||||
// the current handler through an Event.
|
||||
type ReadOp struct {
|
||||
Tag event.Tag
|
||||
}
|
||||
|
||||
// WriteOp copies Text to the clipboard.
|
||||
type WriteOp struct {
|
||||
Text string
|
||||
}
|
||||
|
||||
func (h ReadOp) Add(o *op.Ops) {
|
||||
data := ops.Write1(&o.Internal, ops.TypeClipboardReadLen, h.Tag)
|
||||
data[0] = byte(ops.TypeClipboardRead)
|
||||
}
|
||||
|
||||
func (h WriteOp) Add(o *op.Ops) {
|
||||
data := ops.Write1String(&o.Internal, ops.TypeClipboardWriteLen, h.Text)
|
||||
data[0] = byte(ops.TypeClipboardWrite)
|
||||
}
|
||||
|
||||
func (Event) ImplementsEvent() {}
|
||||
|
||||
func (WriteCmd) ImplementsCommand() {}
|
||||
|
||||
Reference in New Issue
Block a user