Documentation
¶
Overview ¶
Package color handles terminal color capability detection and color conversion. Detection is auto-derived from environment variables and can be overridden via the config color_level field.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResolveColorName ¶
ResolveColorName converts a CSS/ANSI color name to the numeric string equivalent expected by lipgloss.Color(). Hex strings ("#rrggbb") and numeric strings ("2", "114") pass through unchanged. Unrecognised names also pass through, which lets lipgloss handle them (it returns noColor for unknown values, which is the same behaviour as before this function existed).
This is the canonical resolver for all color strings in the config system. Both the widget and render packages call this before passing config color values to lipgloss.Color().
Types ¶
type Level ¶
type Level int
Level represents the color depth supported by the terminal.
func DetectLevel ¶
func DetectLevel() Level
DetectLevel returns the color level from the environment. Detection order:
- COLORTERM=truecolor or 24bit → LevelTruecolor
- TERM is a known truecolor terminal → LevelTruecolor
- TERM_PROGRAM is a known truecolor application → LevelTruecolor
- TERM contains "256color" → Level256
- Default → LevelBasic
The caller is responsible for applying any config override before calling this function (see ParseLevel / LevelFromConfig).
func LevelFromConfig ¶
LevelFromConfig resolves the effective Level given a config override string. When override is "auto" or empty, DetectLevel is called. Otherwise ParseLevel is attempted; unrecognised values fall back to DetectLevel.
func ParseLevel ¶
ParseLevel converts a config string to a Level. Accepted values: "truecolor", "256", "basic". Unknown values return LevelBasic and false.
func (Level) ColorProfile ¶
func (l Level) ColorProfile() colorprofile.Profile
ColorProfile converts a Level to the corresponding colorprofile.Profile so callers can apply the level to lipgloss's global writer without importing colorprofile directly.