Back to index

tetex-bin  3.0
Functions
lib_initscr.c File Reference
#include <curses.priv.h>

Go to the source code of this file.

Functions

 initscr (void)

Function Documentation

initscr ( void  )

Definition at line 51 of file lib_initscr.c.

{
    static bool initialized = FALSE;
    NCURSES_CONST char *name;
    int value;

    START_TRACE();
    T((T_CALLED("initscr()")));
    /* Portable applications must not call initscr() more than once */
    if (!initialized) {
       initialized = TRUE;

       if ((name = getenv("TERM")) == 0
           || *name == '\0')
           name = "unknown";
#ifdef __CYGWIN__
       /*
        * 2002/9/21
        * Work around a bug in Cygwin.  Full-screen subprocesses run from
        * bash, in turn spawned from another full-screen process, will dump
        * core when attempting to write to stdout.  Opening /dev/tty
        * explicitly seems to fix the problem.
        */
       if (isatty(fileno(stdout))) {
           FILE *fp = fopen("/dev/tty", "w");
           if (fp != 0 && isatty(fileno(fp))) {
              fclose(stdout);
              dup2(fileno(fp), STDOUT_FILENO);
              stdout = fdopen(STDOUT_FILENO, "w");
           }
       }
#endif
       if (newterm(name, stdout, stdin) == 0) {
           fprintf(stderr, "Error opening terminal: %s.\n", name);
           exit(EXIT_FAILURE);
       }

       /* allow user to set maximum escape delay from the environment */
       if ((value = _nc_getenv_num("ESCDELAY")) >= 0) {
           ESCDELAY = value;
       }

       /* def_shell_mode - done in newterm/_nc_setupscreen */
       def_prog_mode();
    }
    returnWin(stdscr);
}

Here is the call graph for this function:

Here is the caller graph for this function: