[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions , Volume 2

initscr and newterm Subroutine


Initializes curses and its data structures.


Curses Library (libcurses.a)


#include <curses.h>

WINDOW *initscr(void);

SCREEN *newterm(char *type,
FILE *outfile,
FILE *infile);


The initscr subroutine determines the terminal type and initializes all implementation data structures. The TERM environment variable specifies the terminal type. The initscr subroutine also causes the first refresh operation to clear the screen. If errors occur, initscr writes an appropriate error message to standard error and exits. The only subroutines that can be called before initscr or newterm are the filter, ripoffline, slk_init, use_env, and the subroutines whose prototypes are defined in <term.h>. Portable applications must not call initscr twice.

The newterm subroutine can be called as many times as desired to attach a terminal device. The type argument points to a string specifying the terminal type, except that, if type is a null pointer, the TERM environment variable is used. The outfile and infile arguments are file pointers for output to the terminal and input from the terminal, respectively. It is unspecified whether Curses modifies the buffering mode of these file pointers. The newterm subroutine should be called once for each terminal.

The initscr subroutine is equivalent to:

newterm(gentenv("TERM"), stdout, stdin); return stdscr;

If the current disposition for the signals SIGINT, SIGQUIT or SIGTSTP is SIGDFL, then the initscr subroutine may also install a handler for the signal, which may remain in effect for the life of the process or until the process changes the disposition of the signal.

The initscr and newterm subroutines initialise the cur_term external variable.

initscr           CURSES           Curses Interfaces

Return Values

Upon successful completion, the initscr subroutine returns a pointer to stdscr. Otherwise, it does not return.

Upon successful completion, the newterm subroutine returns a pointer to the specified terminal. Otherwise, it returns a null pointer.


To initialize curses so that other curses subroutines can be called, use:


Implementation Specifics

This subroutine is part of Base Operating System (BOS) Runtime.

Related Information

The doupdate (doupdate, refresh, wnoutrefresh, or wrefresh Subroutines) subroutine, del_curterm (del_curterm, restartterm, set_curterm, or setupterm Subroutine) subroutine, filter (filter Subroutine) subroutine, slk_attroff (slk_attroff, slk_attr_off, slk_attron, slk_attrset, slk_attr_set, slk_clear, slk_color, slk_init, slk_label, slk_noutrefresh, slk_refresh, slk_restore, slk_set, slk_touch, slk_wset, Subroutine) subroutine, setupterm (setupterm Subroutine) subroutine.

Curses Overview for Programming, Initializing Curses, List of Curses Subroutines in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.

[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]