ansi

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2019 License: BSD-3-Clause Imports: 2 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Black int = iota + 30
	Red
	Green
	Yellow
	Blue
	Magenta
	Cyan
	White
)

https://rosettacode.org/wiki/Terminal_control/Coloured_text#ANSI_escape_codes

View Source
const EscapePrefix = "\033["

Variables

View Source
var (
	// Colors are predeclared and accessible externally
	Colors = map[string]colorSet{
		"Black":   initColor(Black),
		"Red":     initColor(Red),
		"Green":   initColor(Green),
		"Yellow":  initColor(Yellow),
		"Blue":    initColor(Blue),
		"Magenta": initColor(Magenta),
		"Cyan":    initColor(Cyan),
		"White":   initColor(White),
	}
	// Controls exports some other strings/bytes
	Controls = map[string]ansiSet{
		"Prefix": initControl(
			"Prefix",
			EscapePrefix,
		),
		"Bold": initControl(
			"Bold",
			EscapePrefix+"1m",
		),
		"Clear": initControl(
			"Clear",
			EscapePrefix+"2J",
		),
		"Dim": initControl(
			"Dim",
			EscapePrefix+"2m",
		),
		"Hide": initControl(
			"Hide",
			EscapePrefix+"8m",
		),
		"Blink": initControl(
			"Blink",
			EscapePrefix+"5m",
		),
		"Unblink": initControl(
			"Unblink",
			EscapePrefix+"25m",
		),
		"Reset": initControl(
			"Reset",
			EscapePrefix+"0m",
		),
		"Reverse": initControl(
			"Reverse",
			EscapePrefix+"7m",
		),
		"Underline": initControl(
			"Underline",
			EscapePrefix+"4m",
		),
	}
)

Functions

func GetColor

func GetColor(color string) colorSet

GetColor returns an ansi with the inmem material ready to be printed/io.Written. Default is Red

func PaintStrings

func PaintStrings(color string, bg bool, sep string, s ...string) string

PaintStrings accepts strings and returns a colored string ready to be printed. Bg is for background

Types

This section is empty.

Jump to

Keyboard shortcuts

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