term

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package term provides terminal capability detection and ANSI color utilities. It uses golang.org/x/term for TTY detection and respects NO_COLOR, TERM=dumb, and COLORTERM environment variables.

Index

Constants

View Source
const (
	ColorNone  = 0 // No color support
	ColorBasic = 1 // Basic 16 colors
	Color256   = 2 // 256 colors
	ColorTrue  = 3 // 24-bit true color
)

ColorLevel indicates the terminal's color support.

View Source
const (
	Reset   = "\033[0m"
	Bold    = "\033[1m"
	Dim     = "\033[2m"
	Red     = "\033[31m"
	Green   = "\033[32m"
	Yellow  = "\033[33m"
	Blue    = "\033[34m"
	Magenta = "\033[35m"
	Cyan    = "\033[36m"
	White   = "\033[37m"
	Gray    = "\033[90m"
)

ANSI escape codes for basic colors.

Variables

This section is empty.

Functions

func Colorize

func Colorize(color, text string, enabled bool) string

Colorize wraps text with the given ANSI color code. Returns plain text when disabled.

Types

type Capability

type Capability struct {
	IsTTY      bool
	ColorLevel int
	Width      int
	Height     int
}

Capability holds detected terminal capabilities.

func Detect

func Detect(fd int) Capability

Detect probes the given file descriptor for terminal capabilities.

Jump to

Keyboard shortcuts

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