Skip to content

Commit

Permalink
Use the TIOCGWINSZ macro from C to determine correct value of option
Browse files Browse the repository at this point in the history
  • Loading branch information
jessevdk committed Feb 9, 2013
1 parent 792019a commit 412dcc0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion convert_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import (
"unsafe"
)

// #include <sys/ioctl.h>
// enum { _GO_TIOCGWINSZ = TIOCGWINSZ };
import "C"

type winsize struct {
ws_row, ws_col uint16
ws_xpixel, ws_ypixel uint16
Expand All @@ -17,7 +21,7 @@ func getTerminalColumns() int {

syscall.Syscall(syscall.SYS_IOCTL,
uintptr(0),
uintptr(0x5413),
uintptr(C._GO_TIOCGWINSZ),
uintptr(unsafe.Pointer(&ws)))

return int(ws.ws_col)
Expand Down

0 comments on commit 412dcc0

Please sign in to comment.