1*c7ef0cfcSnicm /* $OpenBSD: lib_slkatr_set.c,v 1.5 2023/10/17 09:52:09 nicm Exp $ */
292dd1ec0Smillert
392dd1ec0Smillert /****************************************************************************
4*c7ef0cfcSnicm * Copyright 2020 Thomas E. Dickey *
5*c7ef0cfcSnicm * Copyright 1998-2014,2017 Free Software Foundation, Inc. *
692dd1ec0Smillert * *
792dd1ec0Smillert * Permission is hereby granted, free of charge, to any person obtaining a *
892dd1ec0Smillert * copy of this software and associated documentation files (the *
992dd1ec0Smillert * "Software"), to deal in the Software without restriction, including *
1092dd1ec0Smillert * without limitation the rights to use, copy, modify, merge, publish, *
1192dd1ec0Smillert * distribute, distribute with modifications, sublicense, and/or sell *
1292dd1ec0Smillert * copies of the Software, and to permit persons to whom the Software is *
1392dd1ec0Smillert * furnished to do so, subject to the following conditions: *
1492dd1ec0Smillert * *
1592dd1ec0Smillert * The above copyright notice and this permission notice shall be included *
1692dd1ec0Smillert * in all copies or substantial portions of the Software. *
1792dd1ec0Smillert * *
1892dd1ec0Smillert * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
1992dd1ec0Smillert * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
2092dd1ec0Smillert * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
2192dd1ec0Smillert * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
2292dd1ec0Smillert * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
2392dd1ec0Smillert * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
2492dd1ec0Smillert * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
2592dd1ec0Smillert * *
2692dd1ec0Smillert * Except as contained in this notice, the name(s) of the above copyright *
2792dd1ec0Smillert * holders shall not be used in advertising or otherwise to promote the *
2892dd1ec0Smillert * sale, use or other dealings in this Software without prior written *
2992dd1ec0Smillert * authorization. *
3092dd1ec0Smillert ****************************************************************************/
3192dd1ec0Smillert
3292dd1ec0Smillert /****************************************************************************
3381d8c4e1Snicm * Author: Juergen Pfeifer, 1998 *
34*c7ef0cfcSnicm * and: Thomas E. Dickey 2005-on *
3592dd1ec0Smillert ****************************************************************************/
3692dd1ec0Smillert
3792dd1ec0Smillert /*
3892dd1ec0Smillert * lib_slkatr_set.c
3992dd1ec0Smillert * Soft key routines.
4081d8c4e1Snicm * Set the label's attributes
4192dd1ec0Smillert */
4292dd1ec0Smillert #include <curses.priv.h>
4392dd1ec0Smillert
44*c7ef0cfcSnicm MODULE_ID("$Id: lib_slkatr_set.c,v 1.5 2023/10/17 09:52:09 nicm Exp $")
4592dd1ec0Smillert
NCURSES_EXPORT(int)4684af20ceSmillert NCURSES_EXPORT(int)
47*c7ef0cfcSnicm NCURSES_SP_NAME(slk_attr_set) (NCURSES_SP_DCLx
48*c7ef0cfcSnicm const attr_t attr,
49*c7ef0cfcSnicm NCURSES_PAIRS_T pair_arg,
50*c7ef0cfcSnicm void *opts)
5192dd1ec0Smillert {
52*c7ef0cfcSnicm int code = ERR;
53*c7ef0cfcSnicm int color_pair = pair_arg;
5492dd1ec0Smillert
55*c7ef0cfcSnicm T((T_CALLED("slk_attr_set(%p,%s,%d)"),
56*c7ef0cfcSnicm (void *) SP_PARM,
57*c7ef0cfcSnicm _traceattr(attr),
58*c7ef0cfcSnicm color_pair));
59*c7ef0cfcSnicm
60*c7ef0cfcSnicm set_extended_pair(opts, color_pair);
61*c7ef0cfcSnicm if (SP_PARM != 0
62*c7ef0cfcSnicm && SP_PARM->_slk != 0
63*c7ef0cfcSnicm && color_pair >= 0
64*c7ef0cfcSnicm && color_pair < SP_PARM->_pair_limit) {
65*c7ef0cfcSnicm TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP_PARM->_slk->attr))));
66*c7ef0cfcSnicm SetAttr(SP_PARM->_slk->attr, attr);
67*c7ef0cfcSnicm if (color_pair > 0) {
68*c7ef0cfcSnicm SetPair(SP_PARM->_slk->attr, color_pair);
6981d8c4e1Snicm }
70*c7ef0cfcSnicm TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP_PARM->_slk->attr))));
71*c7ef0cfcSnicm code = OK;
7292dd1ec0Smillert }
73*c7ef0cfcSnicm returnCode(code);
74*c7ef0cfcSnicm }
75*c7ef0cfcSnicm
76*c7ef0cfcSnicm #if NCURSES_SP_FUNCS
77*c7ef0cfcSnicm NCURSES_EXPORT(int)
slk_attr_set(const attr_t attr,NCURSES_COLOR_T pair_arg,void * opts)78*c7ef0cfcSnicm slk_attr_set(const attr_t attr, NCURSES_COLOR_T pair_arg, void *opts)
79*c7ef0cfcSnicm {
80*c7ef0cfcSnicm return NCURSES_SP_NAME(slk_attr_set) (CURRENT_SCREEN, attr,
81*c7ef0cfcSnicm pair_arg, opts);
82*c7ef0cfcSnicm }
83*c7ef0cfcSnicm #endif
84