diff options
author | Sergey Grebenshchikov <sgreben@gmail.com> | 2018-03-22 02:15:42 +0100 |
---|---|---|
committer | Sergey Grebenshchikov <sgreben@gmail.com> | 2018-03-22 10:04:51 +0100 |
commit | a49891bdb657d7cbb2521f305251cda1f00359d3 (patch) | |
tree | bb438378e68025641c54d0b2f2dfdcc73c33a4b0 /pkg/terminal/terminal_sysioctl.go |
Initial commit1.0.0
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 +} |