termutil

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 13 Imported by: ? modules, 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

Index

Constants

This section is empty.

Variables

View Source
var Stderr io.Writer = stderr{}

Writer to what Route last sent standard error to, else to whatever os.Stderr holds at the moment of each write

View Source
var Stdout io.Writer = stdout{}

Writer to what Route last sent standard output to, else to whatever os.Stdout holds at the moment of each write

Functions

func As

func As[T any](stream any) (T, bool)

Capability T of a stream: the stream itself when it has it, else the first stream down its Unwrap() io.Writer or Unwrap() io.Reader chain that does

func Fd

func Fd(stream any) (uintptr, bool)

Descriptor of a stream or of the first stream it wraps that has one, false when none has one; an *os.File is asked through SyscallConn, so its blocking mode and deadlines stay as they are

func IsTerminal

func IsTerminal(stream any) bool

Whether a stream is a terminal: the IsTerminal() bool answer of the stream or of what it wraps, else whether its descriptor is a terminal or a Cygwin or MSYS terminal pipe

func Route

func Route(stdout, stderr io.Writer) (restore func())

Sends what is written to Stdout and Stderr to the given writers until restore is called, a nil writer leaving that stream as it is; routes nest, the latest one still in place answers, and restoring them in any order leaves the others in place. Fd, IsTerminal and As on Stdout and Stderr keep answering for os.Stdout and os.Stderr, and a destination must not write to Stdout or Stderr itself

func Size

func Size(fallbackCols, fallbackLines int) (cols, lines int)

Columns and lines of the terminal: COLUMNS and LINES when they hold positive whole numbers, else the size of the terminal on stdout, else the fallback

func SizeOf

func SizeOf(stream any) (cols, lines int, err error)

Columns and lines of the terminal a stream refers to: a uintptr descriptor or handle, or anything Fd finds a descriptor in, read without changing a file's blocking mode; an error when it is not a terminal or reports no size, COLUMNS and LINES never consulted

Types

This section is empty.

Jump to

Keyboard shortcuts

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