From 9e697d61b90a53c5e0643f8d058d967bb144daaf Mon Sep 17 00:00:00 2001 From: deraadt Date: Tue, 5 Apr 1994 22:56:56 +0000 Subject: TIOCGWINSZ --- snake/snake/move.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'snake') diff --git a/snake/snake/move.c b/snake/snake/move.c index 6eea0055..1f28ef99 100644 --- a/snake/snake/move.c +++ b/snake/snake/move.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)move.c 5.8 (Berkeley) 2/28/91";*/ -static char rcsid[] = "$Id: move.c,v 1.6 1993/12/08 08:21:41 mycroft Exp $"; +static char rcsid[] = "$Id: move.c,v 1.7 1994/04/05 22:56:56 deraadt Exp $"; #endif /* not lint */ /************************************************************************* @@ -548,6 +548,9 @@ getcap() char *xPC; struct point z; void stop(); +#ifdef TIOCGWINSZ + struct winsize ws; +#endif term = getenv("TERM"); if (term==0) { @@ -566,8 +569,17 @@ getcap() ap = tcapbuf; - LINES = tgetnum("li"); - COLUMNS = tgetnum("co"); +#ifdef TIOCGWINSZ + if (ioctl(fileno(stdout), TIOCGWINSZ, &ws) != -1 && + ws.ws_col && ws.ws_row) { + LINES = ws.ws_row; + COLUMNS = ws.ws_col; + } else +#endif + { + LINES = tgetnum("li"); + COLUMNS = tgetnum("co"); + } if (!lcnt) lcnt = LINES - 2; if (!ccnt) -- cgit v1.2.3-56-ge451