1 #if !defined(lint) && !defined(DOS)
2 static char rcsid
[] = "$Id: color.c 761 2007-10-23 22:35:18Z hubert@u.washington.edu $";
6 * ========================================================================
7 * Copyright 2013-2021 Eduardo Chappa
8 * Copyright 2006 University of Washington
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * ========================================================================
21 * These routines themselves aren't necessarily OS-specific, they
22 * are all called from within pico, pine and webpine.
24 * They used to be in pico source (osdep/unix, mswin.c), but considering
25 * webpine uses color as well and it should *not* have to be linked
26 * against libpico and considering pico uses these routines but should
27 * not have to link against libpith (and in turn c-client) we put them
28 * in pith/osdep which should only have to link against system libraries
29 * and thus be include freely in all of pine, pico and webpine.
39 * new_color_pair - allocate a new color pair structure assigning
40 * given foreground and background color strings
43 new_color_pair(char *fg
, char *bg
)
47 if((ret
= (COLOR_PAIR
*) malloc(sizeof(*ret
))) != NULL
){
48 memset(ret
, 0, sizeof(*ret
));
50 strncpy(ret
->fg
, fg
, MAXCOLORLEN
);
51 ret
->fg
[MAXCOLORLEN
] = '\0';
55 strncpy(ret
->bg
, bg
, MAXCOLORLEN
);
56 ret
->bg
[MAXCOLORLEN
] = '\0';
65 * free_color_pair - release resources associated with given
66 * color pair structure
69 free_color_pair(COLOR_PAIR
**cp
)
79 * Just like pico_set_color except it doesn't set the color, it just
80 * returns the value. Assumes def of PSC_NONE, since otherwise we always
81 * succeed and don't need to call this.
84 pico_is_good_colorpair(COLOR_PAIR
*cp
)
86 return(cp
&& pico_is_good_color(cp
->fg
) && pico_is_good_color(cp
->bg
));
91 pico_set_colorp(COLOR_PAIR
*col
, int flags
)
93 return(pico_set_colors(col
? col
->fg
: NULL
, col
? col
->bg
: NULL
, flags
));