Commit | Line | Data |
---|---|---|
6e1c93d0 DF |
1 | /* |
2 | * Copyright (c) 1980 Regents of the University of California. | |
3 | * All rights reserved. The Berkeley software License Agreement | |
4 | * specifies the terms and conditions for redistribution. | |
5 | */ | |
6 | ||
7 | #ifndef lint | |
8 | static char sccsid[] = "@(#)initscr.c 5.1 (Berkeley) %G%"; | |
9 | #endif not lint | |
10 | ||
fa02ff96 | 11 | # include "curses.ext" |
4bffae9a | 12 | # include <signal.h> |
fa02ff96 KA |
13 | |
14 | extern char *getenv(); | |
15 | ||
16 | /* | |
17 | * This routine initializes the current and standard screen. | |
18 | * | |
fa02ff96 KA |
19 | */ |
20 | WINDOW * | |
21 | initscr() { | |
22 | ||
23 | reg char *sp; | |
4bffae9a | 24 | int tstp(); |
2557a18e | 25 | int nfd; |
fa02ff96 KA |
26 | |
27 | # ifdef DEBUG | |
28 | fprintf(outf, "INITSCR()\n"); | |
29 | # endif | |
cac32540 KA |
30 | if (My_term) |
31 | setterm(Def_term); | |
32 | else { | |
ffd04853 JB |
33 | for (_tty_ch = 0; _tty_ch < nfd; _tty_ch++) |
34 | if (isatty(_tty_ch)) | |
35 | break; | |
fa02ff96 KA |
36 | gettmode(); |
37 | if ((sp = getenv("TERM")) == NULL) | |
38 | sp = Def_term; | |
39 | setterm(sp); | |
40 | # ifdef DEBUG | |
41 | fprintf(outf, "INITSCR: term = %s\n", sp); | |
42 | # endif | |
43 | } | |
fa02ff96 KA |
44 | _puts(TI); |
45 | _puts(VS); | |
4bffae9a KA |
46 | # ifdef SIGTSTP |
47 | signal(SIGTSTP, tstp); | |
48 | # endif | |
fa02ff96 KA |
49 | if (curscr != NULL) { |
50 | # ifdef DEBUG | |
51 | fprintf(outf, "INITSCR: curscr = 0%o\n", curscr); | |
52 | # endif | |
53 | delwin(curscr); | |
54 | } | |
55 | # ifdef DEBUG | |
56 | fprintf(outf, "LINES = %d, COLS = %d\n", LINES, COLS); | |
57 | # endif | |
4bffae9a | 58 | if ((curscr = newwin(LINES, COLS, 0, 0)) == ERR) |
fa02ff96 | 59 | return ERR; |
62fc2477 JB |
60 | clearok(curscr, TRUE); |
61 | curscr->_flags &= ~_FULLLINE; | |
fa02ff96 KA |
62 | if (stdscr != NULL) { |
63 | # ifdef DEBUG | |
64 | fprintf(outf, "INITSCR: stdscr = 0%o\n", stdscr); | |
65 | # endif | |
66 | delwin(stdscr); | |
67 | } | |
68 | stdscr = newwin(LINES, COLS, 0, 0); | |
69 | return stdscr; | |
70 | } |