Add platform-specific terminal init & restore

This commit is contained in:
Christian Muehlhaeuser
2020-01-25 07:15:29 +01:00
parent 47bfe2b5df
commit bc67e3896b
3 changed files with 44 additions and 14 deletions

28
tty_unix.go Normal file
View File

@@ -0,0 +1,28 @@
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
package tea
import (
"github.com/pkg/term"
)
var (
tty *term.Term
)
func initTerminal() error {
var err error
tty, err = term.Open("/dev/tty")
if err != nil {
return err
}
tty.SetRaw()
hideCursor()
return nil
}
func restoreTerminal() {
showCursor()
tty.Restore()
}