pty: github.com/creack/pty Index | Files

package pty

import "github.com/creack/pty"

Package pty provides functions for working with Unix terminals.

Index

Package Files

doc.go ioctl.go pty_linux.go run.go util.go ztypes_amd64.go

Variables

var ErrUnsupported = errors.New("unsupported")

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

func Getsize Uses

func Getsize(t *os.File) (rows, cols int, err error)

Getsize returns the number of rows (lines) and cols (positions in each line) in terminal t.

func InheritSize Uses

func InheritSize(pty, tty *os.File) error

InheritSize applies the terminal size of pty to tty. This should be run in a signal handler for syscall.SIGWINCH to automatically resize the tty when the pty receives a window size change notification.

func Open Uses

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

Opens a pty and its corresponding tty.

func Setsize Uses

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

Setsize resizes t to s.

func Start Uses

func Start(c *exec.Cmd) (pty *os.File, err 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 Uses

func StartWithAttrs(c *exec.Cmd, sz *Winsize, attrs *syscall.SysProcAttr) (pty *os.File, err 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 Uses

func StartWithSize(c *exec.Cmd, sz *Winsize) (pty *os.File, err 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.

This will resize the pty to the specified size before starting the command. Starts the process in a new session and sets the controlling terminal.

type Winsize Uses

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 Uses

func GetsizeFull(t *os.File) (size *Winsize, err error)

GetsizeFull returns the full terminal size description.

Package pty imports 6 packages (graph) and is imported by 36 packages. Updated 2020-05-20. Refresh now. Tools for package owners.