term

package
v2.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 7 Imported by: 8

Documentation

Overview

Package term provides information about the terminal that the current process is connected to (if any), for example measuring the dimensions of the terminal and inspecting whether it's safe to output color.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsColorDisabled

func IsColorDisabled() bool

IsColorDisabled returns true if environment variables NO_COLOR or CLICOLOR prohibit usage of color codes in terminal output.

func IsColorForced added in v2.0.1

func IsColorForced() bool

IsColorForced returns true if environment variable CLICOLOR_FORCE is set to force colored terminal output.

func IsTerminal

func IsTerminal(f *os.File) bool

IsTerminal reports whether a file descriptor is connected to a terminal.

Types

type Term

type Term struct {
	// contains filtered or unexported fields
}

Term represents information about the terminal that a process is connected to.

func FromEnv

func FromEnv() Term

FromEnv initializes a Term from os.Stdout and environment variables:

  • GH_FORCE_TTY
  • NO_COLOR
  • CLICOLOR
  • CLICOLOR_FORCE
  • TERM
  • COLORTERM

func (Term) ErrOut

func (t Term) ErrOut() io.Writer

ErrOut is the writer writing to standard error.

func (Term) In

func (t Term) In() io.Reader

In is the reader reading from standard input.

func (Term) Is256ColorSupported

func (t Term) Is256ColorSupported() bool

Is256ColorSupported reports whether the terminal advertises ANSI 256 color codes.

func (Term) IsColorEnabled

func (t Term) IsColorEnabled() bool

IsColorEnabled reports whether it's safe to output ANSI color sequences, depending on IsTerminalOutput and environment variables.

func (Term) IsTerminalOutput

func (t Term) IsTerminalOutput() bool

IsTerminalOutput returns true if standard output is connected to a terminal.

func (Term) IsTrueColorSupported

func (t Term) IsTrueColorSupported() bool

IsTrueColorSupported reports whether the terminal advertises support for ANSI true color sequences.

func (Term) Out

func (t Term) Out() io.Writer

Out is the writer writing to standard output.

func (Term) Size

func (t Term) Size() (int, int, error)

Size returns the width and height of the terminal that the current process is attached to. In case of errors, the numeric values returned are -1.

func (Term) Theme

func (t Term) Theme() string

Theme returns the theme of the terminal by analyzing the background color of the terminal.

Jump to

Keyboard shortcuts

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