dict/winsize_linux.go

27 lines
365 B
Go
Raw Permalink Normal View History

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
}{}
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
}