| Zack Williams | e940c7a | 2019-08-21 14:25:39 -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 | } | ||||