vcolor.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 1986 AT&T
* All Rights Reserved
*/
#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.9 */
#include <curses.h>
#include <term.h>
#include "wish.h"
#include "color_pair.h"
#include "moremacros.h"
#include "vtdefs.h"
#include "vt.h"
static int Numcolors = NUMDEFCOLORS;
int Pair_set[MAXCOLPAIRS];
/*
* Table of known colors
*/
struct ctab {
char *colorstr;
int id;
{ "black", COLOR_BLACK },
{ "blue", COLOR_BLUE },
{ "green", COLOR_GREEN },
{ "cyan", COLOR_CYAN },
{ "red", COLOR_RED },
{ "magenta", COLOR_MAGENTA },
{ "yellow", COLOR_YELLOW },
{ "white", COLOR_WHITE },
{ NULL, 0 }
};
/*
* SET_SCR_COLOR sets the screen background color and refreshes
* the screen
*/
int colpair;
int dorefresh;
{
/*
* Set color attributes for the banner, message and
* command lines
*/
}
if (dorefresh) {
refresh();
/*
* The following lines are necessary since curses
* has problems with reverse video screens (e.g., xterm
* by default comes up with a white background)
*/
if (orig_colors)
if (orig_pair)
}
}
/*
* SET_SLK_COLOR simply sets the slk color pair
*/
{
}
/*
* SETPAIR creates new color pair combinations
*/
{
if (foreground < 0 || background < 0)
else
}
/*
* SETCOLOR creates new color specifications or "tweeks" old ones.
* (returns 1 on success and 0 on failure)
*/
char *colorstr;
int r, g, b;
{
int cant_init;
if (!can_change_color())
return(-1);
cant_init = 0;
/*
* The color has been previously defined ...
* If you can't change the color specification then
* restore the old specification.
*/
cant_init++;
else
}
else
}
/*
* The color is NEW ...
*/
id = -1;
else
}
else
id = -1;
}
/*
* GETCOLOR_ID returns the color identifier of the passed color string
*/
char *colorstr;
{
int index;
if (index >= 0)
else
return(-1);
}
/*
* LOOKUP_COLOR returns the index of the passed color string from the
* color table (or "-1" if the color is not in the table).
*/
static int
char *colorstr;
{
register int i;
/* put it in the color table */
for (i = 0; i < Numcolors; i++) {
return(i);
}
return(-1);
}
/*
* ADD_COLOR adds a new color to the color table if the number of colors
* is less than COLORS (curses define for the number of colors the terminal
* can support) and less than MAXCOLORS (color table size)
*/
static int
char *colorstr;
{
return(Numcolors++);
}
else
return(-1);
}