Documentation
¶
Overview ¶
The image on the clipboard of the computer the app runs on, read with the program each system has for it, as a PNG a message attaches
Index ¶
- Constants
- Variables
- func Blocker(sys System, has func(program string) bool) error
- func DataURL(text string) bool
- func Installed(program string) bool
- func Keep(dir string, img Image) (string, error)
- func Preferred(listed string) string
- func Sources(sys System) []string
- func Usable(text string) bool
- type Image
- type Missing
- type Output
- type Runner
- type System
- type Unreachable
Constants ¶
const ( // Largest image a message takes, and the most pixels it may be, as the labels of the prompt take them MaxBytes = 20 << 20 MaxPixels = 100_000_000 // Longest the reading of the clipboard image may take in all Limit = 15 * time.Second // Age past which a kept image, or a page rendered from a PDF, is removed as the next one is kept KeptFor = 7 * 24 * time.Hour )
Variables ¶
var ErrNone = errors.New("The clipboard has no image.")
The clipboard holds no image
Functions ¶
func Blocker ¶
What keeps this computer from reading a clipboard image: a *Missing program, an *Unreachable desktop, nil when nothing does. Has says whether a program is installed. Under WSL the clipboard of Windows is read through powershell.exe, otherwise through the display WSL shows, as Sources tries them
func DataURL ¶
Whether the text is an image as a data URL, as a terminal or a browser pastes one: data:image/<type>;base64,<data>
func Keep ¶
Writes the image into the folder as a file of its own, named for when it was pasted, the files kept there longer than a week removed first. The path of the file
func Preferred ¶
The type of image to take among the lines a clipboard program listed, empty for none
Types ¶
type Image ¶
type Image struct {
PNG []byte
Width, Height int
// Program that read it, as a user knows it
From string
}
The image on the clipboard, as a PNG
func FromDataURL ¶
The image of a data URL as a PNG within the bounds
func Made ¶
The image as a PNG within the bounds: a PNG as it is, any other format the decoders read made PNG, otherwise made PNG by ImageMagick where a runner is given. Refused in words when nothing reads it or it is too large, one of too many pixels before it is decoded
func Read ¶
Read returns the clipboard image as a PNG within the bounds, trying the system's clipboard programs in turn. It returns ErrNone when the clipboard has no image, and an error when the image found can't be a PNG within the bounds. When the context ends, the error gives how long the reading took
type Missing ¶
A program reading clipboard images that this computer lacks, with the package of each package manager that installs it
type Runner ¶
Runs a program to its end within its limit, with nothing on its input, and gives what it printed. An error for one that could not start, ran past its limit or printed too much, exec.ErrNotFound under it for one that is not installed
type System ¶
type System struct {
OS string
// Linux under WSL, whose clipboard is the one of Windows
WSL bool
// A Wayland display, an X11 display is named
Wayland, X11 bool
// The terminal reaches this computer over SSH, so its clipboard is no clipboard of the user's own computer
Remote bool
// This process runs in a container, or in Termux, neither of which holds a desktop clipboard
Contained, Termux bool
}
What the clipboard is read on
type Unreachable ¶
type Unreachable struct {
Why string
}
No desktop clipboard is reachable from this terminal: why, as the end of a sentence
func (*Unreachable) Error ¶
func (u *Unreachable) Error() string