bubbletea/tty.go

26 lines
352 B
Go
Raw Normal View History

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