116125Swpaul/**************************************************************************** 216125Swpaul * Copyright 2020 Thomas E. Dickey * 316125Swpaul * Copyright 1998-2014,2017 Free Software Foundation, Inc. * 416125Swpaul * * 516125Swpaul * Permission is hereby granted, free of charge, to any person obtaining a * 616125Swpaul * copy of this software and associated documentation files (the * 716125Swpaul * "Software"), to deal in the Software without restriction, including * 816125Swpaul * without limitation the rights to use, copy, modify, merge, publish, * 916125Swpaul * distribute, distribute with modifications, sublicense, and/or sell * 1016125Swpaul * copies of the Software, and to permit persons to whom the Software is * 1116125Swpaul * furnished to do so, subject to the following conditions: * 1216125Swpaul * * 1316125Swpaul * The above copyright notice and this permission notice shall be included * 1416125Swpaul * in all copies or substantial portions of the Software. * 1516125Swpaul * * 1616125Swpaul * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 1716125Swpaul * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 1816125Swpaul * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 1916125Swpaul * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 2016125Swpaul * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 2116125Swpaul * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 2216125Swpaul * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 2316125Swpaul * * 2416125Swpaul * Except as contained in this notice, the name(s) of the above copyright * 2516125Swpaul * holders shall not be used in advertising or otherwise to promote the * 2616125Swpaul * sale, use or other dealings in this Software without prior written * 2716125Swpaul * authorization. * 2816125Swpaul ****************************************************************************/ 2916125Swpaul 3016125Swpaul/**************************************************************************** 3116125Swpaul * Author: Thomas E. Dickey 1998-on * 3216125Swpaul * Juergen Pfeifer 2009 * 33114601Sobrien ****************************************************************************/ 34114601Sobrien 3516125Swpaul#include <curses.priv.h> 3630378Scharnier 3730378Scharnier#ifndef CUR 3816125Swpaul#define CUR SP_TERMTYPE 3916125Swpaul#endif 4016125Swpaul 4116125SwpaulMODULE_ID("$Id: lib_dft_fgbg.c,v 1.30 2020/02/02 23:34:34 tom Exp $") 4216125Swpaul 4316125Swpaul/* 4416125Swpaul * Modify the behavior of color-pair 0 so that the library doesn't assume that 4516125Swpaul * it is white on black. This is an extension to XSI curses. 4616125Swpaul */ 4716959SwpaulNCURSES_EXPORT(int) 4816125SwpaulNCURSES_SP_NAME(use_default_colors) (NCURSES_SP_DCL0) 4916125Swpaul{ 5016125Swpaul T((T_CALLED("use_default_colors(%p)"), (void *) SP_PARM)); 5116125Swpaul returnCode(NCURSES_SP_NAME(assume_default_colors) (NCURSES_SP_ARGx -1, -1)); 5216125Swpaul} 5316125Swpaul 5416125Swpaul#if NCURSES_SP_FUNCS 5516125SwpaulNCURSES_EXPORT(int) 5616125Swpauluse_default_colors(void) 5716125Swpaul{ 5816125Swpaul return NCURSES_SP_NAME(use_default_colors) (CURRENT_SCREEN); 5990297Sdes} 6016125Swpaul#endif 6116125Swpaul 6216125Swpaul/* 6316125Swpaul * Modify the behavior of color-pair 0 so that the library assumes that it 6416125Swpaul * is something specific, possibly not white on black. 6516125Swpaul */ 6616125SwpaulNCURSES_EXPORT(int) 6716125SwpaulNCURSES_SP_NAME(assume_default_colors) (NCURSES_SP_DCLx int fg, int bg) 6816125Swpaul{ 6916125Swpaul int code = ERR; 7016125Swpaul 7116125Swpaul T((T_CALLED("assume_default_colors(%p,%d,%d)"), (void *) SP_PARM, fg, bg)); 7216125Swpaul if (SP_PARM != 0) { 7316125Swpaul#ifdef USE_TERM_DRIVER 7416125Swpaul code = CallDriver_2(SP_PARM, td_defaultcolors, fg, bg); 7516125Swpaul#else 7616125Swpaul if ((orig_pair || orig_colors) && !initialize_pair) { 7716125Swpaul 7816125Swpaul SP_PARM->_default_color = isDefaultColor(fg) || isDefaultColor(bg); 7916125Swpaul SP_PARM->_has_sgr_39_49 = (tigetflag("AX") == TRUE); 8016125Swpaul SP_PARM->_default_fg = isDefaultColor(fg) ? COLOR_DEFAULT : fg; 8116125Swpaul SP_PARM->_default_bg = isDefaultColor(bg) ? COLOR_DEFAULT : bg; 8216125Swpaul if (SP_PARM->_color_pairs != 0) { 8316125Swpaul bool save = SP_PARM->_default_color; 8416125Swpaul SP_PARM->_assumed_color = TRUE; 8516125Swpaul SP_PARM->_default_color = TRUE; 8616125Swpaul init_pair(0, (short) fg, (short) bg); 8716125Swpaul SP_PARM->_default_color = save; 8816125Swpaul } 8916125Swpaul code = OK; 9016125Swpaul } 9116125Swpaul#endif 9216125Swpaul } 9316125Swpaul returnCode(code); 9416125Swpaul} 9516125Swpaul 9616125Swpaul#if NCURSES_SP_FUNCS 9716125SwpaulNCURSES_EXPORT(int) 9816125Swpaulassume_default_colors(int fg, int bg) 9916125Swpaul{ 10016125Swpaul return NCURSES_SP_NAME(assume_default_colors) (CURRENT_SCREEN, fg, bg); 10116125Swpaul} 10216125Swpaul#endif 10316125Swpaul