private static extern void ioctl_winsize(int fd, uint mode, out Winsize size);
private static void InvokeWinsize(out uint rows, out uint cols) { Winsize ws = new Winsize(); ioctl_winsize(0, TIOCGWINSZ, out ws); cols = ws.ws_col; rows = ws.ws_row; }