2 /***************************************************************************
4 ****************************************************************************
5 * ncurses is copyright (C) 1992-1995 *
7 * zmbenhal@netcom.com *
9 * esr@snark.thyrsus.com *
11 * Permission is hereby granted to reproduce and distribute ncurses *
12 * by any means and for any fee, whether alone or as part of a *
13 * larger distribution, in source or in binary form, PROVIDED *
14 * this notice is included with any such distribution, and is not *
15 * removed from any of its header files. Mention of ncurses in any *
16 * applications linked with it is highly appreciated. *
18 * ncurses comes AS IS with no warranty, implied or expressed. *
20 ***************************************************************************/
27 ** The newterm() function.
31 #include <curses.priv.h>
37 #include <term.h> /* clear_screen, cup & friends, cur_term */
39 MODULE_ID("$Id: lib_newterm.c,v 1.23 1997/03/30 01:42:01 tom Exp $")
41 /* This should be moved to TERMINAL */
42 static int filter_mode = FALSE;
49 SCREEN * newterm(const char *term, FILE *ofp, FILE *ifp)
53 char *t = getenv("NCURSES_TRACE");
56 trace((unsigned) strtol(t, 0, 0));
59 T((T_CALLED("newterm(\"%s\",%p,%p)"), term, ofp, ifp));
61 /* this loads the capability entry, then sets LINES and COLS */
62 if (setupterm(term, fileno(ofp), &errret) == ERR)
66 * Check for mismatched graphic-rendition capabilities. Most SVr4
67 * terminfo tree contain entries that have rmul or rmso equated to sgr0
68 * (Solaris curses copes with those entries). We do this only for
69 * curses, since many termcap applications assume that smso/rmso and
70 * smul/rmul are paired, and will not function properly if we remove
71 * rmso or rmul. Curses applications shouldn't be looking at this
74 if (exit_attribute_mode) {
75 #define SGR0_FIX(mode) if (mode != 0 && !strcmp(mode, exit_attribute_mode)) \
77 SGR0_FIX(exit_underline_mode);
78 SGR0_FIX(exit_standout_mode);
81 /* implement filter mode */
89 #endif /* init_tabs */
92 T(("TABSIZE = %d", TABSIZE));
95 clear_screen = (char *)NULL;
96 cursor_down = parm_down_cursor = (char *)NULL;
97 cursor_address = (char *)NULL;
98 cursor_up = parm_up_cursor = (char *)NULL;
99 row_address = (char *)NULL;
101 cursor_home = carriage_return;
102 #endif /* clear_screen */
105 /* If we must simulate soft labels, grab off the line to be used.
106 We assume that we must simulate, if it is none of the standard
107 formats (4-4 or 3-2-3) for which there may be some hardware
110 if (num_labels <= 0 || !SLK_STDFMT)
111 #endif /* num_labels */
114 if (ERR==_nc_ripoffline(-SLK_LINES, _nc_slk_initialize))
117 /* this actually allocates the screen structure, and saves the
118 * original terminal settings.
120 if (_nc_setupscreen(LINES, COLS, ofp) == ERR)
124 /* if the terminal type has real soft labels, set those up */
125 if (_nc_slk_format && num_labels > 0 && SLK_STDFMT)
126 _nc_slk_initialize(stdscr, COLS);
127 #endif /* num_labels */
129 SP->_ifd = fileno(ifp);
130 SP->_checkfd = fileno(ifp);
131 typeahead(fileno(ifp));
133 SP->_use_meta = ((cur_term->Ottyb.c_cflag & CSIZE) == CS8 &&
134 !(cur_term->Ottyb.c_iflag & ISTRIP));
136 SP->_use_meta = FALSE;
140 baudrate(); /* sets a field in the SP structure */
142 /* compute movement costs so we can do better move optimization */
145 _nc_signal_handler(TRUE);
147 /* open a connection to the screen's associated mouse, if any */
150 /* Initialize the terminal line settings. */
153 T((T_RETURN("%p"), SP));