date and time created 83/05/31 00:19:54 by sam
[unix-history] / usr / src / lib / libcurses / initscr.c
CommitLineData
fa02ff96 1# include "curses.ext"
4bffae9a 2# include <signal.h>
cac32540 3# include <sys/param.h>
fa02ff96
KA
4
5extern char *getenv();
6
7/*
8 * This routine initializes the current and standard screen.
9 *
cac32540 10 * %G% (Berkeley) @(#)initscr.c 1.3
fa02ff96
KA
11 */
12WINDOW *
13initscr() {
14
15 reg char *sp;
4bffae9a 16 int tstp();
fa02ff96
KA
17
18# ifdef DEBUG
19 fprintf(outf, "INITSCR()\n");
20# endif
cac32540
KA
21 if (My_term)
22 setterm(Def_term);
23 else {
24 if (isatty(2))
25 _tty_ch = 2;
26 else {
27 for (_tty_ch = 0; _tty_ch < NOFILE; _tty_ch++)
28 if (isatty(_tty_ch))
29 break;
30 }
fa02ff96
KA
31 gettmode();
32 if ((sp = getenv("TERM")) == NULL)
33 sp = Def_term;
34 setterm(sp);
35# ifdef DEBUG
36 fprintf(outf, "INITSCR: term = %s\n", sp);
37# endif
38 }
fa02ff96
KA
39 _puts(TI);
40 _puts(VS);
4bffae9a
KA
41# ifdef SIGTSTP
42 signal(SIGTSTP, tstp);
43# endif
fa02ff96
KA
44 if (curscr != NULL) {
45# ifdef DEBUG
46 fprintf(outf, "INITSCR: curscr = 0%o\n", curscr);
47# endif
48 delwin(curscr);
49 }
50# ifdef DEBUG
51 fprintf(outf, "LINES = %d, COLS = %d\n", LINES, COLS);
52# endif
4bffae9a 53 if ((curscr = newwin(LINES, COLS, 0, 0)) == ERR)
fa02ff96
KA
54 return ERR;
55 curscr->_clear = TRUE;
56 if (stdscr != NULL) {
57# ifdef DEBUG
58 fprintf(outf, "INITSCR: stdscr = 0%o\n", stdscr);
59# endif
60 delwin(stdscr);
61 }
62 stdscr = newwin(LINES, COLS, 0, 0);
63 return stdscr;
64}