aboutsummaryrefslogtreecommitdiff
path: root/lib/libncurses/doc/color.doc
blob: 55f33466a454dcc87940b3397b295ebf49ede723 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

	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