Source

termios / termios_linux.go

Full commit
package termios

import (
    "os"
    "syscall"
    "unsafe"
)

func CurrentTerminal() (terminal Termios, err os.Error) {
    _, _, e := syscall.Syscall(syscall.SYS_IOCTL, uintptr(0), _TCGETS, uintptr(unsafe.Pointer(&terminal)))
    err = os.NewSyscallError("ioctl", int(e))
    return
}

func (t *Termios)Set() os.Error {
    _, _, e := syscall.Syscall(syscall.SYS_IOCTL, uintptr(0), _TCSETSW, uintptr(unsafe.Pointer(t)))
    return os.NewSyscallError("ioctl", int(e))
}

func (t *Termios)Echo(echo bool) {
    if echo {
        t.Lflag |= _ECHO
    } else {
        t.Lflag &= ^uint32(_ECHO)
    }
}

const (
    _TCGETS  = 0x5401
    _TCSETSW = 0x5403
    _NCCS = 32
    _ECHO = 010
    )

type Termios struct {
    Iflag, Oflag, Cflag, Lflag uint32
    Line uint8
    Cc [_NCCS]uint8
    Ispeed, Ospeed uint32
}