// IsTerminal returns whether the given stream (File) is attached to a TTY.
971317
func IsTerminal(stream interface {
	Fd() uintptr
}) bool {
	return terminal.IsTerminal(int(stream.Fd()))
}
385251
func IsTerminal(file *os.File) bool {
	rv, err := C.isatty(C.int(file.Fd()))
	if err != nil {
		return false
	}
	if rv != 0 {
		return true
	}
	return false
}
89047
func IsTerminal(file *os.File) bool {
	var tios syscall.Termios
	_, _, ep := syscall.Syscall(syscall.SYS_IOCTL,
		uintptr(file.Fd()), syscall.TCGETS, uintptr(unsafe.Pointer(&tios)))
	if ep != 0 {
		// syscall failed, it's not a terminal
		return false
	}
	return true
}
955350
func GetTerminalSizeErr() (TerminalWindowSize, error) {
	var ws TerminalWindowSize
	if err := termbox.Init(); err != nil {
		return ws, err
	}
	w, h := termbox.Size()
	ws.Col, ws.Row = uint16(w), uint16(h)
	termbox.Close()
	return ws, nil
}
1245620
func isPerfFile(path string) bool {
	sourceFile, openErr := os.Open(path)
	if openErr != nil {
		return false
	}
	defer sourceFile.Close()

	// If the file is the output of a perf record command, it should begin
	// with the string PERFILE2.
	perfHeader := []byte("PERFILE2")
	actualHeader := make([]byte, len(perfHeader))
	if _, readErr := sourceFile.Read(actualHeader); readErr != nil {
		return false
	}
	return bytes.Equal(actualHeader, perfHeader)
}
19687
func IsTail(r rune) bool {
	if TAIL_G <= r && r <= TAIL_H {
		return true
	}
	return false
}
852533
func (pbp *ProgressBarPrinter) isTerminal(w io.Writer) bool {
	if pbp.printToTTYAlways {
		return true
	}
	if f, ok := w.(*os.File); ok {
		return terminal.IsTerminal(int(f.Fd()))
	}
	return false
}
646760
func IsTerminal(w io.Writer) bool {
	fw, ok := w.(fder)
	if !ok {
		return false
	}
	var termios syscall.Termios
	_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fw.Fd(), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
	return err == 0
}
613456
func IsTextFile(data []byte) bool {
	if len(data) == 0 {
		return true
	}
	return strings.Contains(http.DetectContentType(data), "text/")
}
169296
func IsTerminal(fd int) bool {
	var st uint32
	r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0)
	return r != 0 && e == 0
}
1284751
func (d *Dispenser) SyntaxErr(expected string) error {
	msg := fmt.Sprintf("%s:%d - Syntax error: Unexpected token '%s', expecting '%s'", d.File(), d.Line(), d.Val(), expected)
	return errors.New(msg)
}
974423
func NewTerminalParamsFromUint32(w uint32, h uint32) (*TerminalParams, error) {
	if w > maxSize || w < minSize {
		return nil, trace.BadParameter("bad width")
	}
	if h > maxSize || h < minSize {
		return nil, trace.BadParameter("bad height")
	}
	return &TerminalParams{W: int(w), H: int(h)}, nil
}
1291444
func (s *Operation) SetIsTerminal(v bool) *Operation {
	s.IsTerminal = &v
	return s
}
897300
func restoreTerminal(streams command.Streams, in io.Closer) error {
	streams.In().RestoreTerminal()
	streams.Out().RestoreTerminal()
	// WARNING: DO NOT REMOVE THE OS CHECKS !!!
	// For some reason this Close call blocks on darwin..
	// As the client exits right after, simply discard the close
	// until we find a better solution.
	//
	// This can also cause the client on Windows to get stuck in Win32 CloseHandle()
	// in some cases. See https://github.com/docker/docker/issues/28267#issuecomment-288237442
	// Tracked internally at Microsoft by VSO #11352156. In the
	// Windows case, you hit this if you are using the native/v2 console,
	// not the "legacy" console, and you start the client in a new window. eg
	// `start docker run --rm -it microsoft/nanoserver cmd /s /c echo foobar`
	// will hang. Remove start, and it won't repro.
	if in != nil && runtime.GOOS != "darwin" && runtime.GOOS != "windows" {
		return in.Close()
	}
	return nil
}
624219
func isTrueLiteral(expr Expr) bool {
	if expr, ok := expr.(*BooleanLiteral); ok {
		return expr.Val == true
	}
	return false
}
601129
func IsTemporaryErr(err error) bool {
	t, ok := err.(net.Error)
	return ok && t.Temporary()
}
1076511
func taskInTerminalState(task *api.Task) bool {
	return task.Status.State > api.TaskStateRunning
}