ansi

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EscRune = '\u001b'
	Esc     = string(EscRune)
	CSI     = Esc + "[" // Control Sequence Introducer

	TopLeft     = CSI + "H"
	LeftMost    = CSI + "1G" // stays on current line
	BottomRight = CSI + "32767;32767H"

	PosSave    = CSI + "s" // saves the current cursor position
	PosRestore = CSI + "u" // restores cursor position to the last save

	EraseEOL    = CSI + "K"  // erase to end of current line
	EraseSOL    = CSI + "1K" // erase to start of current line
	EraseLine   = CSI + "2K" // erase from start to end of current line
	EraseDown   = CSI + "J"  // erase to end of current line, then everything down to bottom of screen
	EraseUp     = CSI + "1J" // erase to start of current line, then everything up to top of screen
	EraseScreen = CSI + "2J" // erases everything to background colour, then moves cursor home

	ShowCursor = CSI + "?25h"
	HideCursor = CSI + "?25l"

	GetCursorPos = CSI + "6n" // responds with `ESC [ <r> ; <c> R`, where <r> is row and <c> is column
)
View Source
const (
	Reset         = "0"
	Bold          = "1"
	Underline     = "4"
	Reverse       = "7"
	UnderlineOff  = "24"
	ReverseOff    = "27"
	FgBlack       = "30"
	FgDarkRed     = "31"
	FgDarkGreen   = "32"
	FgDarkYellow  = "33"
	FgDarkBlue    = "34"
	FgDarkMagenta = "35"
	FgDarkCyan    = "36"
	FgLightGray   = "37"
	FgReset       = "39" // sets foreground color to default
	BgBlack       = "40"
	BgDarkRed     = "41"
	BgDarkGreen   = "42"
	BgDarkYellow  = "43"
	BgDarkBlue    = "44"
	BgDarkMagenta = "45"
	BgDarkCyan    = "46"
	BgLightGray   = "47"
	BgReset       = "49" // sets background color to default
	FgDarkGray    = "90"
	FgRed         = "91"
	FgGreen       = "92"
	FgYellow      = "93"
	FgBlue        = "94"
	FgMagenta     = "95"
	FgCyan        = "96"
	FgWhite       = "97"
	BgDarkGray    = "100"
	BgRed         = "101"
	BgGreen       = "102"
	BgYellow      = "103"
	BgBlue        = "104"
	BgMagenta     = "105"
	BgCyan        = "106"
	BgWhite       = "107"
)

Variables

This section is empty.

Functions

func CropPreservingANSI added in v0.9.2

func CropPreservingANSI(str string, max int) string

CropPreservingANSI crops the unicode runes down to given length, but preserves all ANSI/VT100 escape sequences.

func Down

func Down(n int) string

func Left

func Left(n int) string

func NextLine

func NextLine(n int) string

NextLine moves cursor to start of line n below current (stops at bottom of viewable area, does not cause a scroll)

func PrevLine

func PrevLine(n int) string

PrevLine moves cursor to start of line n above current (stops at top of viewable area)

func Right(n int) string

func SGR

func SGR(params ...string) string

SGR applies the above sgr params in the order specified (later commands may override earlier commands)

func Up

func Up(n int) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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