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