4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
40 #pragma ident "%Z%%M% %I% %E% SMI"
44 #include <sys/types.h>
45 #include "curses_inc.h"
48 init_pair(short pair
, short f
, short b
)
50 _Color_pair
*ptp
; /* pairs table pointer */
52 /* check the validity of arguments */
54 if (pair
< 1 || pair
>= COLOR_PAIRS
||
55 f
< 0 || b
< 0 || f
>= COLORS
|| b
>= COLORS
)
58 ptp
= cur_term
->_pairs_tbl
+ pair
;
60 /* update the pairs table (if no changes just return) */
62 if (ptp
->foreground
== f
&& ptp
->background
== b
)
68 /* if we are on terminal that cannot define color pairs (Tek) */
69 /* and "pair" was previously defined, go through the curscr */
70 /* and erase information from the color field at all positions */
71 /* that use that color pair (this way when refresh will be */
72 /* called next time, it will be forced to change the color at */
75 if (!initialize_pair
) {
78 short lin
= curscr
->_maxy
;
79 chtype
**y
= curscr
->_y
;
83 chtype new_pair
= COLOR_PAIR(pair
);
85 /* must use lin=curscr->_maxy rather then LINES, because */
86 /* LINES could have been decremented by ripoffline() */
88 for (i
= 0; i
< lin
; i
++) {
90 for (j
= 0; j
< COLS
; j
++) {
91 if ((y
[i
][j
] & A_COLOR
) == new_pair
) {
96 (void) wtouchln(_virtscr
,
101 curscr
->_attrs
&= ~A_COLOR
;
113 /* on terminals that can initialize color pairs (HP) */
114 /* send an escape to initialize the new pair */
117 _init_HP_pair(pair
, f
, b
);
119 /* if that pair has not been previously initialized, it could not */
120 /* have been used on the screen, so we don't have to do refresh */
123 (void) wrefresh(_virtscr
);
133 _init_HP_pair(short pair
, short f
, short b
)
135 _Color
*ctp
= cur_term
->_color_tbl
; /* color table pointer */
138 (void) tputs(tparm_p7(initialize_pair
, (long) pair
,
139 (long) ctp
[f
].r
, (long) ctp
[f
].g
, (long) ctp
[f
].b
,
140 (long) ctp
[b
].r
, (long) ctp
[b
].g
, (long) ctp
[b
].b
),