DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T t

⟦054a18589⟧ TextFile

    Length: 691 (0x2b3)
    Types: TextFile
    Names: »termwidth.c«

Derivation

└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
    └─ ⟦this⟧ »EUUGD11/euug-87hel/sec8/sps/termwidth.c« 

TextFile

#include	<sys/ioctl.h>

/*
** TERMWIDTH - Sets the external variable `Termwidth' to the # of columns
** on the terminal.
*/
termwidth ()
{
	register char           *termtype ;
	register int            twidth ;
#ifdef TIOCGWINSZ
	struct winsize		w ;
#endif
	char                    buf[ 1025 ] ;
	extern unsigned         Termwidth ;
	char                    *getenv() ;

#ifdef TIOCGWINSZ
	w.ws_col = 0 ;
	if ( !ioctl( 0, TIOCGWINSZ, &w ) && w.ws_col )
	{
		Termwidth = w.ws_col ;
		return ;
	}
#endif
	Termwidth = 80 ;
	if ( !(termtype = getenv( "TERM" )) )
		return ;
	if ( tgetent( buf, termtype ) != 1 )
		return ;
	twidth = tgetnum( "co" ) ;
	if ( twidth > 40 )
		Termwidth = twidth ;
}