Home | History | Annotate | Line # | Download | only in libcurses
attributes.c revision 1.35
      1  1.35   blymn /*	$NetBSD: attributes.c,v 1.35 2022/10/25 06:20:01 blymn Exp $	*/
      2   1.1     mrg 
      3   1.3     jdc /*-
      4   1.3     jdc  * Copyright (c) 1999 The NetBSD Foundation, Inc.
      5   1.1     mrg  * All rights reserved.
      6   1.1     mrg  *
      7   1.3     jdc  * This code is derived from software contributed to The NetBSD Foundation
      8   1.3     jdc  * by Julian Coleman.
      9   1.3     jdc  *
     10   1.1     mrg  * Redistribution and use in source and binary forms, with or without
     11   1.1     mrg  * modification, are permitted provided that the following conditions
     12   1.1     mrg  * are met:
     13   1.1     mrg  * 1. Redistributions of source code must retain the above copyright
     14   1.1     mrg  *    notice, this list of conditions and the following disclaimer.
     15   1.3     jdc  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.3     jdc  *    notice, this list of conditions and the following disclaimer in the
     17   1.3     jdc  *    documentation and/or other materials provided with the distribution.
     18   1.1     mrg  *
     19   1.3     jdc  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20   1.3     jdc  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21   1.3     jdc  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22   1.3     jdc  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23   1.3     jdc  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24   1.3     jdc  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25   1.3     jdc  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26   1.3     jdc  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27   1.3     jdc  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28   1.3     jdc  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29   1.3     jdc  * POSSIBILITY OF SUCH DAMAGE.
     30   1.1     mrg  */
     31   1.6   blymn 
     32   1.6   blymn #include <sys/cdefs.h>
     33   1.6   blymn #ifndef lint
     34  1.35   blymn __RCSID("$NetBSD: attributes.c,v 1.35 2022/10/25 06:20:01 blymn Exp $");
     35   1.6   blymn #endif				/* not lint */
     36   1.1     mrg 
     37   1.1     mrg #include "curses.h"
     38   1.2   blymn #include "curses_private.h"
     39   1.1     mrg 
     40  1.27     uwe static int __wattr_off(WINDOW *, attr_t);
     41  1.27     uwe static int __wattr_on(WINDOW *, attr_t);
     42  1.25     uwe static void __wcolor_set(WINDOW *, attr_t);
     43  1.12     jdc 
     44  1.27     uwe 
     45   1.4   blymn #ifndef _CURSES_USE_MACROS
     46  1.31     uwe #ifdef HAVE_WCHAR
     47   1.4   blymn /*
     48  1.12     jdc  * attr_get --
     49  1.16     jdc  *	Get wide attributes and color pair from stdscr
     50  1.12     jdc  */
     51  1.12     jdc /* ARGSUSED */
     52  1.12     jdc int
     53  1.28     uwe attr_get(attr_t *attr, short *pair, void *opts)
     54  1.12     jdc {
     55  1.28     uwe 	return wattr_get(stdscr, attr, pair, opts);
     56  1.12     jdc }
     57  1.12     jdc 
     58  1.12     jdc /*
     59  1.12     jdc  * attr_on --
     60  1.16     jdc  *	Test and set wide attributes on stdscr
     61  1.12     jdc  */
     62  1.12     jdc /* ARGSUSED */
     63  1.12     jdc int
     64  1.28     uwe attr_on(attr_t attr, void *opts)
     65  1.12     jdc {
     66  1.28     uwe 	return wattr_on(stdscr, attr, opts);
     67  1.12     jdc }
     68  1.12     jdc 
     69  1.12     jdc /*
     70  1.12     jdc  * attr_off --
     71  1.16     jdc  *	Test and unset wide attributes on stdscr
     72  1.12     jdc  */
     73  1.12     jdc /* ARGSUSED */
     74  1.12     jdc int
     75  1.28     uwe attr_off(attr_t attr, void *opts)
     76  1.12     jdc {
     77  1.28     uwe 	return wattr_off(stdscr, attr, opts);
     78  1.12     jdc }
     79  1.12     jdc 
     80  1.12     jdc /*
     81  1.12     jdc  * attr_set --
     82  1.16     jdc  *	Set wide attributes and color pair on stdscr
     83  1.12     jdc  */
     84  1.12     jdc /* ARGSUSED */
     85  1.12     jdc int
     86  1.28     uwe attr_set(attr_t attr, short pair, void *opts)
     87  1.12     jdc {
     88  1.28     uwe 	return wattr_set(stdscr, attr, pair, opts);
     89  1.12     jdc }
     90  1.12     jdc 
     91  1.12     jdc /*
     92  1.12     jdc  * color_set --
     93  1.12     jdc  *	Set color pair on stdscr
     94  1.12     jdc  */
     95  1.12     jdc /* ARGSUSED */
     96  1.12     jdc int
     97  1.28     uwe color_set(short pair, void *opts)
     98  1.12     jdc {
     99  1.28     uwe 	return wcolor_set(stdscr, pair, opts);
    100  1.12     jdc }
    101  1.31     uwe #endif /* HAVE_WCHAR */
    102  1.12     jdc 
    103  1.12     jdc /*
    104   1.8     jdc  * attron --
    105   1.4   blymn  *	Test and set attributes on stdscr
    106   1.4   blymn  */
    107   1.4   blymn int
    108   1.4   blymn attron(int attr)
    109   1.4   blymn {
    110  1.30     uwe 	return wattron(stdscr, attr);
    111   1.4   blymn }
    112   1.4   blymn 
    113   1.4   blymn /*
    114   1.8     jdc  * attroff --
    115   1.4   blymn  *	Test and unset attributes on stdscr.
    116   1.4   blymn  */
    117   1.4   blymn int
    118   1.4   blymn attroff(int attr)
    119   1.4   blymn {
    120  1.30     uwe 	return wattroff(stdscr, attr);
    121   1.4   blymn }
    122   1.4   blymn 
    123   1.4   blymn /*
    124   1.8     jdc  * attrset --
    125   1.4   blymn  *	Set specific attribute modes.
    126   1.4   blymn  *	Unset others.  On stdscr.
    127   1.4   blymn  */
    128   1.4   blymn int
    129   1.4   blymn attrset(int attr)
    130   1.4   blymn {
    131   1.4   blymn 	return wattrset(stdscr, attr);
    132   1.4   blymn }
    133  1.12     jdc #endif	/* _CURSES_USE_MACROS */
    134   1.4   blymn 
    135  1.31     uwe 
    136  1.31     uwe #ifdef HAVE_WCHAR
    137  1.12     jdc /*
    138  1.12     jdc  * wattr_get --
    139  1.16     jdc  *	Get wide attributes and colour pair from window
    140  1.12     jdc  *	Note that attributes also includes colour.
    141  1.12     jdc  */
    142  1.12     jdc /* ARGSUSED */
    143  1.12     jdc int
    144  1.28     uwe wattr_get(WINDOW *win, attr_t *attr, short *pair, void *opts)
    145  1.12     jdc {
    146  1.35   blymn 	if (__predict_false(win == NULL))
    147  1.35   blymn 		return ERR;
    148  1.35   blymn 
    149  1.14     jdc 	__CTRACE(__CTRACE_ATTR, "wattr_get: win %p\n", win);
    150  1.15   blymn 	if (attr != NULL) {
    151  1.12     jdc 		*attr = win->wattr;
    152  1.15   blymn #ifdef HAVE_WCHAR
    153  1.15   blymn 		*attr &= WA_ATTRIBUTES;
    154  1.15   blymn #endif
    155  1.15   blymn 	}
    156  1.15   blymn 
    157  1.12     jdc 	if (pair != NULL)
    158  1.12     jdc 		*pair = PAIR_NUMBER(win->wattr);
    159  1.12     jdc 	return OK;
    160  1.12     jdc }
    161   1.4   blymn 
    162   1.1     mrg /*
    163  1.12     jdc  * wattr_on --
    164  1.16     jdc  *	Test and set wide attributes on window
    165   1.1     mrg  */
    166   1.1     mrg int
    167  1.28     uwe wattr_on(WINDOW *win, attr_t attr, void *opts)
    168   1.1     mrg {
    169  1.28     uwe 	if (__predict_false(opts != NULL))
    170  1.27     uwe 		return ERR;
    171  1.23     roy 
    172  1.27     uwe 	return __wattr_on(win, attr);
    173   1.1     mrg }
    174   1.1     mrg 
    175   1.1     mrg /*
    176  1.12     jdc  * wattr_off --
    177  1.16     jdc  *	Test and unset wide attributes on window
    178   1.1     mrg  *
    179   1.1     mrg  *	Note that the 'me' sequence unsets all attributes.  We handle
    180   1.1     mrg  *	which attributes should really be set in refresh.c:makech().
    181   1.1     mrg  */
    182   1.1     mrg int
    183  1.28     uwe wattr_off(WINDOW *win, attr_t attr, void *opts)
    184   1.1     mrg {
    185  1.28     uwe 	if (__predict_false(opts != NULL))
    186  1.27     uwe 		return ERR;
    187  1.23     roy 
    188  1.27     uwe 	return __wattr_off(win, attr);
    189  1.12     jdc }
    190  1.12     jdc 
    191  1.27     uwe 
    192  1.12     jdc /*
    193  1.12     jdc  * wattr_set --
    194  1.16     jdc  *	Set wide attributes and color pair on window
    195  1.12     jdc  */
    196  1.12     jdc int
    197  1.28     uwe wattr_set(WINDOW *win, attr_t attr, short pair, void *opts)
    198  1.12     jdc {
    199  1.14     jdc 	__CTRACE(__CTRACE_ATTR, "wattr_set: win %p, attr %08x, pair %d\n",
    200  1.14     jdc 	    win, attr, pair);
    201  1.28     uwe 	if (__predict_false(opts != NULL))
    202  1.27     uwe 		return ERR;
    203  1.27     uwe 
    204  1.12     jdc 	/*
    205  1.15   blymn 	 * This overwrites any colour setting from the attributes
    206  1.12     jdc 	 * and is compatible with ncurses.
    207  1.12     jdc 	 */
    208  1.22     roy 	attr = (attr & ~__COLOR) | COLOR_PAIR(pair);
    209  1.27     uwe 
    210  1.29     uwe 	__wattr_off(win, WA_ATTRIBUTES);
    211  1.27     uwe 	__wattr_on(win, attr);
    212  1.12     jdc 	return OK;
    213  1.12     jdc }
    214  1.12     jdc 
    215  1.12     jdc /*
    216  1.25     uwe  * wcolor_set --
    217  1.25     uwe  *	Set color pair on window
    218  1.25     uwe  */
    219  1.25     uwe /* ARGSUSED */
    220  1.25     uwe int
    221  1.28     uwe wcolor_set(WINDOW *win, short pair, void *opts)
    222  1.25     uwe {
    223  1.25     uwe 	__CTRACE(__CTRACE_COLOR, "wolor_set: win %p, pair %d\n", win, pair);
    224  1.25     uwe 	__wcolor_set(win, (attr_t) COLOR_PAIR(pair));
    225  1.25     uwe 	return OK;
    226  1.25     uwe }
    227  1.31     uwe #endif /* HAVE_WCHAR */
    228  1.31     uwe 
    229  1.25     uwe 
    230  1.25     uwe /*
    231  1.25     uwe  * getattrs --
    232  1.25     uwe  *	Get window attributes.
    233  1.25     uwe  */
    234  1.25     uwe chtype
    235  1.25     uwe getattrs(WINDOW *win)
    236  1.25     uwe {
    237  1.35   blymn 	if (__predict_false(win == NULL))
    238  1.35   blymn 		return ERR;
    239  1.35   blymn 
    240  1.25     uwe 	__CTRACE(__CTRACE_ATTR, "getattrs: win %p\n", win);
    241  1.25     uwe 	return((chtype) win->wattr);
    242  1.25     uwe }
    243  1.25     uwe 
    244  1.25     uwe /*
    245  1.12     jdc  * wattron --
    246  1.12     jdc  *	Test and set attributes.
    247  1.12     jdc  */
    248  1.12     jdc int
    249  1.12     jdc wattron(WINDOW *win, int attr)
    250  1.12     jdc {
    251  1.14     jdc 	__CTRACE(__CTRACE_ATTR, "wattron: win %p, attr %08x\n", win, attr);
    252  1.27     uwe 	return __wattr_on(win, (attr_t) attr);
    253  1.12     jdc }
    254  1.12     jdc 
    255  1.12     jdc /*
    256  1.12     jdc  * wattroff --
    257  1.12     jdc  *	Test and unset attributes.
    258  1.12     jdc  */
    259  1.12     jdc int
    260  1.12     jdc wattroff(WINDOW *win, int attr)
    261  1.12     jdc {
    262  1.14     jdc 	__CTRACE(__CTRACE_ATTR, "wattroff: win %p, attr %08x\n", win, attr);
    263  1.27     uwe 	return __wattr_off(win, (attr_t) attr);
    264   1.1     mrg }
    265   1.1     mrg 
    266   1.1     mrg /*
    267   1.8     jdc  * wattrset --
    268   1.1     mrg  *	Set specific attribute modes.
    269   1.1     mrg  *	Unset others.
    270   1.1     mrg  */
    271   1.1     mrg int
    272   1.4   blymn wattrset(WINDOW *win, int attr)
    273   1.1     mrg {
    274  1.14     jdc 	__CTRACE(__CTRACE_ATTR, "wattrset: win %p, attr %08x\n", win, attr);
    275  1.27     uwe 	__wattr_off(win, __ATTRIBUTES);
    276  1.27     uwe 	__wattr_on(win, (attr_t) attr);
    277  1.12     jdc 	return OK;
    278  1.12     jdc }
    279  1.12     jdc 
    280  1.12     jdc /*
    281  1.16     jdc  * termattrs --
    282  1.16     jdc  *	Get terminal attributes
    283  1.16     jdc  */
    284  1.16     jdc chtype
    285  1.16     jdc termattrs(void)
    286  1.16     jdc {
    287  1.19    yamt 	chtype ch = 0;
    288  1.19    yamt 
    289  1.16     jdc 	__CTRACE(__CTRACE_ATTR, "termattrs\n");
    290  1.20     roy 	if (exit_attribute_mode != NULL) {
    291  1.21   blymn 	__CTRACE(__CTRACE_ATTR, "termattrs: have exit attribute mode\n");
    292  1.20     roy 		if (enter_blink_mode != NULL)
    293  1.16     jdc 			ch |= __BLINK;
    294  1.20     roy 		if (enter_bold_mode != NULL)
    295  1.16     jdc 			ch |= __BOLD;
    296  1.20     roy 		if (enter_dim_mode != NULL)
    297  1.16     jdc 			ch |= __DIM;
    298  1.20     roy 		if (enter_secure_mode != NULL)
    299  1.16     jdc 			ch |= __BLANK;
    300  1.20     roy 		if (enter_protected_mode != NULL)
    301  1.16     jdc 			ch |= __PROTECT;
    302  1.20     roy 		if (enter_reverse_mode != NULL)
    303  1.16     jdc 			ch |= __REVERSE;
    304  1.16     jdc 	}
    305  1.20     roy 	if (enter_standout_mode != NULL && exit_standout_mode != NULL)
    306  1.16     jdc 		ch |= __STANDOUT;
    307  1.20     roy 	if (enter_underline_mode != NULL && exit_underline_mode != NULL)
    308  1.16     jdc 		ch |= __UNDERSCORE;
    309  1.20     roy 	if (enter_alt_charset_mode != NULL && exit_alt_charset_mode != NULL)
    310  1.16     jdc 		ch |= __ALTCHARSET;
    311  1.16     jdc 
    312  1.16     jdc 	return ch;
    313  1.16     jdc }
    314  1.16     jdc 
    315  1.31     uwe 
    316  1.31     uwe #ifdef HAVE_WCHAR
    317  1.16     jdc /*
    318  1.16     jdc  * term_attrs --
    319  1.16     jdc  *	Get terminal wide attributes
    320  1.16     jdc  */
    321  1.16     jdc attr_t
    322  1.16     jdc term_attrs(void)
    323  1.16     jdc {
    324  1.19    yamt 	attr_t attr = 0;
    325  1.19    yamt 
    326  1.16     jdc 	__CTRACE(__CTRACE_ATTR, "term_attrs\n");
    327  1.20     roy 	if (exit_attribute_mode != NULL) {
    328  1.20     roy 		if (enter_blink_mode != NULL)
    329  1.17     jdc 			attr |= __BLINK;
    330  1.20     roy 		if (enter_bold_mode != NULL)
    331  1.17     jdc 			attr |= __BOLD;
    332  1.20     roy 		if (enter_dim_mode != NULL)
    333  1.17     jdc 			attr |= __DIM;
    334  1.20     roy 		if (enter_secure_mode != NULL)
    335  1.17     jdc 			attr |= __BLANK;
    336  1.20     roy 		if (enter_protected_mode != NULL)
    337  1.17     jdc 			attr |= __PROTECT;
    338  1.20     roy 		if (enter_reverse_mode != NULL)
    339  1.17     jdc 			attr |= __REVERSE;
    340  1.16     jdc #ifdef HAVE_WCHAR
    341  1.20     roy 		if (enter_low_hl_mode != NULL)
    342  1.16     jdc 			attr |= WA_LOW;
    343  1.20     roy 		if (enter_top_hl_mode != NULL)
    344  1.16     jdc 			attr |= WA_TOP;
    345  1.20     roy 		if (enter_left_hl_mode != NULL)
    346  1.16     jdc 			attr |= WA_LEFT;
    347  1.20     roy 		if (enter_right_hl_mode != NULL)
    348  1.16     jdc 			attr |= WA_RIGHT;
    349  1.20     roy 		if (enter_horizontal_hl_mode != NULL)
    350  1.16     jdc 			attr |= WA_HORIZONTAL;
    351  1.20     roy 		if (enter_vertical_hl_mode != NULL)
    352  1.16     jdc 			attr |= WA_VERTICAL;
    353  1.16     jdc #endif /* HAVE_WCHAR */
    354  1.16     jdc 	}
    355  1.20     roy 	if (enter_standout_mode != NULL && exit_standout_mode != NULL)
    356  1.17     jdc 		attr |= __STANDOUT;
    357  1.20     roy 	if (enter_underline_mode != NULL && exit_underline_mode != NULL)
    358  1.17     jdc 		attr |= __UNDERSCORE;
    359  1.20     roy 	if (enter_alt_charset_mode != NULL && exit_alt_charset_mode != NULL)
    360  1.17     jdc 		attr |= __ALTCHARSET;
    361  1.16     jdc 
    362  1.16     jdc 	return attr;
    363  1.16     jdc }
    364  1.31     uwe #endif /* HAVE_WCHAR */
    365  1.16     jdc 
    366  1.27     uwe 
    367  1.27     uwe static int
    368  1.27     uwe __wattr_on(WINDOW *win, attr_t attr)
    369  1.27     uwe {
    370  1.35   blymn 	const TERMINAL *t;
    371  1.35   blymn 
    372  1.35   blymn 	if (__predict_false(win == NULL))
    373  1.35   blymn 		return ERR;
    374  1.35   blymn 
    375  1.35   blymn 	t = win->screen->term;
    376  1.27     uwe 
    377  1.27     uwe 	__CTRACE(__CTRACE_ATTR, "wattr_on: win %p, attr %08x\n", win, attr);
    378  1.33  andvar 	/* If can enter modes, set the relevant attribute bits. */
    379  1.27     uwe 	if (t_exit_attribute_mode(t) != NULL) {
    380  1.27     uwe 		if (attr & __BLINK && t_enter_blink_mode(t) != NULL)
    381  1.27     uwe 			win->wattr |= __BLINK;
    382  1.27     uwe 		if (attr & __BOLD && t_enter_bold_mode(t) != NULL)
    383  1.27     uwe 			win->wattr |= __BOLD;
    384  1.27     uwe 		if (attr & __DIM && t_enter_dim_mode(t) != NULL)
    385  1.27     uwe 			win->wattr |= __DIM;
    386  1.27     uwe 		if (attr & __BLANK && t_enter_secure_mode(t) != NULL)
    387  1.27     uwe 			win->wattr |= __BLANK;
    388  1.27     uwe 		if (attr & __PROTECT && t_enter_protected_mode(t) != NULL)
    389  1.27     uwe 			win->wattr |= __PROTECT;
    390  1.27     uwe 		if (attr & __REVERSE && t_enter_reverse_mode(t) != NULL)
    391  1.27     uwe 			win->wattr |= __REVERSE;
    392  1.27     uwe #ifdef HAVE_WCHAR
    393  1.27     uwe 		if (attr & WA_LOW && t_enter_low_hl_mode(t) != NULL)
    394  1.27     uwe 			win->wattr |= WA_LOW;
    395  1.27     uwe 		if (attr & WA_TOP && t_enter_top_hl_mode(t) != NULL)
    396  1.27     uwe 			win->wattr |= WA_TOP;
    397  1.27     uwe 		if (attr & WA_LEFT && t_enter_left_hl_mode(t) != NULL)
    398  1.27     uwe 			win->wattr |= WA_LEFT;
    399  1.27     uwe 		if (attr & WA_RIGHT && t_enter_right_hl_mode(t) != NULL)
    400  1.27     uwe 			win->wattr |= WA_RIGHT;
    401  1.27     uwe 		if (attr & WA_HORIZONTAL && t_enter_horizontal_hl_mode(t) != NULL)
    402  1.27     uwe 			win->wattr |= WA_HORIZONTAL;
    403  1.27     uwe 		if (attr & WA_VERTICAL && t_enter_vertical_hl_mode(t) != NULL)
    404  1.27     uwe 			win->wattr |= WA_VERTICAL;
    405  1.27     uwe #endif /* HAVE_WCHAR */
    406  1.27     uwe 	}
    407  1.27     uwe 	if (attr & __STANDOUT && t_enter_standout_mode(t) != NULL &&
    408  1.27     uwe 	    t_exit_standout_mode(t) != NULL)
    409  1.27     uwe 		wstandout(win);
    410  1.27     uwe 	if (attr & __UNDERSCORE && t_enter_underline_mode(t) != NULL &&
    411  1.27     uwe 	    t_exit_underline_mode(t) != NULL)
    412  1.27     uwe 		wunderscore(win);
    413  1.27     uwe 	if (attr & __COLOR)
    414  1.27     uwe 		__wcolor_set(win, attr);
    415  1.27     uwe 	return OK;
    416  1.27     uwe }
    417  1.27     uwe 
    418  1.27     uwe 
    419  1.27     uwe static int
    420  1.27     uwe __wattr_off(WINDOW *win, attr_t attr)
    421  1.27     uwe {
    422  1.35   blymn 	const TERMINAL *t;
    423  1.35   blymn 
    424  1.35   blymn 	if (__predict_false(win == NULL))
    425  1.35   blymn 		return ERR;
    426  1.35   blymn 
    427  1.35   blymn 	t = win->screen->term;
    428  1.27     uwe 
    429  1.27     uwe 	__CTRACE(__CTRACE_ATTR, "wattr_off: win %p, attr %08x\n", win, attr);
    430  1.33  andvar 	/* If can do exit modes, unset the relevant attribute bits. */
    431  1.27     uwe 	if (t_exit_attribute_mode(t) != NULL) {
    432  1.27     uwe 		if (attr & __BLINK)
    433  1.27     uwe 			win->wattr &= ~__BLINK;
    434  1.27     uwe 		if (attr & __BOLD)
    435  1.27     uwe 			win->wattr &= ~__BOLD;
    436  1.27     uwe 		if (attr & __DIM)
    437  1.27     uwe 			win->wattr &= ~__DIM;
    438  1.27     uwe 		if (attr & __BLANK)
    439  1.27     uwe 			win->wattr &= ~__BLANK;
    440  1.27     uwe 		if (attr & __PROTECT)
    441  1.27     uwe 			win->wattr &= ~__PROTECT;
    442  1.27     uwe 		if (attr & __REVERSE)
    443  1.27     uwe 			win->wattr &= ~__REVERSE;
    444  1.27     uwe #ifdef HAVE_WCHAR
    445  1.27     uwe 		if (attr & WA_LOW)
    446  1.27     uwe 			win->wattr &= ~WA_LOW;
    447  1.27     uwe 		if (attr & WA_TOP)
    448  1.27     uwe 			win->wattr &= ~WA_TOP;
    449  1.27     uwe 		if (attr & WA_LEFT)
    450  1.27     uwe 			win->wattr &= ~WA_LEFT;
    451  1.27     uwe 		if (attr & WA_RIGHT)
    452  1.27     uwe 			win->wattr &= ~WA_RIGHT;
    453  1.27     uwe 		if (attr & WA_HORIZONTAL)
    454  1.27     uwe 			win->wattr &= ~WA_HORIZONTAL;
    455  1.27     uwe 		if (attr & WA_VERTICAL)
    456  1.27     uwe 			win->wattr &= ~WA_VERTICAL;
    457  1.27     uwe #endif /* HAVE_WCHAR */
    458  1.27     uwe 	}
    459  1.27     uwe 	if (attr & __STANDOUT)
    460  1.27     uwe 		wstandend(win);
    461  1.27     uwe 	if (attr & __UNDERSCORE)
    462  1.27     uwe 		wunderend(win);
    463  1.27     uwe 	if (attr & __COLOR) {
    464  1.27     uwe 		if (max_colors != 0)
    465  1.27     uwe 			win->wattr &= ~__COLOR;
    466  1.27     uwe 	}
    467  1.27     uwe 	return OK;
    468  1.27     uwe }
    469  1.27     uwe 
    470  1.27     uwe 
    471  1.25     uwe static void
    472  1.12     jdc __wcolor_set(WINDOW *win, attr_t attr)
    473  1.12     jdc {
    474  1.35   blymn 	const TERMINAL *t;
    475  1.35   blymn 
    476  1.35   blymn 	if (__predict_false(win == NULL))
    477  1.35   blymn 		return;
    478  1.35   blymn 
    479  1.35   blymn 	t = win->screen->term;
    480  1.23     roy 
    481  1.12     jdc 	/* If another color pair is set, turn that off first. */
    482  1.12     jdc 	win->wattr &= ~__COLOR;
    483  1.12     jdc 	/* If can do color video, set the color pair bits. */
    484  1.34   blymn 	if (t_max_colors(t) != 0)
    485  1.12     jdc 		win->wattr |= attr & __COLOR;
    486   1.1     mrg }
    487