6.5 Predefined Variables and Constants

The <curses.h> header file defines variables and constants useful for implementing Curses (see Table 6-2).

Table 6-2 Curses Predefined Variables and #define Constants

Name  Type  Description 
curscr  WINDOW *  Window of current screen 
stdscr  WINDOW *  Default window 
LINES  int  Number of lines on the terminal screen 
COLS  int  Number of columns on the terminal screen 
ERR  -   Flag (0) for failed routines 
OK  Flag (1) for successful routines 
TRUE  Boolean true flag (1) 
FALSE  Boolean false flag (0) 
_BLINK  Parameter for setattr and clrattr 
_BOLD  Parameter for setattr and clrattr 
_ REVERSE  Parameter for setattr and clrattr 
_UNDERLINE  -   Parameter for setattr and clrattr 

For example, you can use the predefined macro ERR to test the success or failure of a Curses function. Example 6-4 shows how to perform such a test.

Example 6-4 Curses Predefined Variables

#include <curses.h>

WINDOW  *win1, *win2, *win3;

main()
{
   initscr();
   win1 = newwin(10, 10, 1, 5);
      .
      .
      .
   if (mvwin(win1, 1, 10) == ERR)
      addstr("The MVWIN function failed.");
      .
      .
      .
   endwin();
}

In Example 6-4, if the mvwin function fails, the program adds a string to stdscr that explains the outcome. The Curses mvwin function moves the starting position of a window.


Previous Page | Next Page | Table of Contents | Index