Matteo Scandolo | a6a3aee | 2019-11-26 13:30:14 -0700 | [diff] [blame] | 1 | // +build !windows,!plan9,!solaris,!appengine |
2 | |||||
3 | package flags | ||||
4 | |||||
5 | import ( | ||||
6 | "syscall" | ||||
7 | "unsafe" | ||||
8 | ) | ||||
9 | |||||
10 | type winsize struct { | ||||
11 | row, col uint16 | ||||
12 | xpixel, ypixel uint16 | ||||
13 | } | ||||
14 | |||||
15 | func 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 | } |