Add terminal.terminalWidth and supporting types/calls.

This commit is contained in:
Charles Blake 2016-09-01 07:34:42 -04:00
commit 19f83ccd0b
2 changed files with 54 additions and 1 deletions

View file

@ -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.}