github.com/Seikaijyu/gio@v0.0.1/io/clipboard/clipboard.go (about)

     1  // SPDX-License-Identifier: Unlicense OR MIT
     2  
     3  package clipboard
     4  
     5  import (
     6  	"github.com/Seikaijyu/gio/internal/ops"
     7  	"github.com/Seikaijyu/gio/io/event"
     8  	"github.com/Seikaijyu/gio/op"
     9  )
    10  
    11  // Event is generated when the clipboard content is requested.
    12  type Event struct {
    13  	Text string
    14  }
    15  
    16  // ReadOp requests the text of the clipboard, delivered to
    17  // the current handler through an Event.
    18  type ReadOp struct {
    19  	Tag event.Tag
    20  }
    21  
    22  // WriteOp copies Text to the clipboard.
    23  type WriteOp struct {
    24  	Text string
    25  }
    26  
    27  func (h ReadOp) Add(o *op.Ops) {
    28  	data := ops.Write1(&o.Internal, ops.TypeClipboardReadLen, h.Tag)
    29  	data[0] = byte(ops.TypeClipboardRead)
    30  }
    31  
    32  func (h WriteOp) Add(o *op.Ops) {
    33  	data := ops.Write1String(&o.Internal, ops.TypeClipboardWriteLen, h.Text)
    34  	data[0] = byte(ops.TypeClipboardWrite)
    35  }
    36  
    37  func (Event) ImplementsEvent() {}