blob: 1ca6a8503c7ea49b8cca78173e51fc04d63dcba5 [file] [log] [blame]
Zack Williamse940c7a2019-08-21 14:25:39 -07001// +build !windows,!plan9,!solaris,!appengine
2
3package flags
4
5import (
6 "syscall"
7 "unsafe"
8)
9
10type winsize struct {
11 row, col uint16
12 xpixel, ypixel uint16
13}
14
15func getTerminalColumns() int {
16 ws := winsize{}
17
18 if tIOCGWINSZ != 0 {
19 syscall.Syscall(syscall.SYS_IOCTL,
20 uintptr(0),
21 uintptr(tIOCGWINSZ),
22 uintptr(unsafe.Pointer(&ws)))
23
24 return int(ws.col)
25 }
26
27 return 80
28}