gilo/terminal/raw.go
Timothy J. Warren 6cdb658d43
Some checks failed
timw4mail/gilo/pipeline/head There was a failure building this commit
Simplify package paths
2021-04-07 13:10:40 -04:00

26 lines
386 B
Go

package terminal
import (
"os"
"golang.org/x/term"
)
// Put the terminal in raw mode
func RawOn() *term.State {
oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
if err != nil {
panic(err)
}
return oldState
}
// Restore the terminal to canonical mode
func RawOff(oldState *term.State) {
err := term.Restore(int(os.Stdin.Fd()), oldState)
if err != nil {
panic(err)
}
}