xref: /csrg-svn/old/lib2648/ttyinit.c (revision 11496)
1 /*	ttyinit.c	4.1	83/03/09	*/
2 /*
3  * sgtty stuff
4  */
5 
6 #include <sgtty.h>
7 
8 struct	sgttyb	_ttyb;
9 struct	tchars	_otch, _ntch;
10 int	_normf;
11 
12 /*
13  * Routines for dealing with the unix tty modes
14  */
15 
16 #include "2648.h"
17 
18 ttyinit()
19 {
20 	if (strcmp(getenv("TERM"), "hp2648") == 0)
21 		_on2648 = 1;
22 	ioctl(fileno(stdin), TIOCGETP, &_ttyb);
23 	ioctl(fileno(stdin), TIOCGETC, &_otch);
24 	_ntch = _otch;
25 	_ntch.t_quitc = _ntch.t_startc = _ntch.t_stopc = -1;
26 	_normf = _ttyb.sg_flags;
27 	_ttyb.sg_flags |= CBREAK;
28 	_ttyb.sg_flags &= ~(ECHO|CRMOD);
29 	ioctl(fileno(stdin), TIOCSETN, &_ttyb);
30 	ioctl(fileno(stdin), TIOCSETC, &_ntch);
31 	gdefault();
32 	zoomn(1);
33 	zoomon();
34 	kon();
35 	rboff();
36 	_cursoron = 1;	/* to force it off */
37 	_escmode = NONE;
38 	curoff();
39 	clearg();
40 	gon();
41 	aoff();
42 }
43 
44 done()
45 {
46 	goff();
47 	koff();
48 	aon();
49 	sync();
50 	escseq(NONE);
51 	lowleft();
52 	printf("\n");
53 	fflush(stdout);
54 	_ttyb.sg_flags = _normf;
55 	ioctl(fileno(stdin), TIOCSETN, &_ttyb);
56 	ioctl(fileno(stdin), TIOCSETC, &_otch);
57 }
58