1// Copyright 2011 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// +build darwin dragonfly freebsd linux,!appengine netbsd openbsd
6
7package readline
8
9import (
10	"syscall"
11	"unsafe"
12)
13
14type Termios syscall.Termios
15
16// GetSize returns the dimensions of the given terminal.
17func GetSize(fd int) (int, int, error) {
18	var dimensions [4]uint16
19	_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&dimensions)), 0, 0, 0)
20	if err != 0 {
21		return 0, 0, err
22	}
23	return int(dimensions[1]), int(dimensions[0]), nil
24}
25