


curs_color(3X)                                     curs_color(3X)


NNAAMMEE
       ccuurrss__ccoolloorr:     ssttaarrtt__ccoolloorr,     iinniitt__ppaaiirr,    iinniitt__ccoolloorr,
       hhaass__ccoolloorrss, ccaann__cchhaannggee__ccoolloorr, ccoolloorr__ccoonntteenntt,  ppaaiirr__ccoonntteenntt
       - ccuurrsseess color manipulation routines

SSYYNNOOPPSSIISS
       ## iinncclluuddee <<ccuurrsseess..hh>>
       iinntt ssttaarrtt__ccoolloorr((vvooiidd));;
       iinntt iinniitt__ppaaiirr((sshhoorrtt ppaaiirr,, sshhoorrtt ff,, sshhoorrtt bb));;
       iinntt iinniitt__ccoolloorr((sshhoorrtt ccoolloorr,, sshhoorrtt rr,, sshhoorrtt gg,, sshhoorrtt bb));;
       bbooooll hhaass__ccoolloorrss((vvooiidd));;
       bbooooll ccaann__cchhaannggee__ccoolloorr((vvooiidd));;
       iinntt  ccoolloorr__ccoonntteenntt((sshhoorrtt  ccoolloorr,, sshhoorrtt **rr,, sshhoorrtt **gg,, sshhoorrtt
       **bb));;
       iinntt ppaaiirr__ccoonntteenntt((sshhoorrtt ppaaiirr,, sshhoorrtt **ff,, sshhoorrtt **bb));;

DDEESSCCRRIIPPTTIIOONN
   OOvveerrvviieeww
       ccuurrsseess support color attributes  on  terminals  with  that
       capability.   To  use  these  routines ssttaarrtt__ccoolloorr must be
       called, usually right after iinniittssccrr.   Colors  are  always
       used  in pairs (referred to as color-pairs).  A color-pair
       consists of a foreground  color  (for  characters)  and  a
       background color (for the blank field on which the charac-
       ters are displayed).  A programmer  initializes  a  color-
       pair  with  the routine iinniitt__ppaaiirr.  After it has been ini-
       tialized, CCOOLLOORR__PPAAIIRR(_n), a macro  defined  in  <<ccuurrsseess..hh>>,
       can be used as a new video attribute.

       If  a  terminal  is capable of redefining colors, the pro-
       grammer can use the routine iinniitt__ccoolloorr to change the defi-
       nition   of   a   color.    The  routines  hhaass__ccoolloorrss  and
       ccaann__cchhaannggee__ccoolloorr  return  TTRRUUEE  or  FFAALLSSEE,  depending   on
       whether  the  terminal  has color capabilities and whether
       the  programmer  can  change  the  colors.   The   routine
       ccoolloorr__ccoonntteenntt  allows  a programmer to extract the amounts
       of red, green,  and  blue  components  in  an  initialized
       color.   The  routine  ppaaiirr__ccoonntteenntt allows a programmer to
       find out how a given color-pair is currently defined.

   RRoouuttiinnee DDeessccrriippttiioonnss
       The ssttaarrtt__ccoolloorr routine requires no arguments.  It must be
       called  if  the programmer wants to use colors, and before
       any other color manipulation routine  is  called.   It  is
       good  practice  to  call this routine right after iinniittssccrr.
       ssttaarrtt__ccoolloorr initializes eight basic  colors  (black,  red,
       green,  yellow,  blue,  magenta, cyan, and white), and two
       global variables,  CCOOLLOORRSS  and  CCOOLLOORR__PPAAIIRRSS  (respectively
       defining  the maximum number of colors and color-pairs the
       terminal can support).  It also restores the colors on the
       terminal to the values they had when the terminal was just
       turned on.

       The iinniitt__ppaaiirr routine changes the definition of  a  color-



                                                                1





curs_color(3X)                                     curs_color(3X)


       pair.   It takes three arguments: the number of the color-
       pair to be changed, the foreground color number,  and  the
       background  color number.  The value of the first argument
       must be between 11 and CCOOLLOORR__PPAAIIRRSS--11.   The  value  of  the
       second  and  third  arguments must be between 0 and CCOOLLOORRSS
       (the 0 color pair is wired to white on black and cannot be
       changed).   If  the color-pair was previously initialized,
       the screen is refreshed and all occurrences of that color-
       pair is changed to the new definition.

       The  iinniitt__ccoolloorr routine changes the definition of a color.
       It takes four arguments: the number of  the  color  to  be
       changed  followed  by three RGB values (for the amounts of
       red, green, and blue components).  The value of the  first
       argument  must  be between 00 and CCOOLLOORRSS.  (See the section
       CCoolloorrss for the default color index.)   Each  of  the  last
       three  arguments must be a value between 0 and 1000.  When
       iinniitt__ccoolloorr is used, all occurrences of that color  on  the
       screen immediately change to the new definition.

       The  hhaass__ccoolloorrss routine requires no arguments.  It returns
       TTRRUUEE if the terminal can manipulate colors; otherwise,  it
       returns FFAALLSSEE.  This routine facilitates writing terminal-
       independent programs.  For example, a programmer  can  use
       it  to  decide  whether  to  use color or some other video
       attribute.

       The ccaann__cchhaannggee__ccoolloorr routine requires  no  arguments.   It
       returns  TTRRUUEE  if  the  terminal  supports  colors and can
       change their definitions; other, it returns  FFAALLSSEE.   This
       routine facilitates writing terminal-independent programs.

       The ccoolloorr__ccoonntteenntt routine gives programmers a way to  find
       the intensity of the red, green, and blue (RGB) components
       in a color.  It requires four arguments: the color number,
       and  three addresses of sshhoorrtts for storing the information
       about the amounts of red, green, and  blue  components  in
       the  given color.  The value of the first argument must be
       between 0 and CCOOLLOORRSS.  The values that are stored  at  the
       addresses  pointed  to  by  the  last  three arguments are
       between 0 (no component) and 1000 (maximum amount of  com-
       ponent).

       The  ppaaiirr__ccoonntteenntt  routine  allows programmers to find out
       what colors a given color-pair consists of.   It  requires
       three  arguments: the color-pair number, and two addresses
       of sshhoorrtts for storing the foreground  and  the  background
       color  numbers.   The  value of the first argument must be
       between 1 and CCOOLLOORR__PPAAIIRRSS--11.  The values that  are  stored
       at  the addresses pointed to by the second and third argu-
       ments are between 0 and CCOOLLOORRSS.

   CCoolloorrss
       In <<ccuurrsseess..hh>> the following macros are defined.  These are



                                                                2





curs_color(3X)                                     curs_color(3X)


       the  default colors.  ccuurrsseess also assumes that CCOOLLOORR__BBLLAACCKK
       is the default background color for all terminals.

             CCOOLLOORR__BBLLAACCKK
             CCOOLLOORR__RREEDD
             CCOOLLOORR__GGRREEEENN
             CCOOLLOORR__YYEELLLLOOWW
             CCOOLLOORR__BBLLUUEE
             CCOOLLOORR__MMAAGGEENNTTAA
             CCOOLLOORR__CCYYAANN
             CCOOLLOORR__WWHHIITTEE

RREETTUURRNN VVAALLUUEE
       The routines ccaann__cchhaannggee__ccoolloorr(())  and  hhaass__ccoolloorrss(())  return
       TTRRUUEE or FFAALLSSEE.

       All other routines return the integer EERRRR upon failure and
       an OOKK (SVr4 specifies only "an integer  value  other  than
       EERRRR") upon successful completion.

NNOOTTEESS
       Several  caveats  apply  on 386 and 486 machines with VGA-
       compatible graphics:

       COLOR_YELLOW  is  actually  brown.   To  get  yellow,  use
       COLOR_YELLOW combined with the AA__BBOOLLDD attribute.

       The  A_BLINK  attribute  should  in theory cause the back-
       ground to go bright.  This often fails to work,  and  even
       some cards for which it mostly works (such as the Paradise
       and compatibles) do the wrong thing when you try to set  a
       bright  "yellow"  background  (you  get  a blinking yellow
       foreground instead).

       Color RGB values are not settable.

PPOORRTTAABBIILLIITTYY
       This implementation satisfies XSI Curses's  minumum  maxi-
       mums for CCOOLLOORRSS and CCOOLLOORR__PPAAIIRRSS.

SSEEEE AALLSSOO
       ccuurrsseess(3X), ccuurrss__iinniittssccrr(3X), ccuurrss__aattttrr(3X)















                                                                3


