[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs

Initializing Curses

initscr Initializes the curses subroutine library and its data structures
newterm Sets up a new terminal
setupterm Sets up the TERMINAL structure for use by curses
endwin Terminates the curses subroutine libraries and their data structures
isendwin Returns TRUE if the endwin subroutine has been called without any subsequent calls to the wrefresh subroutine

You must include the curses.h file at the beginning of any program that calls curses subroutines. To do this, use the following statement:

#include <curses.h>

Before you can call subroutines that manipulate windows or screens, you must call the initscr or newterm subroutine. These subroutines first save the terminal's settings. These subroutines then call the setupterm subroutine to establish a curses terminal.

If you need to temporarily suspend curses, use a shell escape or system call for example. To resume after a temporary escape, you should call the wrefresh or doupdate subroutine. Before exiting a curses program, you must call the endwin subroutine. The endwin subroutine restores tty modes, moves the cursor to the lower left corner of the screen, and resets the terminal into the proper nonvisual mode.

Most interactive, screen-oriented programs require character-at-a-time input without echoing the result to the screen. To establish your program with character-at-a-time input, call the cbreak and noecho subroutines after calling the initscr subroutine. When accepting this type of input, programs should also call the following subroutines:

The isendwin subroutine is helpful if, for optimization reasons, you don't want to call the wrefresh subroutine needlessly. You can determine if the endwin subroutine was called without any subsequent calls to the wrefresh subroutine by using the isendwin subroutine.

Related Information

Curses Overview for Programming

Windows in the Curses Environment

List of Additional Curses Subroutines


[ Previous | Next | Contents | Glossary | Home | Search ]