Home | History | Annotate | Line # | Download | only in libcurses
attributes.c revision 1.29
      1  1.29    uwe /*	$NetBSD: attributes.c,v 1.29 2018/11/23 11:16:59 uwe 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.29    uwe __RCSID("$NetBSD: attributes.c,v 1.29 2018/11/23 11:16:59 uwe 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.4  blymn /*
     47  1.12    jdc  * attr_get --
     48  1.16    jdc  *	Get wide attributes and color pair from stdscr
     49  1.12    jdc  */
     50  1.12    jdc /* ARGSUSED */
     51  1.12    jdc int
     52  1.28    uwe attr_get(attr_t *attr, short *pair, void *opts)
     53  1.12    jdc {
     54  1.28    uwe 	return wattr_get(stdscr, attr, pair, opts);
     55  1.12    jdc }
     56  1.12    jdc 
     57  1.12    jdc /*
     58  1.12    jdc  * attr_on --
     59  1.16    jdc  *	Test and set wide attributes on stdscr
     60  1.12    jdc  */
     61  1.12    jdc /* ARGSUSED */
     62  1.12    jdc int
     63  1.28    uwe attr_on(attr_t attr, void *opts)
     64  1.12    jdc {
     65  1.28    uwe 	return wattr_on(stdscr, attr, opts);
     66  1.12    jdc }
     67  1.12    jdc 
     68  1.12    jdc /*
     69  1.12    jdc  * attr_off --
     70  1.16    jdc  *	Test and unset wide attributes on stdscr
     71  1.12    jdc  */
     72  1.12    jdc /* ARGSUSED */
     73  1.12    jdc int
     74  1.28    uwe attr_off(attr_t attr, void *opts)
     75  1.12    jdc {
     76  1.28    uwe 	return wattr_off(stdscr, attr, opts);
     77  1.12    jdc }
     78  1.12    jdc 
     79  1.12    jdc /*
     80  1.12    jdc  * attr_set --
     81  1.16    jdc  *	Set wide attributes and color pair on stdscr
     82  1.12    jdc  */
     83  1.12    jdc /* ARGSUSED */
     84  1.12    jdc int
     85  1.28    uwe attr_set(attr_t attr, short pair, void *opts)
     86  1.12    jdc {
     87  1.28    uwe 	return wattr_set(stdscr, attr, pair, opts);
     88  1.12    jdc }
     89  1.12    jdc 
     90  1.12    jdc /*
     91  1.12    jdc  * color_set --
     92  1.12    jdc  *	Set color pair on stdscr
     93  1.12    jdc  */
     94  1.12    jdc /* ARGSUSED */
     95  1.12    jdc int
     96  1.28    uwe color_set(short pair, void *opts)
     97  1.12    jdc {
     98  1.28    uwe 	return wcolor_set(stdscr, pair, opts);
     99  1.12    jdc }
    100  1.12    jdc 
    101  1.12    jdc /*
    102   1.8    jdc  * attron --
    103   1.4  blymn  *	Test and set attributes on stdscr
    104   1.4  blymn  */
    105   1.4  blymn int
    106   1.4  blymn attron(int attr)
    107   1.4  blymn {
    108  1.27    uwe 	return __wattr_on(stdscr, (attr_t) attr);
    109   1.4  blymn }
    110   1.4  blymn 
    111   1.4  blymn /*
    112   1.8    jdc  * attroff --
    113   1.4  blymn  *	Test and unset attributes on stdscr.
    114   1.4  blymn  */
    115   1.4  blymn int
    116   1.4  blymn attroff(int attr)
    117   1.4  blymn {
    118  1.27    uwe 	return __wattr_off(stdscr, (attr_t) attr);
    119   1.4  blymn }
    120   1.4  blymn 
    121   1.4  blymn /*
    122   1.8    jdc  * attrset --
    123   1.4  blymn  *	Set specific attribute modes.
    124   1.4  blymn  *	Unset others.  On stdscr.
    125   1.4  blymn  */
    126   1.4  blymn int
    127   1.4  blymn attrset(int attr)
    128   1.4  blymn {
    129   1.4  blymn 	return wattrset(stdscr, attr);
    130   1.4  blymn }
    131  1.12    jdc #endif	/* _CURSES_USE_MACROS */
    132   1.4  blymn 
    133  1.12    jdc /*
    134  1.12    jdc  * wattr_get --
    135  1.16    jdc  *	Get wide attributes and colour pair from window
    136  1.12    jdc  *	Note that attributes also includes colour.
    137  1.12    jdc  */
    138  1.12    jdc /* ARGSUSED */
    139  1.12    jdc int
    140  1.28    uwe wattr_get(WINDOW *win, attr_t *attr, short *pair, void *opts)
    141  1.12    jdc {
    142  1.12    jdc #ifdef DEBUG
    143  1.14    jdc 	__CTRACE(__CTRACE_ATTR, "wattr_get: win %p\n", win);
    144   1.4  blymn #endif
    145  1.15  blymn 	if (attr != NULL) {
    146  1.12    jdc 		*attr = win->wattr;
    147  1.15  blymn #ifdef HAVE_WCHAR
    148  1.15  blymn 		*attr &= WA_ATTRIBUTES;
    149  1.15  blymn #endif
    150  1.15  blymn 	}
    151  1.15  blymn 
    152  1.12    jdc 	if (pair != NULL)
    153  1.12    jdc 		*pair = PAIR_NUMBER(win->wattr);
    154  1.12    jdc 	return OK;
    155  1.12    jdc }
    156   1.4  blymn 
    157   1.1    mrg /*
    158  1.12    jdc  * wattr_on --
    159  1.16    jdc  *	Test and set wide attributes on window
    160   1.1    mrg  */
    161   1.1    mrg int
    162  1.28    uwe wattr_on(WINDOW *win, attr_t attr, void *opts)
    163   1.1    mrg {
    164  1.28    uwe 	if (__predict_false(opts != NULL))
    165  1.27    uwe 		return ERR;
    166  1.23    roy 
    167  1.27    uwe 	return __wattr_on(win, attr);
    168   1.1    mrg }
    169   1.1    mrg 
    170   1.1    mrg /*
    171  1.12    jdc  * wattr_off --
    172  1.16    jdc  *	Test and unset wide attributes on window
    173   1.1    mrg  *
    174   1.1    mrg  *	Note that the 'me' sequence unsets all attributes.  We handle
    175   1.1    mrg  *	which attributes should really be set in refresh.c:makech().
    176   1.1    mrg  */
    177   1.1    mrg int
    178  1.28    uwe wattr_off(WINDOW *win, attr_t attr, void *opts)
    179   1.1    mrg {
    180  1.28    uwe 	if (__predict_false(opts != NULL))
    181  1.27    uwe 		return ERR;
    182  1.23    roy 
    183  1.27    uwe 	return __wattr_off(win, attr);
    184  1.12    jdc }
    185  1.12    jdc 
    186  1.27    uwe 
    187  1.12    jdc /*
    188  1.12    jdc  * wattr_set --
    189  1.16    jdc  *	Set wide attributes and color pair on window
    190  1.12    jdc  */
    191  1.12    jdc int
    192  1.28    uwe wattr_set(WINDOW *win, attr_t attr, short pair, void *opts)
    193  1.12    jdc {
    194  1.12    jdc #ifdef DEBUG
    195  1.14    jdc 	__CTRACE(__CTRACE_ATTR, "wattr_set: win %p, attr %08x, pair %d\n",
    196  1.14    jdc 	    win, attr, pair);
    197  1.12    jdc #endif
    198  1.28    uwe 	if (__predict_false(opts != NULL))
    199  1.27    uwe 		return ERR;
    200  1.27    uwe 
    201  1.12    jdc 	/*
    202  1.15  blymn 	 * This overwrites any colour setting from the attributes
    203  1.12    jdc 	 * and is compatible with ncurses.
    204  1.12    jdc 	 */
    205  1.22    roy 	attr = (attr & ~__COLOR) | COLOR_PAIR(pair);
    206  1.27    uwe 
    207  1.29    uwe 	__wattr_off(win, WA_ATTRIBUTES);
    208  1.27    uwe 	__wattr_on(win, attr);
    209  1.12    jdc 	return OK;
    210  1.12    jdc }
    211  1.12    jdc 
    212  1.12    jdc /*
    213  1.25    uwe  * wcolor_set --
    214  1.25    uwe  *	Set color pair on window
    215  1.25    uwe  */
    216  1.25    uwe /* ARGSUSED */
    217  1.25    uwe int
    218  1.28    uwe wcolor_set(WINDOW *win, short pair, void *opts)
    219  1.25    uwe {
    220  1.25    uwe #ifdef DEBUG
    221  1.25    uwe 	__CTRACE(__CTRACE_COLOR, "wolor_set: win %p, pair %d\n", win, pair);
    222  1.25    uwe #endif
    223  1.25    uwe 	__wcolor_set(win, (attr_t) COLOR_PAIR(pair));
    224  1.25    uwe 	return OK;
    225  1.25    uwe }
    226  1.25    uwe 
    227  1.25    uwe /*
    228  1.25    uwe  * getattrs --
    229  1.25    uwe  *	Get window attributes.
    230  1.25    uwe  */
    231  1.25    uwe chtype
    232  1.25    uwe getattrs(WINDOW *win)
    233  1.25    uwe {
    234  1.25    uwe #ifdef DEBUG
    235  1.25    uwe 	__CTRACE(__CTRACE_ATTR, "getattrs: win %p\n", win);
    236  1.25    uwe #endif
    237  1.25    uwe 	return((chtype) win->wattr);
    238  1.25    uwe }
    239  1.25    uwe 
    240  1.25    uwe /*
    241  1.12    jdc  * wattron --
    242  1.12    jdc  *	Test and set attributes.
    243  1.12    jdc  */
    244  1.12    jdc int
    245  1.12    jdc wattron(WINDOW *win, int attr)
    246  1.12    jdc {
    247  1.12    jdc #ifdef DEBUG
    248  1.14    jdc 	__CTRACE(__CTRACE_ATTR, "wattron: win %p, attr %08x\n", win, attr);
    249  1.12    jdc #endif
    250  1.27    uwe 	return __wattr_on(win, (attr_t) attr);
    251  1.12    jdc }
    252  1.12    jdc 
    253  1.12    jdc /*
    254  1.12    jdc  * wattroff --
    255  1.12    jdc  *	Test and unset attributes.
    256  1.12    jdc  */
    257  1.12    jdc int
    258  1.12    jdc wattroff(WINDOW *win, int attr)
    259  1.12    jdc {
    260  1.12    jdc #ifdef DEBUG
    261  1.14    jdc 	__CTRACE(__CTRACE_ATTR, "wattroff: win %p, attr %08x\n", win, attr);
    262  1.12    jdc #endif
    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.5    jdc #ifdef DEBUG
    275  1.14    jdc 	__CTRACE(__CTRACE_ATTR, "wattrset: win %p, attr %08x\n", win, attr);
    276   1.5    jdc #endif
    277  1.27    uwe 	__wattr_off(win, __ATTRIBUTES);
    278  1.27    uwe 	__wattr_on(win, (attr_t) attr);
    279  1.12    jdc 	return OK;
    280  1.12    jdc }
    281  1.12    jdc 
    282  1.12    jdc /*
    283  1.16    jdc  * termattrs --
    284  1.16    jdc  *	Get terminal attributes
    285  1.16    jdc  */
    286  1.16    jdc chtype
    287  1.16    jdc termattrs(void)
    288  1.16    jdc {
    289  1.19   yamt 	chtype ch = 0;
    290  1.19   yamt 
    291  1.16    jdc #ifdef DEBUG
    292  1.16    jdc 	__CTRACE(__CTRACE_ATTR, "termattrs\n");
    293  1.16    jdc #endif
    294  1.20    roy 	if (exit_attribute_mode != NULL) {
    295  1.21  blymn #ifdef DEBUG
    296  1.21  blymn 	__CTRACE(__CTRACE_ATTR, "termattrs: have exit attribute mode\n");
    297  1.21  blymn #endif
    298  1.20    roy 		if (enter_blink_mode != NULL)
    299  1.16    jdc 			ch |= __BLINK;
    300  1.20    roy 		if (enter_bold_mode != NULL)
    301  1.16    jdc 			ch |= __BOLD;
    302  1.20    roy 		if (enter_dim_mode != NULL)
    303  1.16    jdc 			ch |= __DIM;
    304  1.20    roy 		if (enter_secure_mode != NULL)
    305  1.16    jdc 			ch |= __BLANK;
    306  1.20    roy 		if (enter_protected_mode != NULL)
    307  1.16    jdc 			ch |= __PROTECT;
    308  1.20    roy 		if (enter_reverse_mode != NULL)
    309  1.16    jdc 			ch |= __REVERSE;
    310  1.16    jdc 	}
    311  1.20    roy 	if (enter_standout_mode != NULL && exit_standout_mode != NULL)
    312  1.16    jdc 		ch |= __STANDOUT;
    313  1.20    roy 	if (enter_underline_mode != NULL && exit_underline_mode != NULL)
    314  1.16    jdc 		ch |= __UNDERSCORE;
    315  1.20    roy 	if (enter_alt_charset_mode != NULL && exit_alt_charset_mode != NULL)
    316  1.16    jdc 		ch |= __ALTCHARSET;
    317  1.16    jdc 
    318  1.16    jdc 	return ch;
    319  1.16    jdc }
    320  1.16    jdc 
    321  1.16    jdc /*
    322  1.16    jdc  * term_attrs --
    323  1.16    jdc  *	Get terminal wide attributes
    324  1.16    jdc  */
    325  1.16    jdc attr_t
    326  1.16    jdc term_attrs(void)
    327  1.16    jdc {
    328  1.19   yamt 	attr_t attr = 0;
    329  1.19   yamt 
    330  1.16    jdc #ifdef DEBUG
    331  1.16    jdc 	__CTRACE(__CTRACE_ATTR, "term_attrs\n");
    332  1.16    jdc #endif
    333  1.20    roy 	if (exit_attribute_mode != NULL) {
    334  1.20    roy 		if (enter_blink_mode != NULL)
    335  1.17    jdc 			attr |= __BLINK;
    336  1.20    roy 		if (enter_bold_mode != NULL)
    337  1.17    jdc 			attr |= __BOLD;
    338  1.20    roy 		if (enter_dim_mode != NULL)
    339  1.17    jdc 			attr |= __DIM;
    340  1.20    roy 		if (enter_secure_mode != NULL)
    341  1.17    jdc 			attr |= __BLANK;
    342  1.20    roy 		if (enter_protected_mode != NULL)
    343  1.17    jdc 			attr |= __PROTECT;
    344  1.20    roy 		if (enter_reverse_mode != NULL)
    345  1.17    jdc 			attr |= __REVERSE;
    346  1.16    jdc #ifdef HAVE_WCHAR
    347  1.20    roy 		if (enter_low_hl_mode != NULL)
    348  1.16    jdc 			attr |= WA_LOW;
    349  1.20    roy 		if (enter_top_hl_mode != NULL)
    350  1.16    jdc 			attr |= WA_TOP;
    351  1.20    roy 		if (enter_left_hl_mode != NULL)
    352  1.16    jdc 			attr |= WA_LEFT;
    353  1.20    roy 		if (enter_right_hl_mode != NULL)
    354  1.16    jdc 			attr |= WA_RIGHT;
    355  1.20    roy 		if (enter_horizontal_hl_mode != NULL)
    356  1.16    jdc 			attr |= WA_HORIZONTAL;
    357  1.20    roy 		if (enter_vertical_hl_mode != NULL)
    358  1.16    jdc 			attr |= WA_VERTICAL;
    359  1.16    jdc #endif /* HAVE_WCHAR */
    360  1.16    jdc 	}
    361  1.20    roy 	if (enter_standout_mode != NULL && exit_standout_mode != NULL)
    362  1.17    jdc 		attr |= __STANDOUT;
    363  1.20    roy 	if (enter_underline_mode != NULL && exit_underline_mode != NULL)
    364  1.17    jdc 		attr |= __UNDERSCORE;
    365  1.20    roy 	if (enter_alt_charset_mode != NULL && exit_alt_charset_mode != NULL)
    366  1.17    jdc 		attr |= __ALTCHARSET;
    367  1.16    jdc 
    368  1.16    jdc 	return attr;
    369  1.16    jdc }
    370  1.16    jdc 
    371  1.27    uwe 
    372  1.27    uwe static int
    373  1.27    uwe __wattr_on(WINDOW *win, attr_t attr)
    374  1.27    uwe {
    375  1.27    uwe 	const TERMINAL *t = win->screen->term;
    376  1.27    uwe 
    377  1.27    uwe #ifdef DEBUG
    378  1.27    uwe 	__CTRACE(__CTRACE_ATTR, "wattr_on: win %p, attr %08x\n", win, attr);
    379  1.27    uwe #endif
    380  1.27    uwe 	/* If can enter modes, set the relevent attribute bits. */
    381  1.27    uwe 	if (t_exit_attribute_mode(t) != NULL) {
    382  1.27    uwe 		if (attr & __BLINK && t_enter_blink_mode(t) != NULL)
    383  1.27    uwe 			win->wattr |= __BLINK;
    384  1.27    uwe 		if (attr & __BOLD && t_enter_bold_mode(t) != NULL)
    385  1.27    uwe 			win->wattr |= __BOLD;
    386  1.27    uwe 		if (attr & __DIM && t_enter_dim_mode(t) != NULL)
    387  1.27    uwe 			win->wattr |= __DIM;
    388  1.27    uwe 		if (attr & __BLANK && t_enter_secure_mode(t) != NULL)
    389  1.27    uwe 			win->wattr |= __BLANK;
    390  1.27    uwe 		if (attr & __PROTECT && t_enter_protected_mode(t) != NULL)
    391  1.27    uwe 			win->wattr |= __PROTECT;
    392  1.27    uwe 		if (attr & __REVERSE && t_enter_reverse_mode(t) != NULL)
    393  1.27    uwe 			win->wattr |= __REVERSE;
    394  1.27    uwe #ifdef HAVE_WCHAR
    395  1.27    uwe 		if (attr & WA_LOW && t_enter_low_hl_mode(t) != NULL)
    396  1.27    uwe 			win->wattr |= WA_LOW;
    397  1.27    uwe 		if (attr & WA_TOP && t_enter_top_hl_mode(t) != NULL)
    398  1.27    uwe 			win->wattr |= WA_TOP;
    399  1.27    uwe 		if (attr & WA_LEFT && t_enter_left_hl_mode(t) != NULL)
    400  1.27    uwe 			win->wattr |= WA_LEFT;
    401  1.27    uwe 		if (attr & WA_RIGHT && t_enter_right_hl_mode(t) != NULL)
    402  1.27    uwe 			win->wattr |= WA_RIGHT;
    403  1.27    uwe 		if (attr & WA_HORIZONTAL && t_enter_horizontal_hl_mode(t) != NULL)
    404  1.27    uwe 			win->wattr |= WA_HORIZONTAL;
    405  1.27    uwe 		if (attr & WA_VERTICAL && t_enter_vertical_hl_mode(t) != NULL)
    406  1.27    uwe 			win->wattr |= WA_VERTICAL;
    407  1.27    uwe #endif /* HAVE_WCHAR */
    408  1.27    uwe 	}
    409  1.27    uwe 	if (attr & __STANDOUT && t_enter_standout_mode(t) != NULL &&
    410  1.27    uwe 	    t_exit_standout_mode(t) != NULL)
    411  1.27    uwe 		wstandout(win);
    412  1.27    uwe 	if (attr & __UNDERSCORE && t_enter_underline_mode(t) != NULL &&
    413  1.27    uwe 	    t_exit_underline_mode(t) != NULL)
    414  1.27    uwe 		wunderscore(win);
    415  1.27    uwe 	if (attr & __COLOR)
    416  1.27    uwe 		__wcolor_set(win, attr);
    417  1.27    uwe 	return OK;
    418  1.27    uwe }
    419  1.27    uwe 
    420  1.27    uwe 
    421  1.27    uwe static int
    422  1.27    uwe __wattr_off(WINDOW *win, attr_t attr)
    423  1.27    uwe {
    424  1.27    uwe 	const TERMINAL *t = win->screen->term;
    425  1.27    uwe 
    426  1.27    uwe #ifdef DEBUG
    427  1.27    uwe 	__CTRACE(__CTRACE_ATTR, "wattr_off: win %p, attr %08x\n", win, attr);
    428  1.27    uwe #endif
    429  1.27    uwe 	/* If can do exit modes, unset the relevent attribute bits. */
    430  1.27    uwe 	if (t_exit_attribute_mode(t) != NULL) {
    431  1.27    uwe 		if (attr & __BLINK)
    432  1.27    uwe 			win->wattr &= ~__BLINK;
    433  1.27    uwe 		if (attr & __BOLD)
    434  1.27    uwe 			win->wattr &= ~__BOLD;
    435  1.27    uwe 		if (attr & __DIM)
    436  1.27    uwe 			win->wattr &= ~__DIM;
    437  1.27    uwe 		if (attr & __BLANK)
    438  1.27    uwe 			win->wattr &= ~__BLANK;
    439  1.27    uwe 		if (attr & __PROTECT)
    440  1.27    uwe 			win->wattr &= ~__PROTECT;
    441  1.27    uwe 		if (attr & __REVERSE)
    442  1.27    uwe 			win->wattr &= ~__REVERSE;
    443  1.27    uwe #ifdef HAVE_WCHAR
    444  1.27    uwe 		if (attr & WA_LOW)
    445  1.27    uwe 			win->wattr &= ~WA_LOW;
    446  1.27    uwe 		if (attr & WA_TOP)
    447  1.27    uwe 			win->wattr &= ~WA_TOP;
    448  1.27    uwe 		if (attr & WA_LEFT)
    449  1.27    uwe 			win->wattr &= ~WA_LEFT;
    450  1.27    uwe 		if (attr & WA_RIGHT)
    451  1.27    uwe 			win->wattr &= ~WA_RIGHT;
    452  1.27    uwe 		if (attr & WA_HORIZONTAL)
    453  1.27    uwe 			win->wattr &= ~WA_HORIZONTAL;
    454  1.27    uwe 		if (attr & WA_VERTICAL)
    455  1.27    uwe 			win->wattr &= ~WA_VERTICAL;
    456  1.27    uwe #endif /* HAVE_WCHAR */
    457  1.27    uwe 	}
    458  1.27    uwe 	if (attr & __STANDOUT)
    459  1.27    uwe 		wstandend(win);
    460  1.27    uwe 	if (attr & __UNDERSCORE)
    461  1.27    uwe 		wunderend(win);
    462  1.27    uwe 	if (attr & __COLOR) {
    463  1.27    uwe 		if (max_colors != 0)
    464  1.27    uwe 			win->wattr &= ~__COLOR;
    465  1.27    uwe 	}
    466  1.27    uwe 	return OK;
    467  1.27    uwe }
    468  1.27    uwe 
    469  1.27    uwe 
    470  1.25    uwe static void
    471  1.12    jdc __wcolor_set(WINDOW *win, attr_t attr)
    472  1.12    jdc {
    473  1.23    roy 	const TERMINAL *t = win->screen->term;
    474  1.23    roy 
    475  1.12    jdc 	/* If another color pair is set, turn that off first. */
    476  1.12    jdc 	win->wattr &= ~__COLOR;
    477  1.12    jdc 	/* If can do color video, set the color pair bits. */
    478  1.23    roy 	if (t_max_colors(t) != 0 && attr & __COLOR)
    479  1.12    jdc 		win->wattr |= attr & __COLOR;
    480   1.1    mrg }
    481