|
|
1.1 root 1: /*********************************************************************
2: * COPYRIGHT NOTICE *
3: **********************************************************************
4: * This software is copyright (C) 1982 by Pavel Curtis *
5: * *
6: * Permission is granted to reproduce and distribute *
7: * this file by any means so long as no fee is charged *
8: * above a nominal handling fee and so long as this *
9: * notice is always included in the copies. *
10: * *
11: * Other rights are reserved except as explicitly granted *
12: * by written permission of the author. *
13: * Pavel Curtis *
14: * Computer Science Dept. *
15: * 405 Upson Hall *
16: * Cornell University *
17: * Ithaca, NY 14853 *
18: * *
19: * Ph- (607) 256-4934 *
20: * *
21: * Pavel.Cornell@Udel-Relay (ARPAnet) *
22: * decvax!cornell!pavel (UUCPnet) *
23: *********************************************************************/
24:
25: /*
26: ** lib_newterm.c
27: **
28: ** The newterm() function.
29: **
30: ** $Log: RCS/lib_newterm.v $
31: * Revision 2.2 91/07/28 12:41:35 munk
32: * Print error message if terminal not found
33: *
34: * Revision 2.1 82/10/25 14:48:14 pavel
35: * Added Copyright Notice
36: *
37: * Revision 2.0 82/10/25 13:47:11 pavel
38: * Beta-one Test Release
39: *
40: **
41: */
42:
43: #ifdef RCSHDR
44: static char RCSid[] =
45: "$Header: RCS/lib_newterm.v Revision 2.2 91/07/85 12:41:35 munk Exp$";
46: #endif
47:
48: #include <signal.h>
49: #include <stdio.h>
50: #include "curses.h"
51: #include "term.h"
52: #include "curses.priv.h"
53:
54:
55:
56: struct screen *
57: newterm(term, fp)
58: char *term;
59: FILE *fp;
60: {
61: int errret;
62: int tstp();
63: char *malloc();
64:
65: #ifdef TRACE
66: _init_trace();
67:
68: if (_tracing)
69: _tracef("newterm(%s,%o) called", term, fp);
70: #endif
71:
72: /* if (setupterm(term, fileno(fp), &errret) != 1) */
73: if (setupterm(term, fileno(fp), 0) != 1)
74: return(ERR);
75:
76: if ((SP = (struct screen *) malloc(sizeof *SP)) == NULL)
77: return(ERR);
78:
79: if (fp == stdout)
80: {
81: SP->_ofp = stdout;
82: SP->_ifp = stdin;
83: }
84: else
85: {
86: SP->_ofp = fp;
87: SP->_ifp = fp;
88: }
89: SP->_term = cur_term;
90: SP->_cursrow = -1;
91: SP->_curscol = -1;
92: SP->_keytry = UNINITIALISED;
93: SP->_nl = TRUE;
94: SP->_raw = FALSE;
95: SP->_cbreak = FALSE;
96: SP->_echo = TRUE;
97: SP->_nlmapping = TRUE;
98: SP->_costinit = FALSE;
99:
100: LINES = lines;
101: COLS = columns;
102:
103: if (enter_ca_mode)
104: putp(enter_ca_mode);
105:
106: if ((newscr = newwin(lines, columns, 0, 0)) == ERR)
107: return(ERR);
108:
109: if ((curscr = newwin(lines, columns, 0, 0)) == ERR)
110: return(ERR);
111:
112: SP->_newscr = newscr;
113: SP->_curscr = curscr;
114:
115: newscr->_clear = TRUE;
116: curscr->_clear = FALSE;
117:
118: #ifdef SIGTSTP
119: signal(SIGTSTP, tstp);
120: #endif
121:
122: if (stdscr == NULL)
123: if ((stdscr = newwin(lines, columns, 0, 0)) == ERR)
124: return(ERR);
125:
126: #ifdef TRACE
127: if (_tracing)
128: _tracef("\tnewterm returns %o", SP);
129: #endif
130:
131: return(SP);
132: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.