terminal

package
v0.0.0-...-10c8d00 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

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

Deprecated: this package moved to golang.org/x/term.

Index

Constants

This section is empty.

Variables

View Source
var ErrPasteIndicator = term.ErrPasteIndicator

ErrPasteIndicator may be returned from ReadLine as the error, in addition to valid line data. It indicates that bracketed paste mode is enabled and that the returned line consists only of pasted data. Programs may wish to interpret pasted data more literally than typed data.

Functions

func GetSize

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

GetSize returns the dimensions of the given terminal.

func IsTerminal

func IsTerminal(fd int) bool

IsTerminal returns whether the given file descriptor is a terminal.

func ReadPassword

func ReadPassword(fd int) ([]byte, error)

ReadPassword reads a line of input from a terminal without local echo. This is commonly used for inputting passwords and other sensitive data. The slice returned does not include the \n.

func Restore

func Restore(fd int, oldState *State) error

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

Types

type EscapeCodes

type EscapeCodes = term.EscapeCodes

EscapeCodes contains escape sequences that can be written to the terminal in order to achieve different styles of text.

type State

type State = term.State

State contains the state of a terminal.

func GetState

func GetState(fd int) (*State, error)

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, error)

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.

type Terminal

type Terminal = term.Terminal

Terminal contains the state for running a VT100 terminal that is capable of reading lines of input.

func NewTerminal

func NewTerminal(c io.ReadWriter, prompt string) *Terminal

NewTerminal runs a VT100 terminal on the given ReadWriter. If the ReadWriter is a local terminal, that terminal must first have been put into raw mode. prompt is a string that is written at the start of each input line (i.e. "> ").

Jump to

Keyboard shortcuts

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