Initializing curses
This section describes the commands used for initializing curses.
Use the following commands to initialize curses:
Command | Description |
---|---|
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 |
#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.
- nonl subroutine.
- intrflush subroutine with the Window parameter set to the stdscr and the Flag parameter set to FALSE. The Window parameter is required but ignored. You can use stdscr as the value of the Window parameter, because stdscr is already created for you.
- keypad subroutine with the Window parameter set to the stdscr and the Flag parameter set to TRUE.
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.