1*51ffecc1SBen Gras.\" $NetBSD: curses_color.3,v 1.12 2009/07/22 16:57:14 roy Exp $ 2*51ffecc1SBen Gras.\" Copyright (c) 2002 The NetBSD Foundation, Inc. 3*51ffecc1SBen Gras.\" All rights reserved. 4*51ffecc1SBen Gras.\" 5*51ffecc1SBen Gras.\" This code is derived from software contributed to The NetBSD Foundation 6*51ffecc1SBen Gras.\" by Julian Coleman. 7*51ffecc1SBen Gras.\" 8*51ffecc1SBen Gras.\" Redistribution and use in source and binary forms, with or without 9*51ffecc1SBen Gras.\" modification, are permitted provided that the following conditions 10*51ffecc1SBen Gras.\" are met: 11*51ffecc1SBen Gras.\" 1. Redistributions of source code must retain the above copyright 12*51ffecc1SBen Gras.\" notice, this list of conditions and the following disclaimer. 13*51ffecc1SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright 14*51ffecc1SBen Gras.\" notice, this list of conditions and the following disclaimer in the 15*51ffecc1SBen Gras.\" documentation and/or other materials provided with the distribution. 16*51ffecc1SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17*51ffecc1SBen Gras.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18*51ffecc1SBen Gras.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19*51ffecc1SBen Gras.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 20*51ffecc1SBen Gras.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21*51ffecc1SBen Gras.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22*51ffecc1SBen Gras.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23*51ffecc1SBen Gras.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24*51ffecc1SBen Gras.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25*51ffecc1SBen Gras.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26*51ffecc1SBen Gras.\" POSSIBILITY OF SUCH DAMAGE. 27*51ffecc1SBen Gras.\" 28*51ffecc1SBen Gras.Dd July 20, 2009 29*51ffecc1SBen Gras.Dt CURSES_COLOR 3 30*51ffecc1SBen Gras.Os 31*51ffecc1SBen Gras.Sh NAME 32*51ffecc1SBen Gras.Nm curses_color , 33*51ffecc1SBen Gras.Nm has_colors , 34*51ffecc1SBen Gras.Nm can_change_color , 35*51ffecc1SBen Gras.Nm start_color , 36*51ffecc1SBen Gras.Nm init_pair , 37*51ffecc1SBen Gras.Nm pair_content , 38*51ffecc1SBen Gras.Nm COLOR_PAIR , 39*51ffecc1SBen Gras.Nm PAIR_NUMBER , 40*51ffecc1SBen Gras.Nm init_color , 41*51ffecc1SBen Gras.Nm color_content , 42*51ffecc1SBen Gras.Nm no_color_attributes 43*51ffecc1SBen Gras.Nd curses color manipulation routines 44*51ffecc1SBen Gras.Sh LIBRARY 45*51ffecc1SBen Gras.Lb libcurses 46*51ffecc1SBen Gras.Sh SYNOPSIS 47*51ffecc1SBen Gras.In curses.h 48*51ffecc1SBen Gras.Ft bool 49*51ffecc1SBen Gras.Fn has_colors void 50*51ffecc1SBen Gras.Ft bool 51*51ffecc1SBen Gras.Fn can_change_color void 52*51ffecc1SBen Gras.Ft int 53*51ffecc1SBen Gras.Fn start_color void 54*51ffecc1SBen Gras.Ft int 55*51ffecc1SBen Gras.Fn init_pair "short pair" "short fore" "short back" 56*51ffecc1SBen Gras.Ft int 57*51ffecc1SBen Gras.Fn pair_content "short pair" "short *fore" "short *back" 58*51ffecc1SBen Gras.Ft int 59*51ffecc1SBen Gras.Fn COLOR_PAIR "int n" 60*51ffecc1SBen Gras.Ft int 61*51ffecc1SBen Gras.Fn PAIR_NUMBER "int val" 62*51ffecc1SBen Gras.Ft int 63*51ffecc1SBen Gras.Fn init_color "short color" "short red" "short green" "short blue" 64*51ffecc1SBen Gras.Ft int 65*51ffecc1SBen Gras.Fn color_content "short color" "short *red" "short *green" "short *blue" 66*51ffecc1SBen Gras.Ft attr_t 67*51ffecc1SBen Gras.Fn no_color_attributes void 68*51ffecc1SBen Gras.Pp 69*51ffecc1SBen Gras.Va extern int COLOR_PAIRS ; 70*51ffecc1SBen Gras.Pp 71*51ffecc1SBen Gras.Va extern int COLORS ; 72*51ffecc1SBen Gras.Sh DESCRIPTION 73*51ffecc1SBen GrasThese functions manipulate color on terminals that support color attributes. 74*51ffecc1SBen Gras.Pp 75*51ffecc1SBen GrasThe function 76*51ffecc1SBen Gras.Fn has_colors 77*51ffecc1SBen Grasindicates whether a terminal is capable of displaying color attributes. 78*51ffecc1SBen GrasIt returns 79*51ffecc1SBen Gras.Dv TRUE 80*51ffecc1SBen Grasif the terminal is capable of displaying color attributes and 81*51ffecc1SBen Gras.Dv FALSE 82*51ffecc1SBen Grasotherwise. 83*51ffecc1SBen Gras.Pp 84*51ffecc1SBen GrasThe function 85*51ffecc1SBen Gras.Fn can_change_color 86*51ffecc1SBen Grasindicates whether a terminal is capable of redefining colors. 87*51ffecc1SBen GrasIt returns 88*51ffecc1SBen Gras.Dv TRUE 89*51ffecc1SBen Grasif colors can be redefined and 90*51ffecc1SBen Gras.Dv FALSE 91*51ffecc1SBen Grasif they can not. 92*51ffecc1SBen Gras.Pp 93*51ffecc1SBen GrasThe function 94*51ffecc1SBen Gras.Fn start_color 95*51ffecc1SBen Grasinitializes the curses color support on a terminal. 96*51ffecc1SBen GrasIt must be called before any color manipulation functions are called on that 97*51ffecc1SBen Grasterminal. 98*51ffecc1SBen GrasThe function initializes the eight basic colors (black, red, green, yellow, 99*51ffecc1SBen Grasblue, magenta, cyan and white) that are specified using the color macros 100*51ffecc1SBen Gras(such as 101*51ffecc1SBen Gras.Dv COLOR_BLACK ) 102*51ffecc1SBen Grasdefined in 103*51ffecc1SBen Gras.Em \*[Lt]curses.h\*[Gt] . 104*51ffecc1SBen Gras.Fn start_color 105*51ffecc1SBen Grasalso initializes the global external variables 106*51ffecc1SBen Gras.Va COLORS 107*51ffecc1SBen Grasand 108*51ffecc1SBen Gras.Va COLOR_PAIRS . 109*51ffecc1SBen Gras.Va COLORS 110*51ffecc1SBen Grasdefines the number of colors that the terminal supports and 111*51ffecc1SBen Gras.Va COLOR_PAIRS 112*51ffecc1SBen Grasdefines the number of color-pairs that the terminal supports. 113*51ffecc1SBen GrasThese color-pairs are initialized to white foreground on black background. 114*51ffecc1SBen Gras.Fn start_color 115*51ffecc1SBen Grassets the colors on the terminal to the curses defaults of white 116*51ffecc1SBen Grasforeground on black background unless the functions 117*51ffecc1SBen Gras.Fn assume_default_colors 118*51ffecc1SBen Grasor 119*51ffecc1SBen Gras.Fn use_default_colors 120*51ffecc1SBen Grashave been called previously. 121*51ffecc1SBen Gras.Pp 122*51ffecc1SBen GrasThe function 123*51ffecc1SBen Gras.Fn init_pair pair fore back 124*51ffecc1SBen Grassets foreground color 125*51ffecc1SBen Gras.Fa fore 126*51ffecc1SBen Grasand background color 127*51ffecc1SBen Gras.Fa back 128*51ffecc1SBen Grasfor color-pair number 129*51ffecc1SBen Gras.Fa pair . 130*51ffecc1SBen GrasThe valid range for the color-pair 131*51ffecc1SBen Gras.Fa pair 132*51ffecc1SBen Grasis from 1 to 133*51ffecc1SBen Gras.Va COLOR_PAIRS 134*51ffecc1SBen Gras\&- 1 135*51ffecc1SBen Grasand the valid range for the colors is any number less than 136*51ffecc1SBen Gras.Va COLORS . 137*51ffecc1SBen GrasSpecifying a negative number will set that color to the default foreground 138*51ffecc1SBen Grasor background color. 139*51ffecc1SBen GrasThe 8 initial colors are defined as: 140*51ffecc1SBen Gras.Bl -tag -width "COLOR_MAGENTA" -compact -offset indent 141*51ffecc1SBen Gras.It COLOR_BLACK 142*51ffecc1SBen Gras.It COLOR_RED 143*51ffecc1SBen Gras.It COLOR_GREEN 144*51ffecc1SBen Gras.It COLOR_YELLOW 145*51ffecc1SBen Gras.It COLOR_BLUE 146*51ffecc1SBen Gras.It COLOR_MAGENTA 147*51ffecc1SBen Gras.It COLOR_CYAN 148*51ffecc1SBen Gras.It COLOR_WHITE 149*51ffecc1SBen Gras.El 150*51ffecc1SBen GrasColor-pair 0 is used as the default color pair, so changing this will 151*51ffecc1SBen Grashave no effect. 152*51ffecc1SBen GrasUse the function 153*51ffecc1SBen Gras.Fn assume_default_colors 154*51ffecc1SBen Grasto change the default colors. 155*51ffecc1SBen Gras.Pp 156*51ffecc1SBen GrasThe function 157*51ffecc1SBen Gras.Fn pair_content pair *fore *back 158*51ffecc1SBen Grasstores the foreground and background color numbers of color-pair 159*51ffecc1SBen Gras.Fa pair 160*51ffecc1SBen Grasin the variables 161*51ffecc1SBen Gras.Fa fore 162*51ffecc1SBen Grasand 163*51ffecc1SBen Gras.Fa back , 164*51ffecc1SBen Grasrespectively. 165*51ffecc1SBen Gras.Pp 166*51ffecc1SBen GrasThe macro 167*51ffecc1SBen Gras.Fn COLOR_PAIR n 168*51ffecc1SBen Grasgives the attribute value of color-pair number 169*51ffecc1SBen Gras.Fa n . 170*51ffecc1SBen GrasThis is the value that is used to set the attribute of a character to this 171*51ffecc1SBen Grascolor-pair. 172*51ffecc1SBen GrasFor example, 173*51ffecc1SBen Gras.Dl attrset(COLOR_PAIR(2)) 174*51ffecc1SBen Graswill display characters using color-pair 2. 175*51ffecc1SBen Gras.Pp 176*51ffecc1SBen GrasThe macro 177*51ffecc1SBen Gras.Fn PAIR_NUMBER val 178*51ffecc1SBen Grasgives the color-pair number associated with the attribute value 179*51ffecc1SBen Gras.Fa val . 180*51ffecc1SBen Gras.Pp 181*51ffecc1SBen GrasThe function 182*51ffecc1SBen Gras.Fn init_color color red green blue 183*51ffecc1SBen Grassets the red, green and blue intensity components of color 184*51ffecc1SBen Gras.Fa color 185*51ffecc1SBen Grasto the values 186*51ffecc1SBen Gras.Fa red , 187*51ffecc1SBen Gras.Fa green 188*51ffecc1SBen Grasand 189*51ffecc1SBen Gras.Fa blue , 190*51ffecc1SBen Grasrespectively. 191*51ffecc1SBen GrasThe minimum intensity value is 0 and the maximum intensity value is 1000. 192*51ffecc1SBen Gras.Pp 193*51ffecc1SBen GrasThe function 194*51ffecc1SBen Gras.Fn color_content color *red *green *blue 195*51ffecc1SBen Grasstores the red, green and blue intensity components of color 196*51ffecc1SBen Gras.Fa color 197*51ffecc1SBen Grasin the variables 198*51ffecc1SBen Gras.Fa red , 199*51ffecc1SBen Gras.Fa green , 200*51ffecc1SBen Grasand 201*51ffecc1SBen Gras.Fa blue , 202*51ffecc1SBen Grasrespectively. 203*51ffecc1SBen Gras.Pp 204*51ffecc1SBen GrasThe function 205*51ffecc1SBen Gras.Fn no_color_attributes 206*51ffecc1SBen Grasreturns those attributes that a terminal is unable to combine with color. 207*51ffecc1SBen Gras.Sh RETURN VALUES 208*51ffecc1SBen GrasThe functions 209*51ffecc1SBen Gras.Fn start_color , 210*51ffecc1SBen Gras.Fn init_pair , 211*51ffecc1SBen Gras.Fn pair_content , 212*51ffecc1SBen Gras.Fn init_color 213*51ffecc1SBen Grasand 214*51ffecc1SBen Gras.Fn color_content 215*51ffecc1SBen Grasreturn OK on success and ERR on failure. 216*51ffecc1SBen Gras.Sh SEE ALSO 217*51ffecc1SBen Gras.Xr curses_attributes 3 , 218*51ffecc1SBen Gras.Xr curses_background 3 , 219*51ffecc1SBen Gras.Xr curses_default_colors 3 220*51ffecc1SBen Gras.Sh STANDARDS 221*51ffecc1SBen GrasThe 222*51ffecc1SBen Gras.Nx 223*51ffecc1SBen GrasCurses library complies with the X/Open Curses specification, part of the 224*51ffecc1SBen GrasSingle Unix Specification. 225*51ffecc1SBen Gras.Pp 226*51ffecc1SBen GrasThe function 227*51ffecc1SBen Gras.Fn no_color_attributes 228*51ffecc1SBen Grasand the use of negative color numbers 229*51ffecc1SBen Grasare extensions to the X/Open Curses specification. 230*51ffecc1SBen Gras.Sh HISTORY 231*51ffecc1SBen GrasThese functions first appeared in 232*51ffecc1SBen Gras.Nx 1.5 . 233