clipboard

package
v0.82.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCopyTimeout  = 5 * time.Second
	DefaultReadTimeout  = 3 * time.Second
	DefaultMaxTextBytes = 16 * 1024 * 1024
)

Variables

View Source
var ErrClipboardTextTooLarge = errors.New(
	"clipboard text exceeds the configured size limit",
)

Functions

func CopyToClipboard

func CopyToClipboard(text string, options ClipboardCopyOptions) error

func ExtensionForImageMIMEType

func ExtensionForImageMIMEType(mimeType string) string

func IsWaylandSession

func IsWaylandSession(env map[string]string) bool

func ReadClipboardText added in v0.82.0

func ReadClipboardText(
	ctx context.Context,
	options ClipboardTextReadOptions,
) (text string, ok bool)

ReadClipboardText returns the first authoritative clipboard result from the native adapter or platform tools. Clipboard access is best-effort: command, permission, timeout, and size-limit failures are represented by ok=false.

Types

type ClipboardCopyOperations

type ClipboardCopyOperations struct {
	SetText        func(text string) error
	ExecCommand    func(command string, options ClipboardTextCommandOptions) error
	SpawnWithInput func(command string, args []string, input string) error
	WriteStdout    func(text string) error
	IsWayland      func(env map[string]string) bool
}

type ClipboardCopyOptions

type ClipboardCopyOptions struct {
	Env        map[string]string
	Platform   string
	Operations ClipboardCopyOperations
}

type ClipboardImage

type ClipboardImage struct {
	Bytes    []byte
	MIMEType string
}

func ReadClipboardImage

func ReadClipboardImage(options ClipboardImageOptions) *ClipboardImage

type ClipboardImageCommandOptions

type ClipboardImageCommandOptions struct {
	Timeout        time.Duration
	MaxBufferBytes int
	Env            map[string]string
}

type ClipboardImageCommandResult

type ClipboardImageCommandResult struct {
	Stdout []byte
	OK     bool
}

type ClipboardImageOperations

type ClipboardImageOperations struct {
	RunCommand           func(command string, args []string, options ClipboardImageCommandOptions) ClipboardImageCommandResult
	NativeHasImage       func() bool
	NativeGetImageBinary func() ([]byte, error)
	TempFilePath         func() (string, error)
	ReadFile             func(path string) ([]byte, error)
	RemoveFile           func(path string) error
	ProcVersion          func() (string, error)
}

type ClipboardImageOptions

type ClipboardImageOptions struct {
	Env        map[string]string
	Platform   string
	Operations ClipboardImageOperations
}

type ClipboardTextCommandOptions

type ClipboardTextCommandOptions struct {
	Input   string
	Timeout time.Duration
}

type ClipboardTextReadOperations added in v0.82.0

type ClipboardTextReadOperations struct {
	GetText    func(context.Context) (string, error)
	RunCommand func(
		context.Context,
		string,
		[]string,
		int,
	) (string, error)
}

type ClipboardTextReadOptions added in v0.82.0

type ClipboardTextReadOptions struct {
	Env        map[string]string
	Platform   string
	Timeout    time.Duration
	MaxBytes   int
	Operations ClipboardTextReadOperations
}

Jump to

Keyboard shortcuts

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