71c00c200f
on windows: if the term is resized when ReadString is being called and no one is reading form ws, we get a panic: send on closed channel. It could make sense to poll getconsolescreenbufferinfo calls instead of this: something started from the sigwinch() func on unix: same story, sigwinch was listened upon by default but if the signals (chan sends) were not handled, this could cause a crash fix #7434 |
||
---|---|---|
.. | ||
.travis.yml | ||
LICENSE | ||
README.md | ||
tty.go | ||
tty_bsd.go | ||
tty_linux.go | ||
tty_plan9.go | ||
tty_unix.go | ||
tty_windows.go |
README.md
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)