summaryrefslogtreecommitdiffstats
path: root/pkg/terminal/terminal_sysioctl.go
diff options
context:
space:
mode:
authorSergey Grebenshchikov <sgreben@gmail.com>2018-03-22 02:15:42 +0100
committerSergey Grebenshchikov <sgreben@gmail.com>2018-03-22 10:04:51 +0100
commita49891bdb657d7cbb2521f305251cda1f00359d3 (patch)
treebb438378e68025641c54d0b2f2dfdcc73c33a4b0 /pkg/terminal/terminal_sysioctl.go
Initial commit1.0.0
Diffstat (limited to 'pkg/terminal/terminal_sysioctl.go')
-rw-r--r--pkg/terminal/terminal_sysioctl.go19
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
+}