bubbletea/tty.go

27 lines
338 B
Go
Raw Normal View History

2020-10-13 12:52:30 -04:00
package tea
import (
"io"
"github.com/containerd/console"
2020-10-13 12:52:30 -04:00
)
var tty console.Console
2020-10-13 12:52:30 -04:00
func initTerminal(w io.Writer) error {
tty = console.Current()
err := tty.SetRaw()
2020-10-13 12:52:30 -04:00
if err != nil {
return err
}
enableAnsiColors()
hideCursor(w)
2020-10-13 12:52:30 -04:00
return nil
}
func restoreTerminal(w io.Writer) error {
showCursor(w)
return tty.Reset()
2020-10-13 12:52:30 -04:00
}