// GetTerminalWindowSize returns the width and height of a terminal in Windows.
508859
func GetTerminalWindowSize(file *os.File) (*Size, error) {
	var info consoleScreenBufferInfo
	_, _, e := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, file.Fd(), uintptr(unsafe.Pointer(&info)), 0)
	if e != 0 {
		return nil, error(e)
	}
	return &Size{
		Lines:   int(info.size.y),
		Columns: int(info.size.x),
	}, nil
}
340165
func GetSize() (ws Size, err error) {
	_, _, ec := syscall.Syscall(syscall.SYS_IOCTL,
		uintptr(syscall.Stdout),
		uintptr(TIOCGWINSZ),
		uintptr(unsafe.Pointer(&ws)))

	err = getError(ec)

	if TIOCGWINSZ == 0 && err != nil {
		ws = Size{80, 25, 0, 0}
	}
	return ws, err
}
188234
func (window *Window) GetMaximumSize() (w, h int32) {
	var _w, _h C.int
	C.SDL_GetWindowMaximumSize(window.cptr(), &_w, &_h)
	return int32(_w), int32(_h)
}
1172900
func GetSize() (ws Size, err error) {
	var wsz *unix.Winsize
	wsz, err = unix.IoctlGetWinsize(syscall.Stdout, TIOCGWINSZ)

	if err != nil {
		ws = Size{80, 25, 0, 0}
	} else {
		ws = Size{wsz.Row, wsz.Col, wsz.Xpixel, wsz.Ypixel}
	}
	return ws, err
}
1051486
func (c *ContainerServer) GetContainerRwSize(containerID string) (int64, error) {
	container, err := c.store.Container(containerID)
	if err != nil {
		return 0, err
	}

	// Get the size of the top layer by calculating the size of the diff
	// between the layer and its parent.  The top layer of a container is
	// the only RW layer, all others are immutable
	layer, err := c.store.Layer(container.LayerID)
	if err != nil {
		return 0, err
	}
	return c.store.DiffSize(layer.Parent, layer.ID)
}
256723
func (surface *ImageSurface) GetWidth() int {
	ret := int(C.cairo_image_surface_get_width(surface.Ptr))
	if err := surface.status(); err != nil {
		panic(err)
	}
	return ret
}
136776
func terminalWidth() (width int, err error) {
	var info consoleScreenBufferInfo
	_, _, e := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(syscall.Stdout), uintptr(unsafe.Pointer(&info)), 0)
	if e != 0 {
		return 0, error(e)
	}
	return int(info.dwSize.X) - 1, nil
}
1314984
func WindowSize() (w, h int) {
	width, height := Window.GetSize()
	return int(width), int(height)
}
1112669
func GetsizeFull(t *os.File) (size *Winsize, err error) {
	var ws Winsize
	err = windowRectCall(&ws, t.Fd(), syscall.TIOCGWINSZ)
	return &ws, err
}
1178810
func (g *GistFile) GetSize() int {
	if g == nil || g.Size == nil {
		return 0
	}
	return *g.Size
}
1068665
func WmIconSizeGet(xu *xgbutil.XUtil, win xproto.Window) (*IconSize, error) {
	raw, err := xprop.PropValNums(xprop.GetProperty(xu, win, "WM_ICON_SIZE"))
	if err != nil {
		return nil, err
	}
	if len(raw) != 6 {
		return nil,
			fmt.Errorf("WmIconSize: Expected six integers in WM_ICON_SIZE "+
				"property, but xgbutil found "+"%d in '%v'.", len(raw), raw)
	}

	return &IconSize{
		MinWidth: raw[0], MinHeight: raw[1],
		MaxWidth: raw[2], MaxHeight: raw[3],
		WidthInc: raw[4], HeightInc: raw[5],
	}, nil
}
1173049
func (w *Window) Resize(width, height int) (err error) {
	if err = w.isActionable(); err != nil {
		return
	}
	w.m.Lock()
	w.o.Height = PtrInt(height)
	w.o.Width = PtrInt(width)
	w.m.Unlock()
	_, err = synchronousEvent(w.c, w, w.w, Event{Name: EventNameWindowCmdResize, TargetID: w.id, WindowOptions: &WindowOptions{Height: PtrInt(height), Width: PtrInt(width)}}, EventNameWindowEventResize)
	return
}
1050822
func (p *TerminalParams) Winsize() *term.Winsize {
	return &term.Winsize{
		Width:  uint16(p.W),
		Height: uint16(p.H),
	}
}
1290511
func IsTerminal() bool {
	// Windows is always a terminal
	if runtime.GOOS == "windows" {
		return true
	}

	// Same implementation as readline but with our custom fds
	return readline.IsTerminal(int(wrappedstreams.Stdin().Fd())) &&
		(readline.IsTerminal(int(wrappedstreams.Stdout().Fd())) ||
			readline.IsTerminal(int(wrappedstreams.Stderr().Fd())))
}
227321
func goWindowSizeCB(window unsafe.Pointer, width, height C.int) {
	w := windows.get((*C.GLFWwindow)(window))
	w.fSizeHolder(w, int(width), int(height))
}
394969
func NewTerminal(c io.ReadWriter, prompt string) *Terminal {
	return &Terminal{
		Escape:       &vt100EscapeCodes,
		c:            c,
		prompt:       []rune(prompt),
		termWidth:    80,
		termHeight:   24,
		echo:         true,
		historyIndex: -1,
	}
}
327462
func TerminalSize(w io.Writer) (int, int, error) {
	outFd, isTerminal := term.GetFdInfo(w)
	if !isTerminal {
		return 0, 0, fmt.Errorf("given writer is no terminal")
	}
	winsize, err := term.GetWinsize(outFd)
	if err != nil {
		return 0, 0, err
	}
	return int(winsize.Width), int(winsize.Height), nil
}