1 /*
2  * Copyright 2001 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
7 /*	  All Rights Reserved  	*/
8 
9 /*
10  * Copyright (c) 1980 Regents of the University of California.
11  * All rights reserved.  The Berkeley software License Agreement
12  * specifies the terms and conditions for redistribution.
13  */
14 
15 /*LINTLIBRARY*/
16 
17 #ifndef lint
18 static char
19 sccsid[] = "@(#)initscr.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */
20 #endif /* not lint */
21 
22 #include	"curses.ext"
23 #include	<term.h>
24 #include	<stdlib.h>
25 #include	<signal.h>
26 
27 /*
28  *	This routine initializes the current and standard screen.
29  */
30 
31 WINDOW *
initscr(void)32 initscr(void)
33 {
34 	char	*sp;
35 
36 #ifdef DEBUG
37 	fprintf(outf, "INITSCR()\n");
38 #endif
39 	if (My_term)
40 		(void) setterm(Def_term);
41 	else {
42 		(void) gettmode();
43 		if ((sp = getenv("TERM")) == NULL)
44 			sp = Def_term;
45 		(void) setterm(sp);
46 #ifdef DEBUG
47 		fprintf(outf, "INITSCR: term = %s\n", sp);
48 #endif
49 	}
50 	(void) _puts(TI);
51 	(void) _puts(VS);
52 #ifdef SIGTSTP
53 	(void) signal(SIGTSTP, (void(*)(int))tstp);
54 #endif
55 	if (curscr != NULL) {
56 #ifdef DEBUG
57 		fprintf(outf, "INITSCR: curscr = 0%o\n", curscr);
58 #endif
59 		(void) delwin(curscr);
60 	}
61 #ifdef DEBUG
62 	fprintf(outf, "LINES = %d, COLS = %d\n", LINES, COLS);
63 #endif
64 	if ((curscr = newwin(LINES, COLS, 0, 0)) == ERR)
65 		return (ERR);
66 	clearok(curscr, TRUE);
67 	curscr->_flags &= ~_FULLLINE;
68 	if (stdscr != NULL) {
69 #ifdef DEBUG
70 		fprintf(outf, "INITSCR: stdscr = 0%o\n", stdscr);
71 #endif
72 		(void) delwin(stdscr);
73 	}
74 	stdscr = newwin(LINES, COLS, 0, 0);
75 	return (stdscr);
76 }
77