ansi

package
v0.0.0-...-6b33518 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2019 License: AGPL-3.0-or-later, BSD-3-Clause Imports: 4 Imported by: 2

Documentation

Overview

Package ansi implements ANSI escape codes for terminal colors.

Index

Constants

This section is empty.

Variables

View Source
var AllColors = []Code{Red, Green, Yellow, Blue, Magenta, Cyan, White}

Functions

func Colorf

func Colorf(value interface{}, codes ...Code) interface{}

Colorf returns an fmt.Formatter that colors the value according to the codes when passed to an fmt "printf" function. For example: fmt.Printf("%d %s", Colorf(42, Blue), Colorf(err, Red)). If codes is empty, Colorf returns the original value for efficiency.

func WriteString

func WriteString(dst io.Writer, str string, codes ...Code) (n int, err error)

Types

type Code

type Code string

Code is an ANSI escape code.

const (
	Reset   Code = "0"
	Bold    Code = "1"
	Reverse Code = "7"
	Red     Code = "38;5;1"
	Green   Code = "38;5;2"
	Yellow  Code = "38;5;3"
	Blue    Code = "38;5;4"
	Magenta Code = "38;5;5"
	Cyan    Code = "38;5;6"
	White   Code = "38;5;7" // Usually light grey.
)

func Foreground

func Foreground(color int) Code

Foreground returns a color from [0,255].

Jump to

Keyboard shortcuts

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