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 ***************************************************************************/
25 ** The routines initscr(), and termname().
29 #include <curses.priv.h>
30 #include <term.h> /* cur_term */
33 #include <sys/termio.h> /* needed for ISC */
36 MODULE_ID("$Id: lib_initscr.c,v 1.18 1997/03/08 14:03:59 tom Exp $")
38 #ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */
43 * SVr4/XSI Curses specify that hardware echo is turned off in initscr, and not
44 * restored during the curses session. The library simulates echo in software.
45 * (The behavior is unspecified if the application enables hardware echo).
47 * The newterm function also initializes terminal settings.
51 /* for extended XPG4 conformance requires cbreak() at this point */
52 /* (SVr4 curses does this anyway) */
56 cur_term->Nttyb.c_lflag &= ~(ECHO|ECHONL);
57 cur_term->Nttyb.c_iflag &= ~(ICRNL|INLCR|IGNCR);
58 cur_term->Nttyb.c_oflag &= ~(ONLCR);
60 cur_term->Nttyb.sg_flags &= ~(ECHO|CRMOD);
62 if ((SET_TTY(cur_term->Filedes, &cur_term->Nttyb)) == -1)
69 static bool initialized = FALSE;
72 T((T_CALLED("initscr()")));
73 /* Portable applications must not call initscr() more than once */
77 if ((name = getenv("TERM")) == 0)
79 if (newterm(name, stdout, stdin) == 0) {
80 fprintf(stderr, "Error opening terminal: %s.\n", name);
84 /* allow user to set maximum escape delay from the environment */
85 if ((name = getenv("ESCDELAY")) != 0)
86 ESCDELAY = atoi(getenv("ESCDELAY"));
88 /* def_shell_mode - done in newterm/_nc_setupscreen */
96 char *term = getenv("TERM");
99 T(("termname() called"));
102 (void) strncpy(ret, term, sizeof(ret) - 1);