clipboard

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package clipboard accesses the host system clipboard.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MIMEToXclipTarget

func MIMEToXclipTarget(mime string) string

MIMEToXclipTarget converts a MIME type to an xclip -target value.

func WriteText added in v0.9.0

func WriteText(data []byte) (err error)

WriteText replaces the host clipboard with text copied inside the container.

Types

type Bridge added in v0.9.0

type Bridge struct {
	// contains filtered or unexported fields
}

Bridge serializes host paste and container copy operations. A paste echoed back by the X11 watcher must not overwrite a newer host clipboard selection.

func NewBridge added in v0.9.0

func NewBridge(writeContainer func(context.Context, []byte, string) error) *Bridge

func (*Bridge) Close added in v0.9.0

func (b *Bridge) Close()

Close prevents in-flight watcher callbacks from writing after detach.

func (*Bridge) Copy added in v0.9.0

func (b *Bridge) Copy(data []byte) error

Copy applies a container clipboard change to the host. Consume the paste echo once: a later agent copy of the same text must still update the host clipboard.

func (*Bridge) Paste added in v0.9.0

func (b *Bridge) Paste(ctx context.Context) error

Paste transfers the host clipboard before forwarding Ctrl+V to the agent.

type Content

type Content struct {
	Data     []byte
	MIMEType string // e.g., "text/plain", "image/png"
}

Content holds clipboard data and its MIME type.

func Read

func Read() (content *Content, err error)

Read reads the current clipboard content from the host. Returns nil Content if the clipboard is empty. Returns an error if the clipboard is unavailable on this platform.

func (*Content) IsImage

func (c *Content) IsImage() bool

IsImage returns true if the content is an image type.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL