Documentation ¶
Index ¶
- func GetSize(fd uintptr) (width, height int, err error)
- func IsTerminal(fd uintptr) bool
- func QueryBackgroundColor(in io.Reader, out io.Writer) (c color.Color, err error)
- func QueryKittyKeyboard(in io.Reader, out io.Writer) (flags int, err error)
- func QueryTerminal(in io.Reader, out io.Writer, timeout time.Duration, filter QueryTerminalFilter, ...) error
- func ReadPassword(fd uintptr) ([]byte, error)
- func Restore(fd uintptr, oldState *State) error
- func SetState(fd uintptr, state *State) error
- type File
- type QueryTerminalFilter
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSize ¶
GetSize returns the visible dimensions of the given terminal.
These dimensions don't include any scrollback buffer height.
func IsTerminal ¶
IsTerminal returns whether the given file descriptor is a terminal.
func QueryBackgroundColor ¶
QueryBackgroundColor queries the terminal for the background color. If the terminal does not support querying the background color, nil is returned.
Note: you will need to set the input to raw mode before calling this function.
state, _ := term.MakeRaw(in.Fd()) defer term.Restore(in.Fd(), state)
func QueryKittyKeyboard ¶
QueryKittyKeyboard returns the enabled Kitty keyboard protocol options. -1 means the terminal does not support the feature.
Note: you will need to set the input to raw mode before calling this function.
state, _ := term.MakeRaw(in.Fd()) defer term.Restore(in.Fd(), state)
func QueryTerminal ¶
func QueryTerminal( in io.Reader, out io.Writer, timeout time.Duration, 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 ¶
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.
Types ¶
type QueryTerminalFilter ¶
QueryTerminalFilter is a function that filters input events using a type switch. If false is returned, the QueryTerminal function will stop reading input.