Documentation
¶
Overview ¶
Package termseq is the terminal sequence policy shared by the process streams and the output primitives: the SGR parameters and OSC 8 targets the CLI lets through to a terminal. Everything else is dropped by the stream and shown in caret notation by the primitives.
Index ¶
Constants ¶
const ( MaxSGRLen = 64 // bytes of SGR parameters MaxOSCLen = 2048 // bytes of an OSC payload )
Limits on one sequence. A longer one is rejected whole.
const Reset = "\x1b[m"
Reset is the canonical SGR reset.
Variables ¶
This section is empty.
Functions ¶
func Link ¶
Link returns target as an OSC 8 target: an http(s) URL with an ASCII host, with every byte outside 0x21-0x7E in the path, query and fragment percent-encoded. ok is false for an empty target, a control character, a missing or non-ASCII host, another scheme, or an encoded form that would put the OSC 8 payload over MaxOSCLen. A non-ASCII host is not encoded yet; it needs IDNA.
func OSC8 ¶
OSC8 reads an OSC 8 payload, the text between "ESC ]" and the terminator, and returns its target as Link encodes it. ok is false unless the payload is printable ASCII within MaxOSCLen of the form "8;params;target" and the target is empty, which closes a link, or passes Link. Params are ignored.
func SGR ¶
SGR validates SGR parameters, the text between "ESC [" and "m", against the allow list: reset; bold, faint, italic, underline, double underline and strike-through; every off code 22-29, which can only remove styling; foreground 30-37, 90-97, 38;5;n, 38;2;r;g;b and 39; default background 49. At most maxParams fields and MaxSGRLen bytes. It returns the canonical sequence and whether it leaves a style open. A sequence whose net effect is a reset is returned as Reset.
Types ¶
This section is empty.