Documentation
¶
Overview ¶
Package clipboard provides cross-platform clipboard access behind build-tag guards so that unsupported platforms (e.g., Android, iOS) compile without requiring CGO or platform-specific dependencies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnsupported is returned when clipboard access is not available on // the current platform. ErrUnsupported = errors.New("clipboard operations are not supported on this platform") // ErrEmpty is returned when the clipboard holds no data for the // requested format. ErrEmpty = errors.New("clipboard is empty or holds an unsupported format") // ErrWriteFailed is returned when the platform has a clipboard but the // written text is not there afterwards. ErrWriteFailed = errors.New("clipboard write did not land") )
Functions ¶
func CopyToClipboard ¶
CopyToClipboard copies the given text to the clipboard using both OSC 52 (terminal escape sequence) and native clipboard for maximum compatibility. Returns a command that reports the outcome to the user, using the given message on success.
func CopyToClipboardWithCallback ¶
CopyToClipboardWithCallback copies text to clipboard and executes a callback before showing the success message. This is useful when you need to perform additional actions like clearing UI state.
The callback and the success message only run when the copy is believed to have worked, so callers can safely use the callback to discard the copied state (a selection, say) without losing it on a failed copy.
func Init ¶
func Init() error
Init initializes the clipboard subsystem. On unsupported platforms it returns ErrUnsupported but is otherwise safe to call.
func Read ¶
Read returns the clipboard contents for the given format. It returns ErrEmpty when no matching data is present and ErrUnsupported on platforms without clipboard support.