terminal

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package terminal provides terminal-related utilities.

Index

Constants

View Source
const DefaultWidth = 50

DefaultWidth is the default terminal width when detection fails.

Variables

View Source
var GetSize = term.GetSize

GetSize returns the terminal width and height for the given file descriptor. This is a variable to allow mocking in tests.

IsTTY checks if the file descriptor is a TTY. This is a variable to allow mocking in tests.

Functions

func GetWidth

func GetWidth() int

GetWidth returns the terminal width for stdout. Returns DefaultWidth if detection fails or stdout is not a terminal.

func GetWidthFromWriter

func GetWidthFromWriter(w io.Writer) int

GetWidthFromWriter returns the terminal width for the given writer. Returns DefaultWidth if detection fails or writer is not a terminal.

func IsTerminal

func IsTerminal() bool

IsTerminal returns true if stdout is a terminal.

func IsTerminalWriter

func IsTerminalWriter(w io.Writer) bool

IsTerminalWriter returns true if the given writer is a terminal.

Types

type Fder

type Fder interface {
	Fd() uintptr
}

Fder is an interface for types that have a file descriptor.

Jump to

Keyboard shortcuts

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