bubbletea/tty_unix.go

30 lines
393 B
Go
Raw Normal View History

// +build darwin dragonfly freebsd linux netbsd openbsd solaris
package tea
import (
2020-01-31 07:47:36 -05:00
"github.com/muesli/termenv"
"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()
2020-01-31 07:47:36 -05:00
termenv.HideCursor()
return nil
}
func restoreTerminal() {
2020-01-31 07:47:36 -05:00
termenv.ShowCursor()
tty.Restore()
}