|
|
1.1 root 1: /*
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
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.
16: */
17:
18: #ifndef COHERENT
19: #ifndef lint
20: static uchar sccsid[] = "@(#)initscr.c 5.3 (Berkeley) 6/30/88";
21: #endif /* not lint */
22: #endif /* not COHERENT */
23:
24: # include <stdio.h>
25: # include "curses.ext"
26: # include <signal.h>
27:
28: extern uchar *getenv();
29:
30: /*
31: * This routine initializes the current and standard screen.
32: *
33: */
34: WINDOW *
35: initscr() {
36:
37: reg uchar *sp;
38: extern int tstp();
39:
40: # ifdef DEBUG
41: if ( outf == NULL )
42: outf = stderr;
43: fprintf(outf, "INITSCR()\n");
44: # endif
45:
46: if (My_term)
47: setterm(Def_term);
48: else {
49: for (_tty_ch = 0; _tty_ch < 20; _tty_ch++)
50: if (isatty(_tty_ch))
51: break;
52: gettmode();
53: if ((sp = getenv("TERM")) == NULL)
54: sp = Def_term;
55: setterm(sp);
56: # ifdef DEBUG
57: fprintf(outf, "INITSCR: term = %s\n", sp);
58: # endif
59: }
60: _puts(TI);
61: _puts(VS);
62: # ifdef SIGTSTP
63: signal(SIGTSTP, tstp);
64: # endif
65: if (curscr != NULL) {
66: # ifdef DEBUG
67: fprintf(outf, "INITSCR: curscr = 0%o\n", curscr);
68: # endif
69: delwin(curscr);
70: }
71: # ifdef DEBUG
72: fprintf(outf, "LINES = %d, COLS = %d\n", LINES, COLS);
73: # endif
74: if ((curscr = newwin(LINES, COLS, 0, 0)) == ERR)
75: return ERR;
76: clearok(curscr, TRUE);
77: curscr->_flags &= ~_FULLLINE;
78: if (stdscr != NULL) {
79: # ifdef DEBUG
80: fprintf(outf, "INITSCR: stdscr = 0%o\n", stdscr);
81: # endif
82: delwin(stdscr);
83: }
84: stdscr = newwin(LINES, COLS, 0, 0);
85: return stdscr;
86: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.