xref: /freebsd/contrib/ncurses/ncurses/base/lib_slkatron.c (revision 43c7dd6b597947c27cab4ebc5a67a8a3f5b7c58d)
10e3d5408SPeter Wemm /****************************************************************************
2*e1865124SBaptiste Daroussin  * Copyright 2020 Thomas E. Dickey                                          *
3*e1865124SBaptiste Daroussin  * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
40e3d5408SPeter Wemm  *                                                                          *
50e3d5408SPeter Wemm  * Permission is hereby granted, free of charge, to any person obtaining a  *
60e3d5408SPeter Wemm  * copy of this software and associated documentation files (the            *
70e3d5408SPeter Wemm  * "Software"), to deal in the Software without restriction, including      *
80e3d5408SPeter Wemm  * without limitation the rights to use, copy, modify, merge, publish,      *
90e3d5408SPeter Wemm  * distribute, distribute with modifications, sublicense, and/or sell       *
100e3d5408SPeter Wemm  * copies of the Software, and to permit persons to whom the Software is    *
110e3d5408SPeter Wemm  * furnished to do so, subject to the following conditions:                 *
120e3d5408SPeter Wemm  *                                                                          *
130e3d5408SPeter Wemm  * The above copyright notice and this permission notice shall be included  *
140e3d5408SPeter Wemm  * in all copies or substantial portions of the Software.                   *
150e3d5408SPeter Wemm  *                                                                          *
160e3d5408SPeter Wemm  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
170e3d5408SPeter Wemm  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
180e3d5408SPeter Wemm  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
190e3d5408SPeter Wemm  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
200e3d5408SPeter Wemm  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
210e3d5408SPeter Wemm  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
220e3d5408SPeter Wemm  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
230e3d5408SPeter Wemm  *                                                                          *
240e3d5408SPeter Wemm  * Except as contained in this notice, the name(s) of the above copyright   *
250e3d5408SPeter Wemm  * holders shall not be used in advertising or otherwise to promote the     *
260e3d5408SPeter Wemm  * sale, use or other dealings in this Software without prior written       *
270e3d5408SPeter Wemm  * authorization.                                                           *
280e3d5408SPeter Wemm  ****************************************************************************/
290e3d5408SPeter Wemm 
300e3d5408SPeter Wemm /****************************************************************************
314a1a9510SRong-En Fan  *  Author:  Juergen Pfeifer, 1997                                          *
324a1a9510SRong-En Fan  *     and:  Thomas E. Dickey 2005                                          *
330e3d5408SPeter Wemm  ****************************************************************************/
340e3d5408SPeter Wemm 
350e3d5408SPeter Wemm /*
360e3d5408SPeter Wemm  *	lib_slkatron.c
370e3d5408SPeter Wemm  *	Soft key routines.
380e3d5408SPeter Wemm  *      Switch on labels attributes
390e3d5408SPeter Wemm  */
400e3d5408SPeter Wemm #include <curses.priv.h>
410e3d5408SPeter Wemm 
42*e1865124SBaptiste Daroussin MODULE_ID("$Id: lib_slkatron.c,v 1.13 2020/02/02 23:34:34 tom Exp $")
430e3d5408SPeter Wemm 
NCURSES_EXPORT(int)447a69bbfbSPeter Wemm NCURSES_EXPORT(int)
4506bfebdeSXin LI NCURSES_SP_NAME(slk_attron) (NCURSES_SP_DCLx const chtype attr)
460e3d5408SPeter Wemm {
4706bfebdeSXin LI     T((T_CALLED("slk_attron(%p,%s)"), (void *) SP_PARM, _traceattr(attr)));
480e3d5408SPeter Wemm 
4906bfebdeSXin LI     if (SP_PARM != 0 && SP_PARM->_slk != 0) {
5006bfebdeSXin LI 	TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP_PARM->_slk->attr))));
5106bfebdeSXin LI 	AddAttr(SP_PARM->_slk->attr, attr);
524a1a9510SRong-En Fan 	if ((attr & A_COLOR) != 0) {
5306bfebdeSXin LI 	    SetPair(SP_PARM->_slk->attr, PairNumber(attr));
544a1a9510SRong-En Fan 	}
5506bfebdeSXin LI 	TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP_PARM->_slk->attr))));
560e3d5408SPeter Wemm 	returnCode(OK);
577a69bbfbSPeter Wemm     } else
580e3d5408SPeter Wemm 	returnCode(ERR);
590e3d5408SPeter Wemm }
6006bfebdeSXin LI 
6106bfebdeSXin LI #if NCURSES_SP_FUNCS
6206bfebdeSXin LI NCURSES_EXPORT(int)
slk_attron(const chtype attr)6306bfebdeSXin LI slk_attron(const chtype attr)
6406bfebdeSXin LI {
6506bfebdeSXin LI     return NCURSES_SP_NAME(slk_attron) (CURRENT_SCREEN, attr);
6606bfebdeSXin LI }
6706bfebdeSXin LI #endif
68