diff options
Diffstat (limited to 'pkg/terminal/terminal_sysioctl.go')
-rw-r--r-- | pkg/terminal/terminal_sysioctl.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/pkg/terminal/terminal_sysioctl.go b/pkg/terminal/terminal_sysioctl.go new file mode 100644 index 0000000..121b566 --- /dev/null +++ b/pkg/terminal/terminal_sysioctl.go @@ -0,0 +1,19 @@ +// +build !windows,!plan9,!solaris + +package terminal + +import ( + "os" + + "golang.org/x/sys/unix" +) + +func getWinsize() (int, int, error) { + + ws, err := unix.IoctlGetWinsize(int(os.Stdout.Fd()), unix.TIOCGWINSZ) + if err != nil { + return 0, 0, os.NewSyscallError("GetWinsize", err) + } + + return int(ws.Col), int(ws.Row), nil +} |