pty

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: MIT, MIT, Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package pty provides pseudo-terminal support for the terminal widget.

Portions of this package are adapted from github.com/creack/pty.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupported = errors.New("unsupported")

ErrUnsupported is returned if a function is not available on the current platform.

Functions

func Open

func Open() (pty, tty *os.File, err error)

Open opens a pty and its corresponding tty.

func Setsize

func Setsize(*os.File, *Winsize) error

Setsize resizes t to s.

func Start

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

Start assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout, and c.Stderr, calls c.Start, and returns the File of the tty's corresponding pty.

Starts the process in a new session and sets the controlling terminal.

func StartWithAttrs

func StartWithAttrs(c *exec.Cmd, sz *Winsize, attrs *syscall.SysProcAttr) (*os.File, error)

StartWithAttrs assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout, and c.Stderr, calls c.Start, and returns the File of the tty's corresponding pty.

This will resize the pty to the specified size before starting the command if a size is provided. The `attrs` parameter overrides the one set in c.SysProcAttr.

This should generally not be needed. Used in some edge cases where it is needed to create a pty without a controlling terminal.

func StartWithSize

func StartWithSize(*exec.Cmd, *Winsize) (*os.File, error)

StartWithSize returns ErrUnsupported on platforms without local PTY support.

Types

type Winsize

type Winsize struct {
	Rows, Cols, X, Y uint16
}

Winsize is a dummy struct to enable compilation on unsupported platforms.

func GetsizeFull

func GetsizeFull(*os.File) (*Winsize, error)

GetsizeFull returns the full terminal size description.

Jump to

Keyboard shortcuts

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