xref: /csrg-svn/old/lib2648/ttyinit.c (revision 18788)
111496Sralph /*
2*18788Sdist  * Copyright (c) 1980 Regents of the University of California.
3*18788Sdist  * All rights reserved.  The Berkeley software License Agreement
4*18788Sdist  * specifies the terms and conditions for redistribution.
5*18788Sdist  */
6*18788Sdist 
7*18788Sdist #ifndef lint
8*18788Sdist static char sccsid[] = "@(#)ttyinit.c	5.1 (Berkeley) 04/26/85";
9*18788Sdist #endif not lint
10*18788Sdist 
11*18788Sdist /*
1211496Sralph  * sgtty stuff
1311496Sralph  */
1411496Sralph 
1511496Sralph #include <sgtty.h>
1611496Sralph 
1711496Sralph struct	sgttyb	_ttyb;
1811496Sralph struct	tchars	_otch, _ntch;
1911496Sralph int	_normf;
2011496Sralph 
2111496Sralph /*
2211496Sralph  * Routines for dealing with the unix tty modes
2311496Sralph  */
2411496Sralph 
2511496Sralph #include "2648.h"
2611496Sralph 
ttyinit()2711496Sralph ttyinit()
2811496Sralph {
2911496Sralph 	if (strcmp(getenv("TERM"), "hp2648") == 0)
3011496Sralph 		_on2648 = 1;
3111496Sralph 	ioctl(fileno(stdin), TIOCGETP, &_ttyb);
3211496Sralph 	ioctl(fileno(stdin), TIOCGETC, &_otch);
3311496Sralph 	_ntch = _otch;
3411496Sralph 	_ntch.t_quitc = _ntch.t_startc = _ntch.t_stopc = -1;
3511496Sralph 	_normf = _ttyb.sg_flags;
3611496Sralph 	_ttyb.sg_flags |= CBREAK;
3711496Sralph 	_ttyb.sg_flags &= ~(ECHO|CRMOD);
3811496Sralph 	ioctl(fileno(stdin), TIOCSETN, &_ttyb);
3911496Sralph 	ioctl(fileno(stdin), TIOCSETC, &_ntch);
4011496Sralph 	gdefault();
4111496Sralph 	zoomn(1);
4211496Sralph 	zoomon();
4311496Sralph 	kon();
4411496Sralph 	rboff();
4511496Sralph 	_cursoron = 1;	/* to force it off */
4611496Sralph 	_escmode = NONE;
4711496Sralph 	curoff();
4811496Sralph 	clearg();
4911496Sralph 	gon();
5011496Sralph 	aoff();
5111496Sralph }
5211496Sralph 
done()5311496Sralph done()
5411496Sralph {
5511496Sralph 	goff();
5611496Sralph 	koff();
5711496Sralph 	aon();
5811496Sralph 	sync();
5911496Sralph 	escseq(NONE);
6011496Sralph 	lowleft();
6111496Sralph 	printf("\n");
6211496Sralph 	fflush(stdout);
6311496Sralph 	_ttyb.sg_flags = _normf;
6411496Sralph 	ioctl(fileno(stdin), TIOCSETN, &_ttyb);
6511496Sralph 	ioctl(fileno(stdin), TIOCSETC, &_otch);
6611496Sralph }
67