home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume3 / sps / part2 / termwidth.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-11-30  |  490 b   |  22 lines

  1. /*
  2. ** TERMWIDTH - Sets the external variable `Termwidth' to the # of columns
  3. ** on the terminal.
  4. */
  5. termwidth ()
  6. {
  7.     register char           *termtype ;
  8.     register int            twidth ;
  9.     char                    buf[ 1025 ] ;
  10.     extern unsigned         Termwidth ;
  11.     char                    *getenv() ;
  12.  
  13.     Termwidth = 80 ;
  14.     if ( !(termtype = getenv( "TERM" )) )
  15.         return ;
  16.     if ( tgetent( buf, termtype ) != 1 )
  17.         return ;
  18.     twidth = tgetnum( "co" ) ;
  19.     if ( twidth > 40 )
  20.         Termwidth = twidth ;
  21. }
  22.