bubbletea/tty_unix.go

34 lines
438 B
Go
Raw Normal View History

// +build darwin dragonfly freebsd linux netbsd openbsd solaris
2020-05-12 16:39:08 -04:00
package boba
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
}
2020-04-17 14:35:54 -04:00
err = tty.SetRaw()
if err != nil {
return err
}
2020-01-31 07:47:36 -05:00
termenv.HideCursor()
return nil
}
func restoreTerminal() {
2020-01-31 07:47:36 -05:00
termenv.ShowCursor()
2020-04-17 14:35:54 -04:00
_ = tty.Restore()
}