termwidth

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package termwidth resolves terminal width with support for the COLUMNS environment variable.

Resolution order:

  1. COLUMNS environment variable (hard override, per Unix convention)
  2. Terminal ioctl detection via the given file descriptor
  3. Fallback default (80)

Index

Constants

View Source
const DefaultWidth = 80

Variables

This section is empty.

Functions

func FromEnv

func FromEnv() int

FromEnv returns the value of the COLUMNS environment variable, or 0 if it is unset or not a valid positive integer.

func Get

func Get(fd uintptr) int

Get returns the terminal width. If COLUMNS is set to a positive integer, it takes priority over ioctl detection. Otherwise the width is read from the given file descriptor (typically os.Stdout). If detection fails, 80 is returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

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