term

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package term holds the canonical terminal-capability primitives: the colour-mode ladder and the TTY check (adr-49, brief invariant 13). It is deliberately banner-independent — the bare-invocation banner (itd-112) is its first consumer and the styled grill (itd-110) its declared second; a surface that wants decoration resolves its mode here rather than minting a parallel copy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTerminal

func IsTerminal(f *os.File) bool

IsTerminal reports whether f is an interactive character device. This is the one canonical check; call sites that used to hand-roll the Stat/ ModeCharDevice test delegate here.

func UTF8Locale

func UTF8Locale(getenv func(string) string) bool

UTF8Locale reports whether the locale advertises UTF-8. Block art (half and shade blocks) assumes UTF-8; without it a decorated surface renders its text lines only. Checked in POSIX order: LC_ALL, LC_CTYPE, LANG.

Types

type ColorMode

type ColorMode int

ColorMode is one rung of the colour ladder.

const (
	// Mono means no colour at all: decoration degrades to plain glyphs,
	// never to blank output.
	Mono ColorMode = iota
	// Ansi16 is the 16-colour floor for colour-capable terminals.
	Ansi16
	// Ansi256 is the xterm-256 palette.
	Ansi256
	// TrueColor is 24-bit colour, rendered straight from hex.
	TrueColor
)

func ResolveColorMode

func ResolveColorMode(getenv func(string) string, noColorFlag bool) ColorMode

ResolveColorMode resolves the ladder for stdout decoration. Precedence, descending: the surface's --no-color flag; the NO_COLOR convention (present AND non-empty — presence alone does not count); TERM dumb or unset (cron, bare containers) forces Mono even when COLORTERM leaks through a multiplexer; COLORTERM truecolor/24bit; a 256color TERM; else the 16-colour floor.

Jump to

Keyboard shortcuts

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