terminal

package
v0.0.0-...-5c79d48 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ResizeEvent

type ResizeEvent struct{}

ResizeEvent is emitted when a terminal window is resized.

type StopEvent

type StopEvent struct{}

StopEvent is emitted when the user sends a SIGSTOP

type Terminal

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

Terminal is used to configure raw input and output modes for an attached terminal emulator.

func New

func New(stdin io.Reader, stdout, stderr io.Writer) (*Terminal, error)

New creates a new Terminal instance. Callers should call `InitRaw` to configure the terminal for raw input or output modes.

Note that the returned Terminal instance must be closed to ensure the terminal is properly reset; unexpected exits may leave users' terminals unusable.

func (*Terminal) Clear

func (t *Terminal) Clear() error

Clear clears the terminal, including scrollback.

func (*Terminal) Close

func (t *Terminal) Close() error

Close closes the Terminal, restoring the console to its original state.

func (*Terminal) InitRaw

func (t *Terminal) InitRaw(input bool) error

InitRaw puts the terminal into raw mode. On Unix, no special input handling is required beyond simply reading from stdin, so `input` has no effect. Note that some implementations may replace one or more streams (particularly stdin).

func (*Terminal) IsAttached

func (t *Terminal) IsAttached() bool

IsAttached determines if this terminal is attached to an interactive console session.

func (*Terminal) Resize

func (t *Terminal) Resize(width, height int16) error

Resize makes a best-effort attempt to resize the terminal window. Support varies between platforms and terminal emulators.

func (*Terminal) RestoreCursor

func (t *Terminal) RestoreCursor() error

RestoreCursor restores the last saved cursor position.

func (*Terminal) SaveCursor

func (t *Terminal) SaveCursor() error

SaveCursor saves the current cursor position.

func (*Terminal) SetCursorPos

func (t *Terminal) SetCursorPos(x, y int) error

SetCursorPos sets the cursor position to the given x, y coordinates. Coordinates are 1-indexed. (1, 1) represents the top left corner.

func (*Terminal) SetWindowTitle

func (t *Terminal) SetWindowTitle(s string) error

SetWindowTitle sets the terminal window's title.

func (*Terminal) Size

func (t *Terminal) Size() (width int16, height int16, err error)

Size fetches the current terminal size as measured in columns and rows.

func (*Terminal) Stderr

func (t *Terminal) Stderr() io.Writer

func (*Terminal) Stdin

func (t *Terminal) Stdin() io.Reader

func (*Terminal) Stdout

func (t *Terminal) Stdout() io.Writer

func (*Terminal) Subscribe

func (e *Terminal) Subscribe() chan interface{}

Subscribe creates a channel that will receive terminal events.

Jump to

Keyboard shortcuts

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