term

package
v0.6.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetStdinSize

func GetStdinSize() (width, height int, err error)

GetStdinSize returns the size of the stdin terminal

func GetTerminalSize

func GetTerminalSize(fd int) (width, height int, err error)

GetTerminalSize returns the terminal size for the given file descriptor. This is the canonical wrapper for x/term.GetSize — use this instead of importing golang.org/x/term directly.

func IsColorDisabled added in v0.3.2

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 v0.3.2

func IsColorForced() bool

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

func IsStdinTerminal

func IsStdinTerminal() bool

IsStdinTerminal checks if stdin is a terminal

func IsStdoutTerminal

func IsStdoutTerminal() bool

IsStdoutTerminal checks if stdout is a terminal

func IsTerminal added in v0.3.2

func IsTerminal(f *os.File) bool

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

func IsTerminalFd

func IsTerminalFd(fd int) bool

IsTerminalFd checks if a file descriptor is a terminal

Types

type RawMode

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

RawMode manages putting the terminal into raw mode

func NewRawMode

func NewRawMode(fd int) *RawMode

NewRawMode creates a new RawMode manager for the given file descriptor

func NewRawModeStdin

func NewRawModeStdin() *RawMode

NewRawModeStdin creates a RawMode manager for stdin

func (*RawMode) Enable

func (r *RawMode) Enable() error

Enable puts the terminal into raw mode

func (*RawMode) GetSize

func (r *RawMode) GetSize() (width, height int, err error)

GetSize returns the current terminal size

func (*RawMode) IsRaw

func (r *RawMode) IsRaw() bool

IsRaw returns true if the terminal is currently in raw mode

func (*RawMode) IsTerminal

func (r *RawMode) IsTerminal() bool

IsTerminal checks if the file descriptor is a terminal

func (*RawMode) Restore

func (r *RawMode) Restore() error

Restore returns the terminal to its original state

type Term

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

Term holds detected terminal capabilities and file descriptors.

func FromEnv

func FromEnv() Term

FromEnv creates a Term by reading from the real system environment.

func (*Term) Is256ColorSupported

func (t *Term) Is256ColorSupported() bool

Is256ColorSupported returns true if the terminal supports 256 colors.

func (*Term) IsColorEnabled

func (t *Term) IsColorEnabled() bool

IsColorEnabled returns true if basic color output is supported.

func (*Term) IsTTY

func (t *Term) IsTTY() bool

IsTTY returns true if stdout is a terminal.

func (*Term) IsTrueColorSupported

func (t *Term) IsTrueColorSupported() bool

IsTrueColorSupported returns true if the terminal supports 24-bit true color.

func (Term) Size added in v0.3.2

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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