本站源代码
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.

29 lines
386B

  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. }
上海开阖软件有限公司 沪ICP备12045867号-1