72 lines
2.3 KiB
Plaintext
72 lines
2.3 KiB
Plaintext
|
|
5.10. Color Manipulation
|
|
|
|
Ncurses provides support for the use of color on terminals
|
|
that are capable of display it. Note the BSD and older SYSV
|
|
curses don't support color. Color support in the PC version
|
|
is not compatible with SYSR4.
|
|
|
|
has_colors()
|
|
this function returns TRUE if the terminal supports color,
|
|
FALSE otherwise. Other color handling funtions will return
|
|
ERR if has_colors() is FALSE. You should always check before
|
|
using color and use other video attributes to replace color.
|
|
|
|
can_change_color()
|
|
This function returns TRUE if the terminal is capable of
|
|
redefining colors using the init_color function, FALSE if it
|
|
can't. Don't use init_color and color_content if it returns
|
|
FALSE.
|
|
|
|
start_color()
|
|
This function must be called before any other color handling
|
|
function is called. It initializes the 8 basic colors (see
|
|
appendix I) and sets the global variables COLORS and COLOR_
|
|
PAIRS to the maximum number of colors and color-pairs a
|
|
terminal can handle.
|
|
|
|
init_pair(pair, fg, bg)
|
|
This function changes the definition of a color-pair, pair.
|
|
Each pair has a foregroung color fg, and a background color
|
|
bg. Both values must be between 0 and COLORS-1. pair must be
|
|
between 1 and COLOR_PAIRS-1.
|
|
[If a pair is changed from a previous definition, the screen
|
|
is refreshed and all occurances of the color-pair are
|
|
changed to reflect the change.]
|
|
|
|
pair_content(pair, f, b)
|
|
This function stores the foreground and background colors of
|
|
the color-pair pair into the variables pointed to by f, b.
|
|
pair should be between 1 and COLOR_PAIRS-1.
|
|
|
|
init_color(color, r, g, b)
|
|
This function changes the value of a given color. A color is
|
|
defined by its red, green, and blue components, r, g, and b.
|
|
These values must be between 0 and 1000. color should be
|
|
between 0 and COLORS-1.
|
|
|
|
color_content(color, r, g, b)
|
|
This function puts the red, green, and blue components of
|
|
color into the variable pointed to by r, g, b respectively.
|
|
color should be between 0 and COLORS-1.
|
|
|
|
COLOR_PAIR(n) set color-pair to that stored in n
|
|
PAIR_NUMBER(a) get color-pair stored in attribute a
|
|
|
|
|
|
Appendix II: COLORS
|
|
-------------------
|
|
|
|
Colors are defined in <ncurses.h> are used with init_pair().
|
|
|
|
COLOR_BLACK 0
|
|
COLOR_RED 1
|
|
COLOR_GREEN 2
|
|
COLOR_YELLOW 3
|
|
COLOR_BLUE 4
|
|
COLOR_MAGENTA 5
|
|
COLOR_CYAN 6
|
|
COLOR_WHITE 7
|
|
|
|
|