terminal

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package terminal provides TTY detection, dimension validation, color capability detection, and tmux awareness.

Index

Constants

View Source
const MinHeight = 24

MinHeight is the minimum terminal height required.

View Source
const MinWidth = 80

MinWidth is the minimum terminal width required.

Variables

This section is empty.

Functions

func CheckDimensions

func CheckDimensions(width, height int) error

CheckDimensions returns an error if the terminal is smaller than 80x24.

func IsTTY

func IsTTY(f *os.File) bool

IsTTY reports whether f is connected to a terminal.

func IsTmux

func IsTmux(env Env) bool

IsTmux reports whether the session is running inside tmux.

Types

type ColorProfile

type ColorProfile int

ColorProfile describes the terminal's color capability.

const (
	ColorNone      ColorProfile = iota // NO_COLOR or dumb terminal
	ColorBasic                         // 16-color ANSI
	ColorANSI256                       // 256-color
	ColorTrueColor                     // 24-bit true color
)

func DetectColorProfile

func DetectColorProfile(env Env) ColorProfile

DetectColorProfile determines the terminal's color capability. Per https://no-color.org/, NO_COLOR set to any value (including empty) disables color output.

func (ColorProfile) String

func (c ColorProfile) String() string

String returns a human-readable name for the color profile.

type Env

type Env struct {
	Getenv    func(string) string
	LookupEnv func(string) (string, bool)
}

Env abstracts environment variable access for testability.

func OSEnv

func OSEnv() Env

OSEnv returns an Env backed by the real OS environment.

Jump to

Keyboard shortcuts

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