summary refs log tree commit diff stats
path: root/lib/posix
diff options
context:
space:
mode:
authorCharles Blake <cb@cblake.net>2016-09-01 07:34:42 -0400
committerCharles Blake <cb@cblake.net>2016-09-01 07:34:42 -0400
commit19f83ccd0bf03dea93698a5611c881f57499ca12 (patch)
treece07b15040f963135cc2fcc39dcd4f6cd16f8cc9 /lib/posix
parent0cb90f3eaf482415662091a62b06aceb53d4b1f5 (diff)
downloadNim-19f83ccd0bf03dea93698a5611c881f57499ca12.tar.gz
Add terminal.terminalWidth and supporting types/calls.
Diffstat (limited to 'lib/posix')
-rw-r--r--lib/posix/termios.nim10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/posix/termios.nim b/lib/posix/termios.nim
index c3934c6a9..88c3edf01 100644
--- a/lib/posix/termios.nim
+++ b/lib/posix/termios.nim
@@ -259,3 +259,13 @@ proc tcFlow*(fd: cint; action: cint): cint {.importc: "tcflow",
 # Get process group ID for session leader for controlling terminal FD.
 
 proc tcGetSid*(fd: cint): Pid {.importc: "tcgetsid", header: "<termios.h>".}
+
+# Window size ioctl.  Should work on on any Unix that xterm has been ported to.
+var TIOCGWINSZ*{.importc, header: "<sys/ioctl.h>".}: culong
+
+type ioctl_winsize* {.importc: "struct winsize", header: "<termios.h>",
+                      final, pure.} = object
+  ws_row*, ws_col*, ws_xpixel*, ws_ypixel*: cushort
+
+proc ioctl*(fd: cint, request: culong, reply: ptr ioctl_winsize): int {.
+  importc: "ioctl", header: "<stdio.h>", varargs.}