This section explains some of the Curses terminology and shows you how Curses looks on the terminal screen.
Consider a Curses application as being a series of overlapping windows. Window overlapping is called occlusion. To distinguish the boundaries of these occluding windows, you can outline the rectangular windows with specified characters, or you can turn on the reverse video option (make the window a light background with dark writing).
Initially, two windows the size of the terminal screen are predefined by Curses. These windows are called stdscr and curscr. The stdscr window is defined for your use. Many Curses macros default to this window. For example, if you draw a box around stdscr, move the cursor to the left-corner area of the screen, write a string to stdscr, and then display stdscr on the terminal screen, your display will look like that in Figure 6-1.
The second predefined window, curscr, is designed for internal Curses work; it is an image of what is currently displayed on the terminal screen. The only DEC C for OpenVMS Curses function that will accept this window as an argument is clearok. Do not write to or read from curscr. Use stdscr and user-defined windows for all your Curses applications.
You can occlude stdscr with your own windows. The size and location of each window is given in terms of the number of lines, the number of columns, and the starting position.
The lines and columns of the terminal screen form a coordinate system, or grid, on which the windows are formed. You specify the starting position of a window with the (y,x) coordinates on the terminal screen where the upper left corner of the window is located. The coordinates (0,0) on the terminal screen, for example, are the upper left corner of the screen.
The entire area of the window must be within the terminal screen borders; windows can be as small as a single character or as large as the entire terminal screen. You can create as many windows as memory allows.
When writing to or deleting from windows, changes do not appear on the terminal screen until the window is refreshed. When refreshing a window, you place the updated window onto the terminal screen, which leaves the rest of the screen unaltered.
All user-defined windows, by default, occlude stdscr. You can create two or more windows that occlude each other as well as stdscr. When writing data to one occluding window, the data is not written to the underlying window.
You can create overlapping windows (called subwindows). A declared window must contain the entire area of its subwindow. When writing data to a subwindow or to the portion of the window overlapped by the subwindow, both windows contain the new data. For instance, if you write data to a subwindow and then delete that subwindow, the data is still present on the underlying window.
If you create a window that occludes stdscr and a subwindow of stdscr, your terminal screen will look like Figure 6-2.
If you delete both the user-defined window and the subwindow, and then update the terminal screen with the new image, your terminal screen will look like Figure 6-3.
The string written on the window is deleted, but the string written on the subwindow remains on stdscr.