console

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package console detects output capabilities without writing escape sequences or reading terminal input. Font coverage cannot be queried portably, so font support is unknown unless explicitly configured by the user.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Capabilities

type Capabilities struct {
	Terminal  bool
	ANSI      bool
	Unicode   bool
	Powerline Support
	NerdFont  Support
}

Capabilities describes one output destination, not process-wide state. Unicode and ANSI are conservative environment-based estimates, not probes. Powerline support alone does not imply support for Nerd Font icons.

func Detect

func Detect(w io.Writer) Capabilities

Detect checks whether w is a terminal and inspects the current environment. Non-file writers, redirected files, and TERM=dumb use plain ASCII output. Unicode requires a UTF-8 locale (LC_ALL, LC_CTYPE, then LANG), or an explicitly enabled font. VIEWKIT_POWERLINE and VIEWKIT_NERD_FONT accept strconv.ParseBool values; unset, "auto", and invalid values mean unknown. Nerd Fonts include Powerline symbols, unless Powerline is explicitly disabled. Font overrides do not enable capabilities for non-terminal or dumb output. Detect neither changes global rendering state nor consumes terminal input.

type Support

type Support uint8

Support distinguishes an unverified capability from known lack of support.

const (
	// Unknown means there is not enough information to determine support.
	Unknown Support = iota
	// Unsupported means the capability is disabled or unavailable.
	Unsupported
	// Supported means the capability is explicitly enabled.
	Supported
)

Jump to

Keyboard shortcuts

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