clipboard

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package clipboard accesses the user's desktop clipboard and streams explicit file pastes.

Index

Constants

View Source
const MaxBytes int64 = 1 << 40
View Source
const MaxFiles = 128
View Source
const MaxText = 1 << 20
View Source
const OpenMethod = "clipboard.open"
View Source
const PasteMethod = "clipboard.paste"
View Source
const Protocol = "clipboard-v1"

Variables

This section is empty.

Functions

func CheckDestination

func CheckDestination(c Content, root *os.Root) error

CheckDestination rejects collisions before the sender starts reading file bytes.

func Copy

func Copy(ctx context.Context, text string) error

func Receive

func Receive(ctx context.Context, c Content, root *os.Root, r io.Reader) ([]string, error)

Receive publishes each verified file without overwriting existing entries. Previously completed files remain if a later file fails.

Types

type Ack

type Ack struct {
	Protocol string  `json:"protocol"`
	Content  Content `json:"content,omitempty"`
}

type Batch

type Batch struct {
	Content Content
	// contains filtered or unexported fields
}

func Snapshot

func Snapshot(value Value) (_ *Batch, err error)

func (*Batch) Close

func (b *Batch) Close()

func (*Batch) Send

func (b *Batch) Send(ctx context.Context, w io.Writer) error

Send reads file bytes only after the destination has accepted the paste.

type Content

type Content struct {
	Kind  string `json:"kind"`
	Text  string `json:"text,omitempty"`
	Files []File `json:"files,omitempty"`
}

Content contains transfer metadata only, never source paths or file bytes.

func (Content) Result

func (c Content) Result() Result

func (Content) Validate

func (c Content) Validate() error

type File

type File struct {
	Name string `json:"name"`
	Size int64  `json:"size"`
}

type Ready

type Ready struct {
	Ready bool `json:"ready"`
}

type Request

type Request struct {
	Protocol string  `json:"protocol"`
	Content  Content `json:"content,omitempty"`
	Dir      string  `json:"dir,omitempty"`
}

type Result

type Result struct {
	Kind  string   `json:"kind"`
	Files []string `json:"files,omitempty"`
	Bytes int64    `json:"bytes"`
}

Result deliberately excludes clipboard text and source paths from tool output.

type Value

type Value struct {
	Text  string   `json:"text"`
	Paths []string `json:"paths"`
}

Value is local clipboard data. Paths never travel to the receiving machine.

func Read

func Read(ctx context.Context) (Value, error)

Read prefers file references over text. Reading references does not read file bytes.

Jump to

Keyboard shortcuts

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