2015-07-28 17:12:26 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"syscall"
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2020-05-16 11:12:44 +02:00
|
|
|
ws := &struct {
|
|
|
|
row uint16
|
|
|
|
col uint16
|
|
|
|
xpixel uint16
|
|
|
|
ypixel uint16
|
|
|
|
}{}
|
|
|
|
|
2015-07-28 17:12:26 +02:00
|
|
|
retCode, _, errno := syscall.Syscall(syscall.SYS_IOCTL,
|
|
|
|
uintptr(syscall.Stdin),
|
|
|
|
uintptr(syscall.TIOCGWINSZ),
|
|
|
|
uintptr(unsafe.Pointer(ws)))
|
|
|
|
|
|
|
|
if int(retCode) == -1 {
|
|
|
|
panic(errno)
|
|
|
|
}
|
|
|
|
|
2020-05-16 11:12:44 +02:00
|
|
|
Width = int(ws.col) - 2
|
2015-07-28 17:12:26 +02:00
|
|
|
}
|