Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!UCBVAX.BERKELEY.EDU!"Dan Karron From: Dan Karron@UCBVAX.BERKELEY.EDU Newsgroups: comp.sys.sgi Subject: wsh window size code Message-ID: <9104170341.AA13470@karron.med.nyu.edu> Date: 17 Apr 91 03:41:05 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: karron@cmcl2.nyu.edu Organization: The Internet Lines: 59 Here is the answer to my previous question. Thans to Mike Sweet for clueing me to the place to look. This code is adapted from the tcsh editor code. Thanks Christos ! Now for the hard part, that I don't want to do: What about cases when you are 1) not connected to a terminal, 2) piped to the printer, or 3) using termio 4) using termcap 4) completely lost and need to make a best guess ! Anyway, here is the simple way: ---------snip--------------------------------------------------- #include "stdio.h" #include "termio.h" #include #include #include int GetSize(int *lins, int *cols) { struct winsize ws; if (ioctl(0, TIOCGWINSZ,&ws) < 0) return(0); if (ws.ws_col) *cols = ws.ws_col; if (ws.ws_row) *lins = ws.ws_row; return(*cols); } main() { int i,j; int lines,cols; struct winsize *t; system("clear"); sleep(4); GetSize(&lines,&cols); for(j=0;j (212) 397 9330 | | New York, New York 10016 <2> 10896 <3> |