// RawMode places the terminal into raw mode. func RawMode(t *Term) error { var a attr if err := termios.Tcgetattr(uintptr(t.fd), (*syscall.Termios)(&a)); err != nil { return err } termios.Cfmakeraw((*syscall.Termios)(&a)) return termios.Tcsetattr(uintptr(t.fd), termios.TCSANOW, (*syscall.Termios)(&a)) }
func (t *Term) setSpeed(baud int) error { var a attr if err := termios.Tcgetattr(uintptr(t.fd), (*syscall.Termios)(&a)); err != nil { return err } a.setSpeed(baud) return termios.Tcsetattr(uintptr(t.fd), termios.TCSANOW, (*syscall.Termios)(&a)) }
// Restore restores the state of the terminal captured at the point that // the terminal was originally opened. func (t *Term) Restore() error { return termios.Tcsetattr(uintptr(t.fd), termios.TCIOFLUSH, &t.orig) }