/****************************************************************************
- * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_color.c,v 1.101 2011/05/28 21:57:59 tom Exp $")
+MODULE_ID("$Id: lib_color.c,v 1.106 2012/12/15 19:14:34 tom Exp $")
#ifdef USE_TERM_DRIVER
#define CanChange InfoOf(SP_PARM).canchange
default_bg(NCURSES_SP_ARG),
NCURSES_SP_NAME(_nc_outch));
}
+#if !NCURSES_EXT_COLORS
+ /*
+ * Without ext-colors, we cannot represent more than 256 color pairs.
+ */
+ if (maxpairs > 256)
+ maxpairs = 256;
+#endif
if (maxpairs > 0 && maxcolors > 0) {
SP_PARM->_pair_limit = maxpairs;
/* This function was originally written by Daniel Weaver <danw@znyx.com> */
static void
-rgb2hls(short r, short g, short b, short *h, short *l, short *s)
+rgb2hls(int r, int g, int b, short *h, short *l, short *s)
/* convert RGB to HLS system */
{
- short min, max, t;
+ int min, max, t;
if ((min = g < r ? g : r) > b)
min = b;
else
t = (short) (360 + ((r - g) * 60) / (max - min));
- *h = t % 360;
+ *h = (short) (t % 360);
}
/*
if (!ValidPair(pair)) {
result = ERR;
} else {
- NCURSES_COLOR_T fg = FORE_OF(SP_PARM->_color_pairs[pair]);
- NCURSES_COLOR_T bg = BACK_OF(SP_PARM->_color_pairs[pair]);
+ NCURSES_COLOR_T fg = (NCURSES_COLOR_T) FORE_OF(SP_PARM->_color_pairs[pair]);
+ NCURSES_COLOR_T bg = (NCURSES_COLOR_T) BACK_OF(SP_PARM->_color_pairs[pair]);
#if NCURSES_EXT_FUNCS
if (fg == COLOR_DEFAULT)
NCURSES_EXPORT(void)
NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_DCLx
- short old_pair,
- short pair,
- bool reverse,
+ int old_pair,
+ int pair,
+ int reverse,
NCURSES_SP_OUTC outc)
{
#ifdef USE_TERM_DRIVER
1, outc);
return;
} else if (SP_PARM != 0) {
- pair_content((short) pair, &fg, &bg);
+ if (pair_content((short) pair, &fg, &bg) == ERR)
+ return;
}
}
if (old_pair >= 0
&& SP_PARM != 0
- && pair_content(old_pair, &old_fg, &old_bg) != ERR) {
+ && pair_content((short) old_pair, &old_fg, &old_bg) != ERR) {
if ((isDefaultColor(fg) && !isDefaultColor(old_fg))
|| (isDefaultColor(bg) && !isDefaultColor(old_bg))) {
#if NCURSES_EXT_FUNCS
#if NCURSES_SP_FUNCS
NCURSES_EXPORT(void)
-_nc_do_color(short old_pair, short pair, bool reverse, NCURSES_OUTC outc)
+_nc_do_color(int old_pair, int pair, int reverse, NCURSES_OUTC outc)
{
SetSafeOutcWrapper(outc);
NCURSES_SP_NAME(_nc_do_color) (CURRENT_SCREEN,