Documentation
¶
Overview ¶
Paths a terminal types at the start of the input when a user drags files onto it or pastes their paths, read as each terminal and shell writes them, and the files they name
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrMissing = errors.New("There is no file there.") ErrFolder = errors.New("It is a folder, and only files are attached.") ErrSpecial = errors.New("It is not a regular file. It may be a device or a socket.") ErrDenied = errors.New("You are not allowed to read it.") )
Why a path a drop names gives no file to attach, each a sentence a user reads after the path
var ImageExtensions = map[string]bool{ ".png": true, ".jpg": true, ".jpeg": true, ".gif": true, ".webp": true, ".bmp": true, ".tiff": true, ".tif": true, ".svg": true, ".ico": true, }
Extensions of the files a drop takes for images
Functions ¶
func Looks ¶
Whether the input starts as a terminal writes the path of a file dropped on it or pasted: the home folder, a folder relative to the one in use, a file:// address, a drive or a share of Windows, each perhaps quoted, PowerShell's call operator before a quote, and a root quoted or followed by more of a path, a slash or a dot, so a slash command such as /help is none
func Resolve ¶
The file a path names, read against base when it is relative, the working folder of the process when base is empty: a file:// address as its path (a share or a drive of Windows as Windows writes it), ~ and ~user as their home folders, a path of Windows off Windows as the path WSL mounts it at and an MSYS path such as /c/Users on Windows as its drive. The path as written first, then with its variables expanded. An error in words when it names no file there, a folder, no regular file or one that can't be read, with the whole path of what is there
func Split ¶
The first path of the input as one word of a shell, unquoted and unescaped, and the text after it. Quoted and bare parts that touch make one word, as a shell reads them: single quotes keep what is between them (for a quote mark of a name, a POSIX shell closes the quotes, escapes the mark and opens them again, and PowerShell doubles the mark), double quotes take a backslash before ", \, $ or a backtick as an escape, and outside quotes a backslash escapes the next character, as macOS Terminal, iTerm2, Ghostty and kitty write a dropped path. In a path of Windows, a backslash is a separator and a backtick, PowerShell's escape, escapes the next character. PowerShell's call operator before a quoted path is left out
Types ¶
type Drop ¶
What a drop at the start of the input names: the files, the paths refused, and the text after them, which is the message
func Detect ¶
The paths a terminal typed at the start of the input for files dropped on it or pasted, a relative one read against base, and the text after them, which is the message. nil when the input starts with no path that names something there. Several files dropped at once, each quoted or escaped as its terminal wrote it and set apart by spaces or lines, are each a file of the drop. A path that names a folder, no regular file or a file that can't be read is refused with why. A path with spaces typed bare is found too: the whole input, or its longest start up to a space that names a file