[5877] in Athena Bugs

home help back first fref pref prev next nref lref last post

top and screen heights (comp.sources.bugs)

daemon@ATHENA.MIT.EDU (Jonathan I. Kamens)
Tue Aug 28 10:54:02 1990

Date: Tue, 28 Aug 90 10:53:48 -0400
From: Jonathan I. Kamens <jik@PIT-MANAGER.MIT.EDU>
To: bugs@ATHENA.MIT.EDU

In article <1990Aug25.042839.15222@umigw.miami.edu>, jim@mango.miami.edu (jim brown) writes:
|> The following patch to top v2.1 was found to be necessary for both
|> RISC Ultrix 3.1 and 4.0.  Top was treating a normal ASCII tube
|> (say a vt200 or vt100) as 'dumb' because ws.ws_row was coming back 0.
|> 
|> If the ioctl works and ws.ws_row is 0 then use "li" and "co" to size
|> the 'dumb'er (but not stupid) terminal.
|> 
|> *** screen.c.orig	Mon Sep  5 22:35:05 1988
|> --- screen.c	Sat Aug 25 00:19:39 1990
|> ***************
|> *** 8,13 ****
|> --- 8,14 ----
|>   
|>   #include <stdio.h>
|>   #include <sgtty.h>
|> + #include <errno.h>
|>   #include "screen.h"
|>   #include "boolean.h"
|>   
|> ***************
|> *** 89,102 ****
|>   #if defined(TIOCGWINSZ)
|>       {
|>           struct winsize ws;
|>   
|> !         ioctl(0, TIOCGWINSZ, &ws);
|> !         if (!(screen_length = ws.ws_row)) {		/* yes I mean "=" */
|>   		screen_length = smart_terminal = 0;
|>   		return;
|> ! 	}
|> !         if (!(screen_width = ws.ws_col - 1)) {		/* uh huh */
|>   		screen_width = 79;
|>   	}
|>       }
|>   #else
|> --- 90,132 ----
|>   #if defined(TIOCGWINSZ)
|>       {
|>           struct winsize ws;
|> + 	int		stat;
|>   
|> ! 	stat = ioctl(0, TIOCGWINSZ, &ws);
|> ! 	if (stat != -1 && ws.ws_row == 0) {
|> ! 	    stat = -1; errno = ENOTTY;			/* values no good */
|> ! 	}
|> ! 	if (stat != -1) {
|> ! 	    if (!(screen_length = ws.ws_row)) {		/* yes I mean "=" */
|> ! 		    screen_length = smart_terminal = 0;
|> ! 		    return;
|> ! 	    }
|> ! 	    if (!(screen_width = ws.ws_col - 1)) {	/* uh huh */
|> ! 		    screen_width = 79;
|> ! 	    }
|> ! 	}
|> ! 	else if (errno == ENOTTY) {
|> ! 	    /* set up common terminal capabilities */
|> ! 	    if ((screen_length = tgetnum("li")) <= 0)
|> ! 	    {
|>   		screen_length = smart_terminal = 0;
|>   		return;
|> ! 	    }
|> ! 
|> ! 	    /* screen_width is a little different */
|> ! 	    if ((screen_width = tgetnum("co")) == -1)
|> ! 	    {
|>   		screen_width = 79;
|> + 	    }
|> + 	    else
|> + 	    {
|> + 		screen_width -= 1;
|> + 	    }
|> + 	}
|> + 	else {
|> + 	    fprintf("Can't ioctl TTY: %d\n", errno);
|> + 	    screen_length = smart_terminal = 0;
|> + 	    return;
|>   	}
|>       }
|>   #else
|> 
|> =========== end of patch for screen.c ============
|> --
|> Jim Brown, University of Miami, RSMAS/MPO
|> [send mail to jim@umigw.miami.edu]

Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik@Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710

home help back first fref pref prev next nref lref last post