clip

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package clip is the one path text takes to the clipboard.

Every copy Sidecar performs goes through here so that a copy means the same thing everywhere: the system clipboard when a clipboard utility is reachable, and the terminal's own clipboard over OSC 52 — the half that works when Sidecar runs over SSH or inside tmux, where no local utility exists.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(text string, wrap func(Result) tea.Msg) tea.Cmd

Copy writes text to every clipboard reachable from here — the system clipboard natively and the terminal's over OSC 52 — and hands the outcome to wrap, which turns it into the host's own message. wrap may return nil when the host says nothing about a copy.

func CopyFrom

func CopyFrom(produce func() (string, tea.Msg), wrap func(Result, string) tea.Msg) tea.Cmd

CopyFrom copies text the command produces when it runs — read off disk, taken from a subprocess — rather than text the caller already holds, so work that belongs off the update loop stays off it. produce returns the message the host should show instead when there is nothing to copy, and wrap is handed the text that was copied so nothing has to be carried between them.

func LastCopied added in v1.3.0

func LastCopied() (string, bool)

LastCopied returns the text of the most recent copy any surface made this session — a yank in one plugin, a cut in another. It is what paste reaches for when the system clipboard is out of reach, as it is over SSH, and it never fails on a machine with no clipboard utility because no clipboard is involved: the copy already passed through here.

func ReadAll

func ReadAll() (string, error)

ReadAll reads the system clipboard.

func ResetRecent added in v1.3.0

func ResetRecent()

ResetRecent empties the session ring.

func WriteAll

func WriteAll(text string) error

WriteAll writes text to the system clipboard, and only that one — over SSH it reaches nothing. It is for handing a writer to code that owns the call and gives nothing back to the program loop; everything that can return a tea.Cmd uses Copy or CopyFrom, which also reach the terminal's own clipboard.

Types

type Result

type Result struct {
	// NativeErr is the system clipboard write's failure. A copy is not over
	// when it is set: the OSC 52 write still happened, and over SSH it is the
	// half that was ever going to work.
	NativeErr error
}

Result reports what a copy achieved. Only the native half can report anything: an OSC 52 write is fire-and-forget by design — the terminal never answers — so a Result with no error means "both were attempted", not "both landed".

func (Result) Message

func (r Result) Message(ok string) string

Message is what the user is told about a copy, phrased from the caller's own success wording. A failed native write is not a failed copy — the OSC 52 write still went to the terminal, which over SSH is the half that was ever going to work — so the wording names the clipboard the text was sent to rather than reporting an error the user cannot act on. It is one sentence for every copy path so that the same outcome never reads two ways.

Jump to

Keyboard shortcuts

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