From 361618047bb97a030b8e29e153c496b1a1099ebf Mon Sep 17 00:00:00 2001 From: William McBrine Date: Mon, 12 Dec 2005 00:26:58 +0000 Subject: [PATCH] Added wcolor_set() and color_set(). --- curses.h | 4 +++- pdcurses/attr.c | 43 +++++++++++++++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/curses.h b/curses.h index 73b6aa43..21cb41bc 100644 --- a/curses.h +++ b/curses.h @@ -18,7 +18,7 @@ *************************************************************************** */ /* -$Id: curses.h,v 1.47 2005/12/11 23:03:04 wmcbrine Exp $ +$Id: curses.h,v 1.48 2005/12/12 00:26:57 wmcbrine Exp $ */ /* *---------------------------------------------------------------------- @@ -1787,6 +1787,7 @@ int PDC_CDECL wborder Args(( WINDOW*, chtype, chtype, chtype, chtype, chtype int PDC_CDECL wclear Args(( WINDOW* )); int PDC_CDECL wclrtobot Args(( WINDOW* )); int PDC_CDECL wclrtoeol Args(( WINDOW* )); +int PDC_CDECL wcolor_set Args(( WINDOW*, short, void* )); void PDC_CDECL wcursyncup Args((WINDOW*)); int PDC_CDECL wdelch Args(( WINDOW* )); int PDC_CDECL wdeleteln Args(( WINDOW* )); @@ -1911,6 +1912,7 @@ int PDC_CDECL PDC_set_line_color Args(( short )); #define clear() wclear( stdscr ) #define clrtobot() wclrtobot( stdscr ) #define clrtoeol() wclrtoeol( stdscr ) +#define color_set(a,b) wcolor_set( stdscr, a, b ) #define delch() wdelch( stdscr ) #define deleteln() wdeleteln( stdscr ) #define derwin(w,nl,nc,by,bx) subwin((w),(nl),(nc),(by+(w)->_begy),(bx+(w)->_begx)) diff --git a/pdcurses/attr.c b/pdcurses/attr.c index 8d248817..b5ed6911 100644 --- a/pdcurses/attr.c +++ b/pdcurses/attr.c @@ -35,13 +35,15 @@ #undef wstandend #undef wstandout #undef getattrs +#undef color_set +#undef wcolor_set /* undefine any macros for functions called by this module if in debug mode */ #ifdef PDCDEBUG #endif #ifdef PDCDEBUG -char *rcsid_attr = "$Id: attr.c,v 1.2 2004/08/07 07:18:46 rexx Exp $"; +char *rcsid_attr = "$Id: attr.c,v 1.3 2005/12/12 00:26:58 wmcbrine Exp $"; #endif /*man-start********************************************************************* @@ -59,11 +61,13 @@ char *rcsid_attr = "$Id: attr.c,v 1.2 2004/08/07 07:18:46 rexx Exp $"; int wstandend(WINDOW *win); int standout(void); int wstandout(WINDOW *win); + int color_set(short color_pair, void *opts); + int wcolor_set(WINDOW *win, short color_pair, void *opts); X/Open Description: - These functions manipulate the current attributes of the named - window. These attributes can be any combination of A_STANDOUT, - A_REVERSE, A_BOLD, A_DIM, A_BLINK, A_UNDERLINE. + These functions manipulate the current attributes and/or colors + of the named window. These attributes can be any combination + of A_STANDOUT, A_REVERSE, A_BOLD, A_DIM, A_BLINK, A_UNDERLINE. These constants are defined in and can be combined with the bitwise-OR operator (|). @@ -297,3 +301,34 @@ WINDOW *win; #endif return( wattrset( win, A_STANDOUT ) ); } +/***********************************************************************/ +#ifdef HAVE_PROTO +int PDC_CDECL color_set(short color_pair, void *opts) +#else +int PDC_CDECL color_set(color_pair, opts) +short color_pair; +void *opts; +#endif +/***********************************************************************/ +{ + return( wcolor_set( stdscr, color_pair, opts ) ); +} +/***********************************************************************/ +#ifdef HAVE_PROTO +int PDC_CDECL wcolor_set(WINDOW *win, short color_pair, void *opts) +#else +int PDC_CDECL wcolor_set(win, color_pair, opts) +WINDOW *win; +short color_pair; +void *opts; /* "opts" not used, but required by the standard */ +#endif +/***********************************************************************/ +{ +#ifdef PDCDEBUG + if (trace_on) PDC_debug("wcolor_set() - called\n"); +#endif + if (win == (WINDOW *)NULL) + return( ERR ); + win->_attrs = (win->_attrs & ~A_COLOR) | COLOR_PAIR(color_pair); + return( OK ); +}