2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License, Version 1.0 only
2N/A * (the "License"). You may not use this file except in compliance
2N/A * with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A/* Copyright (c) 1988 AT&T */
2N/A/* All Rights Reserved */
2N/A
2N/A/*
2N/A * University Copyright- Copyright (c) 1982, 1986, 1988
2N/A * The Regents of the University of California
2N/A * All Rights Reserved
2N/A *
2N/A * University Acknowledgment- Portions of this document are derived from
2N/A * software developed by the University of California, Berkeley, and its
2N/A * contributors.
2N/A */
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A/*LINTLIBRARY*/
2N/A
2N/A#include <sys/types.h>
2N/A#include "curses_inc.h"
2N/A
2N/Aint
2N/Ainit_pair(short pair, short f, short b)
2N/A{
2N/A _Color_pair *ptp; /* pairs table pointer */
2N/A
2N/A /* check the validity of arguments */
2N/A
2N/A if (pair < 1 || pair >= COLOR_PAIRS ||
2N/A f < 0 || b < 0 || f >= COLORS || b >= COLORS)
2N/A return (ERR);
2N/A
2N/A ptp = cur_term->_pairs_tbl + pair;
2N/A
2N/A /* update the pairs table (if no changes just return) */
2N/A
2N/A if (ptp->foreground == f && ptp->background == b)
2N/A return (OK);
2N/A
2N/A ptp->foreground = f;
2N/A ptp->background = b;
2N/A
2N/A /* if we are on terminal that cannot define color pairs (Tek) */
2N/A /* and "pair" was previously defined, go through the curscr */
2N/A /* and erase information from the color field at all positions */
2N/A /* that use that color pair (this way when refresh will be */
2N/A /* called next time, it will be forced to change the color at */
2N/A /* these positions */
2N/A
2N/A if (!initialize_pair) {
2N/A if (ptp->init) {
2N/A short i, j;
2N/A short lin = curscr->_maxy;
2N/A chtype **y = curscr->_y;
2N/A bool change;
2N/A short top = -1;
2N/A short bottom = -1;
2N/A chtype new_pair = COLOR_PAIR(pair);
2N/A
2N/A /* must use lin=curscr->_maxy rather then LINES, because */
2N/A /* LINES could have been decremented by ripoffline() */
2N/A
2N/A for (i = 0; i < lin; i++) {
2N/A change = FALSE;
2N/A for (j = 0; j < COLS; j++) {
2N/A if ((y[i][j] & A_COLOR) == new_pair) {
2N/A y[i][j] &= ~A_COLOR;
2N/A change = TRUE;
2N/A }
2N/A if (change) {
2N/A (void) wtouchln(_virtscr,
2N/A i, 1, -1);
2N/A if (top == -1)
2N/A top = i;
2N/A bottom = i;
2N/A curscr->_attrs &= ~A_COLOR;
2N/A }
2N/A }
2N/A if (top != -1) {
2N/A _VIRTTOP = top;
2N/A _VIRTBOT = bottom;
2N/A }
2N/A }
2N/A
2N/A }
2N/A }
2N/A
2N/A /* on terminals that can initialize color pairs (HP) */
2N/A /* send an escape to initialize the new pair */
2N/A
2N/A else
2N/A _init_HP_pair(pair, f, b);
2N/A
2N/A /* if that pair has not been previously initialized, it could not */
2N/A /* have been used on the screen, so we don't have to do refresh */
2N/A
2N/A if (ptp->init)
2N/A (void) wrefresh(_virtscr);
2N/A else
2N/A ptp->init = TRUE;
2N/A
2N/A return (OK);
2N/A}
2N/A
2N/A
2N/A
2N/Avoid
2N/A_init_HP_pair(short pair, short f, short b)
2N/A{
2N/A _Color *ctp = cur_term->_color_tbl; /* color table pointer */
2N/A
2N/A if (initialize_pair)
2N/A (void) tputs(tparm_p7(initialize_pair, (long) pair,
2N/A (long) ctp[f].r, (long) ctp[f].g, (long) ctp[f].b,
2N/A (long) ctp[b].r, (long) ctp[b].g, (long) ctp[b].b),
2N/A 1, _outch);
2N/A}