ansi

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: GPL-3.0 Imports: 5 Imported by: 1 module, 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

Index

Constants

View Source
const (
	EscapeByte = 0x1b
	Escape     = "\x1b"
	ClearLine  = Escape + "[2K"
	Reset      = Escape + "[0m"
)

Variables

View Source
var (
	Bold = bold.SprintFunc()

	Cyan = cyan.SprintFunc()

	Gray = gray.SprintFunc()

	Green = green.SprintFunc()

	Yellow = yellow.SprintFunc()

	Underline = underline.Sprint()
)

Functions

func ColorSequence

func ColorSequence(fn func(a ...any) string) (start, stop string)

func CursorUpLeftN

func CursorUpLeftN(lines int) string

CursorUpLeftN creates the escape sequence to move the cursor left and up N lines

func New256BgColor

func New256BgColor(code uint8) *color.Color

New256BgColor return a new xterm 256 (8bit) background color

func New256FgColor

func New256FgColor(code uint8) *color.Color

New256FgColor return a new xterm 256 (8bit) foreground color

func NewLineLengthWriter

func NewLineLengthWriter(writer io.Writer, maxLineLength int) io.Writer

NewLineLengthWriter return an io.Writer that limits the max line length, adding line breaks ('\n') as needed. The writer detects the right most column (consecutive whitespace) and aligns content if possible. UTF sequences are counted as single character and ANSI escape sequences are not counted at all.

func RunesLength

func RunesLength(src []rune, maxLength int) (length, index int)

RunesLength returns the visible content length (and index at the length)

func Sequence

func Sequence(terminator byte, attributes ...any) string

Sequence builds an arbitrary escape sequence

Types

This section is empty.

Jump to

Keyboard shortcuts

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