diff options
author | Özgür Kesim <oec@codeblau.de> | 2015-07-28 17:16:43 +0200 |
---|---|---|
committer | Özgür Kesim <oec@codeblau.de> | 2015-07-28 17:16:43 +0200 |
commit | 3121760c3a2033c9e7b3b99834b0fe0c29dd332b (patch) | |
tree | deff3a96340c14274d651f3f3977578f275e4fbf /winsize_linux.go | |
parent | f251231590b188681b33705feaf5156d88f09197 (diff) |
fixed constrained build for linux
Diffstat (limited to 'winsize_linux.go')
-rw-r--r-- | winsize_linux.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/winsize_linux.go b/winsize_linux.go new file mode 100644 index 0000000..ebb9f67 --- /dev/null +++ b/winsize_linux.go @@ -0,0 +1,27 @@ +package main + +import ( + "syscall" + "unsafe" +) + +type winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} + +func init() { + ws := &winsize{} + retCode, _, errno := syscall.Syscall(syscall.SYS_IOCTL, + uintptr(syscall.Stdin), + uintptr(syscall.TIOCGWINSZ), + uintptr(unsafe.Pointer(ws))) + + if int(retCode) == -1 { + panic(errno) + } + + Width = int(ws.Col) +} |