Timothy J. Warren
6cdb658d43
Some checks failed
timw4mail/gilo/pipeline/head There was a failure building this commit
26 lines
386 B
Go
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)
|
|
}
|
|
}
|