tty

package module
v0.0.0-...-5518497 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2019 License: MIT Imports: 8 Imported by: 0

README

go-tty

Simple tty utility

Usage

tty, err := tty.Open()
if err != nil {
	log.Fatal(err)
}
defer tty.Close()

for {
	r, err := tty.ReadRune()
	if err != nil {
		log.Fatal(err)
	}
	// handle key event
}

if you are on windows and want to display ANSI colors, use go-colorable.

tty, err := tty.Open()
if err != nil {
	log.Fatal(err)
}
defer tty.Close()

out := colorable.NewColorable(tty.Output())

fmt.Fprintln(out, "\x1b[2J")

Installation

$ go get github.com/mattn/go-tty

License

MIT

Author

Yasuhiro Matsumoto (a.k.a mattn)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TTY

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

func Open

func Open() (*TTY, error)

func (*TTY) Buffered

func (tty *TTY) Buffered() bool

func (*TTY) Close

func (tty *TTY) Close() error

func (*TTY) Input

func (tty *TTY) Input() *os.File

func (*TTY) MustRaw

func (tty *TTY) MustRaw() func() error

func (*TTY) Output

func (tty *TTY) Output() *os.File

func (*TTY) Raw

func (tty *TTY) Raw() (func() error, error)

func (*TTY) ReadPassword

func (tty *TTY) ReadPassword() (string, error)

func (*TTY) ReadPasswordClear

func (tty *TTY) ReadPasswordClear() (string, error)

func (*TTY) ReadPasswordNoEcho

func (tty *TTY) ReadPasswordNoEcho() (string, error)

func (*TTY) ReadRune

func (tty *TTY) ReadRune() (rune, error)

func (*TTY) ReadString

func (tty *TTY) ReadString() (string, error)

func (*TTY) SIGWINCH

func (tty *TTY) SIGWINCH() chan WINSIZE

func (*TTY) Size

func (tty *TTY) Size() (int, int, error)

type WINSIZE

type WINSIZE struct {
	W int
	H int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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