clipboard

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package clipboard provides cross-platform clipboard image reading for Kit.

Terminals cannot paste binary image data via bracketed paste — only text is supported. To read images we shell out to platform-specific clipboard tools:

  • Linux X11: xclip -selection clipboard -t image/png -o
  • Linux Wayland: wl-paste --type image/png
  • macOS: osascript + pbpaste (via a helper that reads NSPasteboard)
  • Windows/WSL: powershell Get-Clipboard -Format Image (not yet supported)

The ReadImage function returns the raw image bytes and detected MIME type, or an error if no image is available on the clipboard.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoImage = fmt.Errorf("no image data on clipboard")

ErrNoImage is returned when the clipboard does not contain image data.

Functions

func DetectMediaType

func DetectMediaType(data []byte) string

DetectMediaType inspects the magic bytes of data to determine the image MIME type. Returns empty string if the format is not recognized.

Types

type ImageData

type ImageData struct {
	// Data is the raw image bytes (PNG, JPEG, etc.).
	Data []byte
	// MediaType is the MIME type (e.g. "image/png", "image/jpeg").
	MediaType string
}

ImageData holds the result of a clipboard image read.

func ReadImage

func ReadImage() (*ImageData, error)

ReadImage reads image data from the system clipboard on Linux. It tries xclip first (X11), then falls back to wl-paste (Wayland).

Jump to

Keyboard shortcuts

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