2020-10-13 12:52:30 -04:00
|
|
|
package tea
|
|
|
|
|
|
|
|
import (
|
2020-10-13 14:41:35 -04:00
|
|
|
"github.com/containerd/console"
|
2020-10-13 12:52:30 -04:00
|
|
|
"github.com/muesli/termenv"
|
|
|
|
)
|
|
|
|
|
2020-10-13 14:41:35 -04:00
|
|
|
var tty console.Console
|
2020-10-13 12:52:30 -04:00
|
|
|
|
|
|
|
func initTerminal() error {
|
2020-10-13 14:41:35 -04:00
|
|
|
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()
|
2020-10-13 14:41:35 -04:00
|
|
|
return tty.Reset()
|
2020-10-13 12:52:30 -04:00
|
|
|
}
|