terminal

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEventTimeout = errors.New("event timeout")

ErrEventTimeout is error returned by TimeoutEvent if timeout exceeded.

Functions

This section is empty.

Types

type Pty

type Pty struct {
	Stdin  *os.File
	Stdout *os.File
	// contains filtered or unexported fields
}

Pty is a PTY representation.

func NewPty

func NewPty() (*Pty, error)

NewPty attaches to current terminal and performs some initializations.

func (*Pty) Close

func (p *Pty) Close() error

Close resets terminal and performs de-initializations.

func (*Pty) Reset

func (p *Pty) Reset() error

Reset restores terminal to saved state.

func (*Pty) Size

func (p *Pty) Size() (int, int, error)

Size returns terminal size

func (*Pty) TimeoutEvent

func (p *Pty) TimeoutEvent(timeout time.Duration) (termbox.Event, error)

TimeoutEvent polls terminal event but not greater than provided timeout. If timeout exceeded ErrEventTimeout will be returned.

func (*Pty) ToRaw

func (p *Pty) ToRaw() error

ToRaw saves terminal state and tries to put it to raw mode.

func (*Pty) Write

func (p *Pty) Write(data []byte) error

Write puts data to terminal

type Terminal

type Terminal interface {
	// Size returns terminal width and height.
	Size() (width, height int, err error)

	// Write puts provided bytes to terminal.
	Write([]byte) error

	// ToRaw puts terminal to "raw" state. Previous state should be saved.
	ToRaw() error

	// Reset resets terminal to saved state.
	Reset() error

	// TimeoutEvent waits for terminal event. It blocks until event caught or timeout exceeded.
	TimeoutEvent(timeout time.Duration) (termbox.Event, error)

	io.Closer
}

Terminal is an interface for terminal.

Jump to

Keyboard shortcuts

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