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