You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

termsize.go 386B

12345678910111213141516171819202122232425262728
  1. // +build !windows,!plan9,!solaris,!appengine
  2. package flags
  3. import (
  4. "syscall"
  5. "unsafe"
  6. )
  7. type winsize struct {
  8. row, col uint16
  9. xpixel, ypixel uint16
  10. }
  11. func getTerminalColumns() int {
  12. ws := winsize{}
  13. if tIOCGWINSZ != 0 {
  14. syscall.Syscall(syscall.SYS_IOCTL,
  15. uintptr(0),
  16. uintptr(tIOCGWINSZ),
  17. uintptr(unsafe.Pointer(&ws)))
  18. return int(ws.col)
  19. }
  20. return 80
  21. }