Categorygithub.com/cockroachdb/ttycolor
modulepackage
0.0.0-20210902133924-c7d7dcdde4e8
Repository: https://github.com/cockroachdb/ttycolor.git
Documentation: pkg.go.dev

# README

ttycolor

Conditionally expose ANSI color codes for use on a terminal

This code is suitable for use in CockroachDB as it satisfies the following requirements:

  1. it should abstract the color numeric codes into symbolic names
  2. it must test the right file descriptor (either stderr or stdout depending on caller requirements)
  3. it must be conservative about which color codes are sent to which terminal type. Not every terminal supports the same colors.

Other Go packages for terminal colors typically fail to satisfy requirements 2 or 3, or both.

# Functions

DetectProfile configures a profile suitable for the given file output.
PickArbitraryColor maps a uint32 to an arbitrary color code (excluding Reset) in a deterministic fashion.
Stderr sets the color for future output to os.Stderr.
Stdout sets the color for future output to os.Stdout.

# Constants

Color codes.
Color codes.
Color codes.
Color codes.
Color codes.
Color codes.
Color codes.
Color codes.
Color codes.
Color codes.

# Variables

Profile256 is suitable for terminals with 256-color support.
Profile8 is suitable for terminals with 8-color support.
StderrProfile is the Profile to use for stderr.
StdoutProfile is the Profile to use for stdout.

# Type aliases

Code represents a terminal color code.
Profile defines escape sequences which provide color in terminals.