xref: /titanic_50/usr/src/ucblib/libcurses/initscr.c (revision 74e20cfe817b82802b16fac8690dadcda76f54f5)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
16 
17 /*LINTLIBRARY*/
18 
19 #ifndef lint
20 static char
21 sccsid[] = "@(#)initscr.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */
22 #endif /* not lint */
23 
24 #include	"curses.ext"
25 #include	<term.h>
26 #include	<stdlib.h>
27 #include	<signal.h>
28 
29 /*
30  *	This routine initializes the current and standard screen.
31  */
32 
33 WINDOW *
34 initscr(void)
35 {
36 	char	*sp;
37 
38 #ifdef DEBUG
39 	fprintf(outf, "INITSCR()\n");
40 #endif
41 	if (My_term)
42 		(void) setterm(Def_term);
43 	else {
44 		(void) gettmode();
45 		if ((sp = getenv("TERM")) == NULL)
46 			sp = Def_term;
47 		(void) setterm(sp);
48 #ifdef DEBUG
49 		fprintf(outf, "INITSCR: term = %s\n", sp);
50 #endif
51 	}
52 	(void) _puts(TI);
53 	(void) _puts(VS);
54 #ifdef SIGTSTP
55 	(void) signal(SIGTSTP, (void(*)(int))tstp);
56 #endif
57 	if (curscr != NULL) {
58 #ifdef DEBUG
59 		fprintf(outf, "INITSCR: curscr = 0%o\n", curscr);
60 #endif
61 		(void) delwin(curscr);
62 	}
63 #ifdef DEBUG
64 	fprintf(outf, "LINES = %d, COLS = %d\n", LINES, COLS);
65 #endif
66 	if ((curscr = newwin(LINES, COLS, 0, 0)) == ERR)
67 		return (ERR);
68 	clearok(curscr, TRUE);
69 	curscr->_flags &= ~_FULLLINE;
70 	if (stdscr != NULL) {
71 #ifdef DEBUG
72 		fprintf(outf, "INITSCR: stdscr = 0%o\n", stdscr);
73 #endif
74 		(void) delwin(stdscr);
75 	}
76 	stdscr = newwin(LINES, COLS, 0, 0);
77 	return (stdscr);
78 }
79