term

package
v0.0.0-...-ba57f76 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrGetWinsizeFailed = errors.New("term: syscall.TIOCGWINSZ failed")

ErrGetWinsizeFailed indicates that the system call to extract the size of a Unix tty from the kernel failed.

Functions

This section is empty.

Types

type Size

type Size struct {
	Lines   int
	Columns int
}

Size is the size of a terminal, expressed in character cells, as Lines and Columns. This might come from environment variables or OS-dependent resources.

func GetEnvWindowSize

func GetEnvWindowSize() *Size

GetEnvWindowSize returns the window Size, as determined by process environment; if either LINES or COLUMNS is present, and whichever is present is also numeric, the Size will be non-nil. If Size is nil, there's insufficient data in environ. If one entry is 0, that means that the environment does not include that data. If a value is negative, we treat that as an error.

func GetSize

func GetSize() (*Size, error)

GetSize will return the terminal window size.

We prefer environ $LINES/$COLUMNS, then fall back to tty-held information. We do not support use of termcap/terminfo to derive default size information.

func GetTerminalWindowSize

func GetTerminalWindowSize(file *os.File) (*Size, error)

GetTerminalWindowSize returns the terminal size maintained by the kernel for a Unix TTY, passed in as an *os.File. This information can be seen with the stty(1) command, and changes in size (eg, terminal emulator resized) should trigger a SIGWINCH signal delivery to the foreground process group at the time of the change, so a long-running process might reasonably watch for SIGWINCH and arrange to re-fetch the size when that happens.

Jump to

Keyboard shortcuts

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