Documentation ¶
Overview ¶
Package pty provides functions for working with Unix terminals.
Index ¶
Constants ¶
const ( TIOCGWINSZ = syscall.TIOCGWINSZ TIOCSWINSZ = syscall.TIOCSWINSZ )
Variables ¶
var ErrUnsupported = errors.New("unsupported")
ErrUnsupported is returned if a function is not available on the current platform.
Functions ¶
func Getsize ¶
Getsize returns the number of rows (lines) and cols (positions in each line) in terminal t.
func InheritSize ¶ added in v1.1.0
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.
Types ¶
type Pty ¶ added in v1.1.12
type Pty interface { // Fd intended to resize Tty of child process in current process FdHolder // WriteString is only used to identify Pty and Tty WriteString(s string) (n int, err error) io.ReadWriteCloser }
Pty for terminal control in current process for unix systems, the real type is *os.File for windows, the real type is a *WindowsPty for ConPTY handle
func Start ¶
Start assigns a pseudo-terminal Tty 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 ¶ added in v1.1.12
StartWithAttrs assigns a pseudo-terminal Tty 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 ¶ added in v1.1.3
StartWithSize assigns a pseudo-terminal Tty 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 Tty ¶ added in v1.1.12
type Tty interface { // Fd only intended for manual InheritSize from Pty FdHolder io.ReadWriteCloser }
Tty for data i/o in child process for unix systems, the real type is *os.File for windows, the real type is a *WindowsTty, which is a combination of two pipe file
type Winsize ¶ added in v1.1.0
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 ¶ added in v1.1.0
GetsizeFull returns the full terminal size description.