termseq

package
v0.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	MaxSGRLen = 64   // bytes of SGR parameters
	MaxOSCLen = 2048 // bytes of an OSC payload

)

Limits on one sequence. A longer one is rejected whole.

View Source
const Reset = "\x1b[m"

Reset is the canonical SGR reset.

Variables

This section is empty.

Functions

func Link(target string) (encoded string, ok bool)

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

func OSC8(payload string) (target string, ok bool)

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

func SGR(params string) (canon string, open, ok bool)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL