term

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package term provides support functions for dealing with terminals, as commonly found on UNIX systems.

Putting a terminal into raw mode is the most common requirement:

oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
if err != nil {
        panic(err)
}
defer term.Restore(int(os.Stdin.Fd()), oldState)

Note that on non-Unix systems os.Stdin.Fd() may not be 0.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSize

func GetSize(fd int) (width, height int)

GetSize returns the visible dimensions of the given terminal.

These dimensions don't include any scrollback buffer height.

func IsTerminal

func IsTerminal(fd int) bool

IsTerminal returns whether the given file descriptor is a terminal.

func Restore

func Restore(fd int, oldState *State)

Restore restores the terminal connected to the given file descriptor to a previous state.

Types

type State

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

State contains the state of a terminal.

func GetState

func GetState(fd int) *State

GetState returns the current state of a terminal which may be useful to restore the terminal after a signal.

func MakeRaw

func MakeRaw(fd int) *State

MakeRaw puts the terminal connected to the given file descriptor into raw mode and returns the previous state of the terminal so that it can be restored.

Jump to

Keyboard shortcuts

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