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

General Programming Concepts:
Writing and Debugging Programs

Initializing Curses

Use the following commnads to initialize curses:

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

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 and then call the setupterm subroutine to establish a curses terminal.

If you need to temporarily suspend curses, use a shell escape or subroutine. To resume after a temporary escape, 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 do not want to call the wrefresh subroutine needlessly. To determine if the endwin subroutine was called without any subsequent calls to the wrefresh subroutine, use the isendwin subroutine.

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