pty

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: MIT, Apache-2.0, MIT 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

View Source
const (
	TIOCGWINSZ = syscall.TIOCGWINSZ
	TIOCSWINSZ = syscall.TIOCSWINSZ
)

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(t *os.File, ws *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(cmd *exec.Cmd, ws *Winsize) (*os.File, error)

StartWithSize 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.

Types

type Winsize

type Winsize struct {
	Rows uint16 // ws_row: Number of rows (in cells)
	Cols uint16 // ws_col: Number of columns (in cells)
	X    uint16 // ws_xpixel: Width in pixels
	Y    uint16 // ws_ypixel: Height in pixels
}

Winsize describes the terminal size.

func GetsizeFull

func GetsizeFull(t *os.File) (size *Winsize, err 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