Пример #1
0
// New creates a new terminal interface in the file descriptor InputFD.
func New() (*Terminal, error) {
	var t Terminal

	// Get the actual state
	if err := sys.Getattr(InputFD, &t.lastState); err != nil {
		return nil, os.NewSyscallError("sys.Getattr", err)
	}

	t.oldState = t.lastState // the actual state is copied to another one
	t.fd = InputFD
	return &t, nil
}
Пример #2
0
// IsTerminal returns true if the file descriptor is a term.
func IsTerminal(fd int) bool {
	return sys.Getattr(fd, &sys.Termios{}) == nil
}