TermColor.Color: colors and terminal color levels #
Color describes a color independently of a terminal. Rendering chooses the strongest
representation the target terminal can accept: the eight ANSI colors, the xterm 256-color
palette, or 24-bit RGB. default means the terminal's configured default color.
The RGB-to-palette conversions use the conventional xterm palette. A terminal may let its user redefine that palette, so RGB fallback is necessarily an approximation unless the caller chooses a stronger target.
The eight ANSI color names.
- black : BasicColor
Black.
- red : BasicColor
Red.
- green : BasicColor
Green.
- yellow : BasicColor
Yellow.
- blue : BasicColor
Blue.
- magenta : BasicColor
Magenta.
- cyan : BasicColor
Cyan.
- white : BasicColor
White.
Instances For
Equations
Equations
- TermColor.instBEqBasicColor.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Equations
- One or more equations did not get rendered due to their size.
- TermColor.instReprBasicColor.repr TermColor.BasicColor.red prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "TermColor.BasicColor.red")).group prec✝
- TermColor.instReprBasicColor.repr TermColor.BasicColor.blue prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "TermColor.BasicColor.blue")).group prec✝
- TermColor.instReprBasicColor.repr TermColor.BasicColor.cyan prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "TermColor.BasicColor.cyan")).group prec✝
Instances For
Equations
- TermColor.instReprBasicColor = { reprPrec := TermColor.instReprBasicColor.repr }
The two intensities of the eight ANSI colors.
Instances For
Equations
- TermColor.instBEqIntensity.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Equations
Equations
- TermColor.instReprIntensity.repr TermColor.Intensity.normal prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "TermColor.Intensity.normal")).group prec✝
- TermColor.instReprIntensity.repr TermColor.Intensity.bright prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "TermColor.Intensity.bright")).group prec✝
Instances For
Equations
- TermColor.instReprIntensity = { reprPrec := TermColor.instReprIntensity.repr }
A color that can be represented by ANSI SGR color parameters.
- default : Color
The terminal's configured default color.
- ansi : Intensity → BasicColor → Color
An ANSI basic color at the given intensity.
- indexed : UInt8 → Color
An xterm 256-color palette index.
- rgb : UInt8 → UInt8 → UInt8 → Color
An explicit red, green, and blue color.
Instances For
Equations
Equations
- TermColor.instBEqColor.beq TermColor.Color.default TermColor.Color.default = true
- TermColor.instBEqColor.beq (TermColor.Color.ansi a a_1) (TermColor.Color.ansi b b_1) = (a == b && a_1 == b_1)
- TermColor.instBEqColor.beq (TermColor.Color.indexed a) (TermColor.Color.indexed b) = (a == b)
- TermColor.instBEqColor.beq (TermColor.Color.rgb a a_1 a_2) (TermColor.Color.rgb b b_1 b_2) = (a == b && (a_1 == b_1 && a_2 == b_2))
- TermColor.instBEqColor.beq x✝¹ x✝ = false
Instances For
Equations
- One or more equations did not get rendered due to their size.
- TermColor.instDecidableEqColor.decEq TermColor.Color.default TermColor.Color.default = isTrue ⋯
- TermColor.instDecidableEqColor.decEq TermColor.Color.default (TermColor.Color.ansi a a_1) = isFalse ⋯
- TermColor.instDecidableEqColor.decEq TermColor.Color.default (TermColor.Color.indexed a) = isFalse ⋯
- TermColor.instDecidableEqColor.decEq TermColor.Color.default (TermColor.Color.rgb a a_1 a_2) = isFalse ⋯
- TermColor.instDecidableEqColor.decEq (TermColor.Color.ansi a a_1) TermColor.Color.default = isFalse ⋯
- TermColor.instDecidableEqColor.decEq (TermColor.Color.ansi a a_1) (TermColor.Color.ansi b b_1) = if h : a = b then h ▸ if h : a_1 = b_1 then h ▸ isTrue ⋯ else isFalse ⋯ else isFalse ⋯
- TermColor.instDecidableEqColor.decEq (TermColor.Color.ansi a a_1) (TermColor.Color.indexed a_2) = isFalse ⋯
- TermColor.instDecidableEqColor.decEq (TermColor.Color.ansi a a_1) (TermColor.Color.rgb a_2 a_3 a_4) = isFalse ⋯
- TermColor.instDecidableEqColor.decEq (TermColor.Color.indexed a) TermColor.Color.default = isFalse ⋯
- TermColor.instDecidableEqColor.decEq (TermColor.Color.indexed a) (TermColor.Color.ansi a_1 a_2) = isFalse ⋯
- TermColor.instDecidableEqColor.decEq (TermColor.Color.indexed a) (TermColor.Color.indexed b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- TermColor.instDecidableEqColor.decEq (TermColor.Color.indexed a) (TermColor.Color.rgb a_1 a_2 a_3) = isFalse ⋯
- TermColor.instDecidableEqColor.decEq (TermColor.Color.rgb a a_1 a_2) TermColor.Color.default = isFalse ⋯
- TermColor.instDecidableEqColor.decEq (TermColor.Color.rgb a a_1 a_2) (TermColor.Color.ansi a_3 a_4) = isFalse ⋯
- TermColor.instDecidableEqColor.decEq (TermColor.Color.rgb a a_1 a_2) (TermColor.Color.indexed a_3) = isFalse ⋯
Instances For
Equations
- TermColor.instReprColor = { reprPrec := TermColor.instReprColor.repr }
Equations
- One or more equations did not get rendered due to their size.
- TermColor.instReprColor.repr TermColor.Color.default prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "TermColor.Color.default")).group prec✝
Instances For
The ordinary ANSI colors.
Equations
Instances For
The ordinary red ANSI color.
Equations
Instances For
The ordinary green ANSI color.
Equations
Instances For
The ordinary yellow ANSI color.
Equations
Instances For
The ordinary blue ANSI color.
Equations
Instances For
The ordinary magenta ANSI color.
Equations
Instances For
The ordinary cyan ANSI color.
Equations
Instances For
The ordinary white ANSI color.
Equations
Instances For
The bright black ANSI color.
Equations
Instances For
The bright red ANSI color.
Equations
Instances For
The bright green ANSI color.
Equations
Instances For
The bright yellow ANSI color.
Equations
Instances For
The bright blue ANSI color.
Equations
Instances For
The bright magenta ANSI color.
Equations
Instances For
The bright cyan ANSI color.
Equations
Instances For
The bright white ANSI color.
Equations
Instances For
The fully saturated, full-brightness color at a hue given in degrees.
The hue wheel wraps, so any Nat is a valid argument. Saturation and value are fixed at their
maximum, which is what gradients and rainbows want; for anything else build .rgb directly.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The xterm index of an ANSI color.
Equations
Instances For
The xterm 256-color index nearest to an RGB color.
The 6×6×6 cube is used for chromatic colors and the 8..238 grayscale ramp for exact grays; pure black and white use the exact ANSI-16 endpoints.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The ANSI-16 index nearest to an RGB color, using the conventional xterm palette.
Equations
Instances For
The xterm 256-color index represented by a color when a palette fallback is needed.
Equations
- TermColor.Color.default.toAnsi256 = none
- (TermColor.Color.ansi a a_1).toAnsi256 = some (TermColor.Color.ansiIndex a a_1)
- (TermColor.Color.indexed a).toAnsi256 = some a
- (TermColor.Color.rgb a a_1 a_2).toAnsi256 = some (TermColor.Color.rgbToAnsi256 a a_1 a_2)
Instances For
The ANSI-16 index represented by a color when only the basic palette is available.
Equations
- One or more equations did not get rendered due to their size.
- TermColor.Color.default.toAnsi16 = none
- (TermColor.Color.ansi a a_1).toAnsi16 = some (TermColor.Color.ansiIndex a a_1)
- (TermColor.Color.rgb a a_1 a_2).toAnsi16 = some (TermColor.Color.rgbToAnsi16 a a_1 a_2)
Instances For
Terminal color levels #
The color precision a terminal can receive through SGR.
- none : ColorLevel
Do not emit color codes.
- ansi16 : ColorLevel
Emit the ANSI-16 palette.
- ansi256 : ColorLevel
Emit the xterm 256-color palette.
- trueColor : ColorLevel
Emit 24-bit RGB colors.
Instances For
Equations
Equations
- TermColor.instBEqColorLevel.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Equations
- TermColor.instReprColorLevel = { reprPrec := TermColor.instReprColorLevel.repr }
Equations
- One or more equations did not get rendered due to their size.
- TermColor.instReprColorLevel.repr TermColor.ColorLevel.none prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "TermColor.ColorLevel.none")).group prec✝