1 /* $OpenBSD: lib_slkcolor.c,v 1.5 2023/10/17 09:52:09 nicm Exp $ */
2
3 /****************************************************************************
4 * Copyright 2018,2020 Thomas E. Dickey *
5 * Copyright 1998-2014,2017 Free Software Foundation, Inc. *
6 * *
7 * Permission is hereby granted, free of charge, to any person obtaining a *
8 * copy of this software and associated documentation files (the *
9 * "Software"), to deal in the Software without restriction, including *
10 * without limitation the rights to use, copy, modify, merge, publish, *
11 * distribute, distribute with modifications, sublicense, and/or sell *
12 * copies of the Software, and to permit persons to whom the Software is *
13 * furnished to do so, subject to the following conditions: *
14 * *
15 * The above copyright notice and this permission notice shall be included *
16 * in all copies or substantial portions of the Software. *
17 * *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
21 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
24 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
25 * *
26 * Except as contained in this notice, the name(s) of the above copyright *
27 * holders shall not be used in advertising or otherwise to promote the *
28 * sale, use or other dealings in this Software without prior written *
29 * authorization. *
30 ****************************************************************************/
31
32 /****************************************************************************
33 * Author: Juergen Pfeifer, 1998,2009 *
34 * and: Thomas E. Dickey 2005-on *
35 ****************************************************************************/
36
37 /*
38 * lib_slkcolor.c
39 * Soft key routines.
40 * Set the label's color
41 */
42 #include <curses.priv.h>
43
44 MODULE_ID("$Id: lib_slkcolor.c,v 1.5 2023/10/17 09:52:09 nicm Exp $")
45
46 static int
_nc_slk_color(SCREEN * sp,int pair_arg)47 _nc_slk_color(SCREEN *sp, int pair_arg)
48 {
49 int code = ERR;
50
51 T((T_CALLED("slk_color(%p,%d)"), (void *) sp, pair_arg));
52
53 if (sp != 0
54 && sp->_slk != 0
55 && pair_arg >= 0
56 && pair_arg < sp->_pair_limit) {
57 TR(TRACE_ATTRS, ("... current is %s", _tracech_t(CHREF(sp->_slk->attr))));
58 SetPair(sp->_slk->attr, pair_arg);
59 TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(sp->_slk->attr))));
60 code = OK;
61 }
62 returnCode(code);
63 }
64
65 NCURSES_EXPORT(int)
NCURSES_SP_NAME(slk_color)66 NCURSES_SP_NAME(slk_color) (NCURSES_SP_DCLx NCURSES_PAIRS_T pair_arg)
67 {
68 return _nc_slk_color(SP_PARM, pair_arg);
69 }
70
71 #if NCURSES_SP_FUNCS
72 NCURSES_EXPORT(int)
slk_color(NCURSES_PAIRS_T pair_arg)73 slk_color(NCURSES_PAIRS_T pair_arg)
74 {
75 return NCURSES_SP_NAME(slk_color) (CURRENT_SCREEN, pair_arg);
76 }
77 #endif
78
79 #if NCURSES_EXT_COLORS
80 NCURSES_EXPORT(int)
NCURSES_SP_NAME(extended_slk_color)81 NCURSES_SP_NAME(extended_slk_color) (NCURSES_SP_DCLx int pair_arg)
82 {
83 return _nc_slk_color(SP_PARM, pair_arg);
84 }
85
86 #if NCURSES_SP_FUNCS
87 NCURSES_EXPORT(int)
extended_slk_color(int pair_arg)88 extended_slk_color(int pair_arg)
89 {
90 return NCURSES_SP_NAME(extended_slk_color) (CURRENT_SCREEN, pair_arg);
91 }
92 #endif
93 #endif
94