term

package module
v0.0.0-...-ba2a951 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackgroundColor

func BackgroundColor(in, out *os.File) (c color.Color)

BackgroundColor queries the terminal for the background color. If the terminal does not support querying the background color, nil is returned.

func CursorColor

func CursorColor(in, out *os.File) (c color.Color)

CursorColor queries the terminal for the cursor color. If the terminal does not support querying the cursor color, nil is returned.

func ForegroundColor

func ForegroundColor(in, out *os.File) (c color.Color)

ForegroundColor queries the terminal for the foreground color. If the terminal does not support querying the foreground color, nil is returned.

func GetSize

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

GetSize returns the visible dimensions of the given terminal.

These dimensions don't include any scrollback buffer height.

func IsTerminal

func IsTerminal(fd uintptr) bool

IsTerminal returns whether the given file descriptor is a terminal.

func QueryTerminal

func QueryTerminal(
	in *os.File,
	out *os.File,
	filter QueryTerminalFilter,
	query string,
) error

QueryTerminal queries the terminal for support of various features and returns a list of response events. Most of the time, you will need to set stdin to raw mode before calling this function. Note: This function will block until the terminal responds or the timeout is reached.

func ReadPassword

func ReadPassword(fd uintptr) ([]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 uintptr, oldState *State) error

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

func SetState

func SetState(fd uintptr, state *State) error

SetState sets the given state of the terminal.

func SupportsKittyKeyboard

func SupportsKittyKeyboard(in, out *os.File) (supported bool)

SupportsKittyKeyboard returns true if the terminal supports the Kitty keyboard protocol.

Types

type Environ

type Environ interface {
	Getenv(string) string
	LookupEnv(string) (string, bool)
	Environ() []string
}

Environ represents the terminal environment.

type OsEnviron

type OsEnviron struct{}

OsEnviron is an implementation of Environ that uses os.Environ.

func (OsEnviron) Environ

func (OsEnviron) Environ() []string

Environ implements Environ.

func (OsEnviron) Getenv

func (OsEnviron) Getenv(key string) string

Getenv implements Environ.

func (OsEnviron) LookupEnv

func (OsEnviron) LookupEnv(key string) (string, bool)

LookupEnv implements Environ.

type QueryTerminalFilter

type QueryTerminalFilter func(events []input.Event) bool

QueryTerminalFilter is a function that filters input events using a type switch. If false is returned, the QueryTerminal function will stop reading input.

type State

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

State contains platform-specific state of a terminal.

func GetState

func GetState(fd uintptr) (*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 uintptr) (*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.

Directories

Path Synopsis
Package ansi defines common ANSI escape sequences based on the ECMA-48 specs.
Package ansi defines common ANSI escape sequences based on the ECMA-48 specs.
examples

Jump to

Keyboard shortcuts

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