escape

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2021 License: Apache-2.0 Imports: 1 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Start     = "\033[" // Start is the CSI escape code
	Separator = ";"     // Separator allows multiple attributes to be strung together
	End       = "m"     // End terminates the CSI sequence and indicates that this is an SGR command
)

ECMA-48 strings for constructing CSI SGR directives

Variables

View Source
var (
	Reset          = Sequence{Pre: "0"}  // Reset all Character Attributes to defaults
	Bold           = Sequence{Pre: "1"}  // Bold text
	Dim            = Sequence{Pre: "2"}  // Dim text, opposite of Bold
	Underline      = Sequence{Pre: "4"}  // Underline text
	Blink          = Sequence{Pre: "5"}  // Blink text at cursor rate
	Reverse        = Sequence{Pre: "7"}  // Reverse FG and BG colors
	Hidden         = Sequence{Pre: "8"}  // Hidden suppresses typed characters (e.g. password entry)
	ResetBold      = Sequence{Pre: "22"} // ResetBold turns off Bold/Dim formatting only
	ResetDim       = Sequence{Pre: "22"} // ResetDim turns off Bold/Dim formatting only
	ResetUnderline = Sequence{Pre: "24"} // ResetUnderline turns off Underline formatting only
	ResetBlink     = Sequence{Pre: "25"} // ResetBlink turns off Blink formatting only
	ResetReverse   = Sequence{Pre: "27"} // ResetReverse turns off Reverse formatting only
	ResetHidden    = Sequence{Pre: "28"} // ResetHidden turns off Hidden formatting only
)

CSI Character Attributes (SGR) See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html

Functions

This section is empty.

Types

type Sequence

type Sequence struct {
	// Pre is added at the start of the formatted string
	Pre string
	// Post is added at the end of the formatted string
	Post string
}

Sequence Represents one or more CSI Character Attributes (SGR)

func Combine

func Combine(seqs ...Sequence) (next Sequence)

Combine concatenates one or more Sequences together to form a single pre-calculated Sequence

func (Sequence) Func

func (s Sequence) Func() style.Style

Func forms a closure around a sequence which allows it to be called as a formatting function

func (Sequence) String

func (s Sequence) String() string

String generates the sequence, without and associated text to format

func (Sequence) Swap

func (s Sequence) Swap() Sequence

Swap exchanges the Pre and Post fields, useful for the last Sequence(s) in a combination

Jump to

Keyboard shortcuts

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