NAME | SYNOPSIS | PARAMETERS | DESCRIPTION | RETURN VALUES | ERRORS | SEE ALSO
#include <curses.h>bool can_change_color(void);
Is the number of the color for which to provide information (0 to COLORS).
Is a pointer to the RGB value for the amount of red in color.
Is a pointer to the RGB value for the amount of green in color.
Is a pointer to the RGB value for the amount of blue in color.
Is the number of a color pair.
Is the number of the color pair for which to provide information (1 to COLOR_PAIRS).
Is a pointer to the number of the foreground color (0 to COLORS) in pair.
Is a pointer to the number of the background color (0 to COLORS ) in pair.
Is a color attribute value.
The start_color() function initializes the use of color. It must be used if color is to be used in the program. It must be called before any other color functions, ideally right after initscr(3XC). Eight basic colors are initialized (black, red, green, yellow, blue, magenta, cyan, and white) and two global variables (COLORS and COLOR_PAIRS). The former variable specifies the number of colors the terminal supports, the latter the number of color pairs. Colors are always in pairs consisting of a foreground color (for characters) and a background color (for the the rest of the character cell). The initial appearance of these colors is unspecified.
The init_pair() function initializes a color pair so that it can be used as a parameter. COLOR_PAIR() can be used as an attribute and as a parameter to functions like attr_set(3XC). Its first parameter is the number of the color pair to be changed; the second parameter is the number of the foreground color; the third parameter is the number of the background color. The maximum number of color pairs and colors the terminal can support are defined in the global variables COLOR_PAIRS and COLORS, respectively.
Color pair 0 (zero) is reserved for use by X/Open Curses.
Each time that a color pair is initialized, the screen is refreshed and all occurrences of that color pair are updated to reflect the new definition.
The init_color() function redefines the color using the number of the color and the RGB values for red, green, and blue as parameters.
The following default colors are defined (X/Open Curses assumes that COLOR_BLACK is the default background color for all terminals):
COLOR_BLACK COLOR_RED COLOR_GREEN COLOR_YELLOW COLOR_BLUE COLOR_MAGENTA COLOR_CYAN COLOR_WHITE
Each time that a color is redefined with the init_color() function, the screen is refreshed and all occurrences of that color are updated to reflect the new definition.
The can_change_color() function returns TRUE if the terminal supports color and the colors can be changed. The has_colors() function returns TRUE if the terminal supports color. These functions are useful when writing terminal-independent programs. They can be used to determine whether to replace color with another attribute on a particular terminal.
The color_content() function provides information on the amount of red, green, and blue in a particular color. The intensity of each color is stored in the addresses pointed to by the r, g, andb parameters, respectively. The values passed back range from 0 (zero) (no component of that color) to 1000 (maximum amount of component).
The pair_content() function provides information on what colors compose the specified color pair. The numbers of the foreground and background colors are passed back in the addresses pointed to by the fg and bg parameters, respectively. The values stored in fg and bg range from 0 (zero) to COLORS.
The has_colors() function returns TRUE if the terminal is able to handle colors. Otherwise, it returns FALSE.
The can_change_color() function returns TRUE if the terminal supports colors and is able to change their definitions. Otherwise, it returns FALSE.
On success, the other functions return OK. Otherwise, they return ERR.
None.
NAME | SYNOPSIS | PARAMETERS | DESCRIPTION | RETURN VALUES | ERRORS | SEE ALSO