madux_term

package
v0.0.0-...-014678a Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package terminal provides support functions for dealing with terminals, as commonly found on UNIX systems.

Putting a terminal into raw mode is the most common requirement:

oldState, err := terminal.MakeRaw(0)
if err != nil {
        panic(err)
}
defer terminal.Restore(0, oldState)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSize

func GetSize(fd int) (width, height int, err error)

GetSize returns the dimensions of the given terminal.

func IsTerminal

func IsTerminal(fd int) bool

IsTerminal returns true if the given file descriptor is a terminal.

func ReadPassword

func ReadPassword(fd int) ([]byte, error)

ReadPassword reads a line of input from a terminal without local echo. This is commonly used for inputting passwords and other sensitive data. The slice returned does not include the \n.

func Restore

func Restore(fd int, state *State) error

func SetSize

func SetSize(fd uintptr, width, height int) (err error)

Types

type Pty

type Pty struct {
	// contains filtered or unexported fields
}

func CopyTerm

func CopyTerm(cmd *exec.Cmd) (*Pty, error)

func NewPty

func NewPty() (*Pty, error)

func (*Pty) Close

func (p *Pty) Close()

func (*Pty) CopyAttr

func (p *Pty) CopyAttr(fd uintptr) error

func (*Pty) Read

func (p *Pty) Read(b []byte) (int, error)

func (*Pty) SetCmd

func (p *Pty) SetCmd(c *exec.Cmd)

func (*Pty) SetSize

func (p *Pty) SetSize(w, h int) error

func (*Pty) WindowChange

func (p *Pty) WindowChange(w, h int) error

func (*Pty) Write

func (p *Pty) Write(b []byte) (int, error)

type State

type State struct {
	// contains filtered or unexported fields
}

State contains the state of a terminal.

func GetState

func GetState(fd int) (*State, error)

GetState returns the current state of a terminal which may be useful to restore the terminal after a signal.

func MakeRaw

func MakeRaw(fd int) (*State, error)

MakeRaw put the terminal connected to the given file descriptor into raw mode and returns the previous state of the terminal so that it can be restored.

Jump to

Keyboard shortcuts

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