clipboard
import "github.com/tangoui/tango/sys/clipboard"本页由
site/tools/apigen从源码注释生成(按 darwin 构建标签选文件),请勿手改。
Package clipboard reads and writes the system clipboard: text, images (PNG bytes) and file lists.
Functions are safe from any goroutine once the app runs. They return platform.ErrUnsupported (errors.Is(err, clipboard.ErrUnsupported)) when the backend has no clipboard, and tango.ErrNotRunning after the app quit.
变量
var ErrNotAbsolute = errors.New("clipboard: file paths must be absolute")ErrNotAbsolute is returned by WriteFiles for a path that is not absolute.
var ErrNotPNG = errors.New("clipboard: image is not a PNG")ErrNotPNG is returned by WriteImage when the bytes are not a PNG image.
var ErrUnsupported = platform.ErrUnsupportedErrUnsupported is platform.ErrUnsupported, re-exported for callers outside the module.
函数
func ReadFiles
func ReadFiles(a *tango.App) ([]string, error)ReadFiles returns the paths of files copied in the file manager (Finder, Explorer, Files), or nil when the clipboard holds none.
func ReadImage
func ReadImage(a *tango.App) ([]byte, error)ReadImage returns the clipboard's image encoded as PNG, converting from the platform's native image format when needed. It returns nil (and no error) when the clipboard holds no image.
func ReadText
func ReadText(a *tango.App) (string, error)ReadText returns the clipboard's text ("" if it holds none).
func WriteFiles
func WriteFiles(a *tango.App, paths []string) errorWriteFiles replaces the clipboard's content with a list of files, as copying them in the file manager does; pasting in Finder, Explorer or Files then copies them. Paths must be absolute; an empty list clears the clipboard.
func WriteImage
func WriteImage(a *tango.App, pngData []byte) errorWriteImage replaces the clipboard's content with a PNG image. Backends also offer it in the platform's native image format so other apps can paste it.
func WriteText
func WriteText(a *tango.App, text string) errorWriteText replaces the clipboard's content with text.