summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/jessevdk/go-flags/termsize.go
blob: 1ca6a8503c7ea49b8cca78173e51fc04d63dcba5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// +build !windows,!plan9,!solaris,!appengine

package flags

import (
	"syscall"
	"unsafe"
)

type winsize struct {
	row, col       uint16
	xpixel, ypixel uint16
}

func getTerminalColumns() int {
	ws := winsize{}

	if tIOCGWINSZ != 0 {
		syscall.Syscall(syscall.SYS_IOCTL,
			uintptr(0),
			uintptr(tIOCGWINSZ),
			uintptr(unsafe.Pointer(&ws)))

		return int(ws.col)
	}

	return 80
}