pty

package
v0.7.11 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2022 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PTY

type PTY interface {
	io.Closer

	// Output handles TTY output.
	//
	// cmd.SetOutput(pty.Output()) would be used to specify a command
	// uses the output stream for writing.
	//
	// The same stream could be read to validate output.
	Output() ReadWriter

	// Input handles TTY input.
	//
	// cmd.SetInput(pty.Input()) would be used to specify a command
	// uses the PTY input for reading.
	//
	// The same stream would be used to provide user input: pty.Input().Write(...)
	Input() ReadWriter

	// Resize sets the size of the PTY.
	Resize(height uint16, width uint16) error
}

PTY is a minimal interface for interacting with a TTY.

func New

func New() (PTY, error)

New constructs a new Pty.

func Start

func Start(cmd *exec.Cmd) (PTY, *os.Process, error)

type ReadWriter added in v0.6.0

type ReadWriter struct {
	Reader *os.File
	Writer *os.File
}

ReadWriter is an implementation of io.ReadWriter that wraps two separate underlying file descriptors, one for reading and one for writing, and allows them to be accessed separately.

func (ReadWriter) Read added in v0.6.0

func (rw ReadWriter) Read(p []byte) (int, error)

func (ReadWriter) Write added in v0.6.0

func (rw ReadWriter) Write(p []byte) (int, error)

type WithFlags added in v0.6.0

type WithFlags interface {
	PTY

	// EchoEnabled determines whether local echo is currently enabled for this terminal.
	EchoEnabled() (bool, error)
}

WithFlags represents a PTY whose flags can be inspected, in particular to determine whether local echo is enabled.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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