Commit | Line | Data |
---|---|---|
6e1c93d0 | 1 | /* |
2f14f200 KB |
2 | * Copyright (c) 1981 Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms are permitted | |
a399f6c8 KB |
6 | * provided that the above copyright notice and this paragraph are |
7 | * duplicated in all such forms and that any documentation, | |
8 | * advertising materials, and other materials related to such | |
9 | * distribution and use acknowledge that the software was developed | |
10 | * by the University of California, Berkeley. The name of the | |
11 | * University may not be used to endorse or promote products derived | |
12 | * from this software without specific prior written permission. | |
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
15 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
6e1c93d0 DF |
16 | */ |
17 | ||
18 | #ifndef lint | |
a399f6c8 | 19 | static char sccsid[] = "@(#)initscr.c 5.3 (Berkeley) %G%"; |
2f14f200 | 20 | #endif /* not lint */ |
6e1c93d0 | 21 | |
fa02ff96 | 22 | # include "curses.ext" |
4bffae9a | 23 | # include <signal.h> |
fa02ff96 KA |
24 | |
25 | extern char *getenv(); | |
26 | ||
27 | /* | |
28 | * This routine initializes the current and standard screen. | |
29 | * | |
fa02ff96 KA |
30 | */ |
31 | WINDOW * | |
32 | initscr() { | |
33 | ||
34 | reg char *sp; | |
4bffae9a | 35 | int tstp(); |
2557a18e | 36 | int nfd; |
fa02ff96 KA |
37 | |
38 | # ifdef DEBUG | |
39 | fprintf(outf, "INITSCR()\n"); | |
40 | # endif | |
cac32540 KA |
41 | if (My_term) |
42 | setterm(Def_term); | |
43 | else { | |
ffd04853 JB |
44 | for (_tty_ch = 0; _tty_ch < nfd; _tty_ch++) |
45 | if (isatty(_tty_ch)) | |
46 | break; | |
fa02ff96 KA |
47 | gettmode(); |
48 | if ((sp = getenv("TERM")) == NULL) | |
49 | sp = Def_term; | |
50 | setterm(sp); | |
51 | # ifdef DEBUG | |
52 | fprintf(outf, "INITSCR: term = %s\n", sp); | |
53 | # endif | |
54 | } | |
fa02ff96 KA |
55 | _puts(TI); |
56 | _puts(VS); | |
4bffae9a KA |
57 | # ifdef SIGTSTP |
58 | signal(SIGTSTP, tstp); | |
59 | # endif | |
fa02ff96 KA |
60 | if (curscr != NULL) { |
61 | # ifdef DEBUG | |
62 | fprintf(outf, "INITSCR: curscr = 0%o\n", curscr); | |
63 | # endif | |
64 | delwin(curscr); | |
65 | } | |
66 | # ifdef DEBUG | |
67 | fprintf(outf, "LINES = %d, COLS = %d\n", LINES, COLS); | |
68 | # endif | |
4bffae9a | 69 | if ((curscr = newwin(LINES, COLS, 0, 0)) == ERR) |
fa02ff96 | 70 | return ERR; |
62fc2477 JB |
71 | clearok(curscr, TRUE); |
72 | curscr->_flags &= ~_FULLLINE; | |
fa02ff96 KA |
73 | if (stdscr != NULL) { |
74 | # ifdef DEBUG | |
75 | fprintf(outf, "INITSCR: stdscr = 0%o\n", stdscr); | |
76 | # endif | |
77 | delwin(stdscr); | |
78 | } | |
79 | stdscr = newwin(LINES, COLS, 0, 0); | |
80 | return stdscr; | |
81 | } |