Home | History | Annotate | Line # | Download | only in libcurses
attributes.c revision 1.21.28.2
      1  1.21.28.2  pgoyette /*	$NetBSD: attributes.c,v 1.21.28.2 2017/03/20 06:56:58 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.2  pgoyette __RCSID("$NetBSD: attributes.c,v 1.21.28.2 2017/03/20 06:56:58 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.21.28.2  pgoyette 	const TERMINAL *t = win->screen->term;
    163  1.21.28.2  pgoyette 
    164        1.3       jdc #ifdef DEBUG
    165       1.14       jdc 	__CTRACE(__CTRACE_ATTR, "wattr_on: win %p, attr %08x\n", win, attr);
    166        1.3       jdc #endif
    167        1.7   mycroft 	/* If can enter modes, set the relevent attribute bits. */
    168  1.21.28.2  pgoyette 	if (t_exit_attribute_mode(t) != NULL) {
    169  1.21.28.2  pgoyette 		if (attr & __BLINK && t_enter_blink_mode(t) != NULL)
    170        1.2     blymn 			win->wattr |= __BLINK;
    171  1.21.28.2  pgoyette 		if (attr & __BOLD && t_enter_bold_mode(t) != NULL)
    172        1.2     blymn 			win->wattr |= __BOLD;
    173  1.21.28.2  pgoyette 		if (attr & __DIM && t_enter_dim_mode(t) != NULL)
    174        1.2     blymn 			win->wattr |= __DIM;
    175  1.21.28.2  pgoyette 		if (attr & __BLANK && t_enter_secure_mode(t) != NULL)
    176        1.2     blymn 			win->wattr |= __BLANK;
    177  1.21.28.2  pgoyette 		if (attr & __PROTECT && t_enter_protected_mode(t) != NULL)
    178        1.2     blymn 			win->wattr |= __PROTECT;
    179  1.21.28.2  pgoyette 		if (attr & __REVERSE && t_enter_reverse_mode(t) != NULL)
    180        1.2     blymn 			win->wattr |= __REVERSE;
    181       1.15     blymn #ifdef HAVE_WCHAR
    182  1.21.28.2  pgoyette 		if (attr & WA_LOW && t_enter_low_hl_mode(t) != NULL)
    183       1.15     blymn 			win->wattr |= WA_LOW;
    184  1.21.28.2  pgoyette 		if (attr & WA_TOP && t_enter_top_hl_mode(t) != NULL)
    185       1.15     blymn 			win->wattr |= WA_TOP;
    186  1.21.28.2  pgoyette 		if (attr & WA_LEFT && t_enter_left_hl_mode(t) != NULL)
    187       1.15     blymn 			win->wattr |= WA_LEFT;
    188  1.21.28.2  pgoyette 		if (attr & WA_RIGHT && t_enter_right_hl_mode(t) != NULL)
    189       1.15     blymn 			win->wattr |= WA_RIGHT;
    190  1.21.28.2  pgoyette 		if (attr & WA_HORIZONTAL && t_enter_horizontal_hl_mode(t) != NULL)
    191       1.15     blymn 			win->wattr |= WA_HORIZONTAL;
    192  1.21.28.2  pgoyette 		if (attr & WA_VERTICAL && t_enter_vertical_hl_mode(t) != NULL)
    193       1.15     blymn 			win->wattr |= WA_VERTICAL;
    194       1.15     blymn #endif /* HAVE_WCHAR */
    195        1.1       mrg 	}
    196  1.21.28.2  pgoyette 	if (attr & __STANDOUT && t_enter_standout_mode(t) != NULL &&
    197  1.21.28.2  pgoyette 	    t_exit_standout_mode(t) != NULL)
    198        1.2     blymn 		wstandout(win);
    199  1.21.28.2  pgoyette 	if (attr & __UNDERSCORE && t_enter_underline_mode(t) != NULL &&
    200  1.21.28.2  pgoyette 	    t_exit_underline_mode(t) != NULL)
    201        1.1       mrg 		wunderscore(win);
    202       1.12       jdc 	if ((attr_t) attr & __COLOR)
    203       1.12       jdc 		__wcolor_set(win, (attr_t) attr);
    204       1.12       jdc 	return OK;
    205        1.1       mrg }
    206        1.1       mrg 
    207        1.1       mrg /*
    208       1.12       jdc  * wattr_off --
    209       1.16       jdc  *	Test and unset wide attributes on window
    210        1.1       mrg  *
    211        1.1       mrg  *	Note that the 'me' sequence unsets all attributes.  We handle
    212        1.1       mrg  *	which attributes should really be set in refresh.c:makech().
    213        1.1       mrg  */
    214       1.12       jdc /* ARGSUSED */
    215        1.1       mrg int
    216       1.12       jdc wattr_off(WINDOW *win, attr_t attr, void *opt)
    217        1.1       mrg {
    218  1.21.28.2  pgoyette 	const TERMINAL *t = win->screen->term;
    219  1.21.28.2  pgoyette 
    220        1.3       jdc #ifdef DEBUG
    221       1.14       jdc 	__CTRACE(__CTRACE_ATTR, "wattr_off: win %p, attr %08x\n", win, attr);
    222        1.3       jdc #endif
    223        1.3       jdc 	/* If can do exit modes, unset the relevent attribute bits. */
    224  1.21.28.2  pgoyette 	if (t_exit_attribute_mode(t) != NULL) {
    225       1.12       jdc 		if (attr & __BLINK)
    226        1.2     blymn 			win->wattr &= ~__BLINK;
    227       1.12       jdc 		if (attr & __BOLD)
    228        1.2     blymn 			win->wattr &= ~__BOLD;
    229       1.12       jdc 		if (attr & __DIM)
    230        1.2     blymn 			win->wattr &= ~__DIM;
    231       1.12       jdc 		if (attr & __BLANK)
    232        1.2     blymn 			win->wattr &= ~__BLANK;
    233       1.12       jdc 		if (attr & __PROTECT)
    234        1.2     blymn 			win->wattr &= ~__PROTECT;
    235       1.12       jdc 		if (attr & __REVERSE)
    236        1.2     blymn 			win->wattr &= ~__REVERSE;
    237       1.15     blymn #ifdef HAVE_WCHAR
    238       1.15     blymn 		if (attr & WA_LOW)
    239       1.15     blymn 			win->wattr &= ~WA_LOW;
    240       1.15     blymn 		if (attr & WA_TOP)
    241       1.15     blymn 			win->wattr &= ~WA_TOP;
    242       1.15     blymn 		if (attr & WA_LEFT)
    243       1.15     blymn 			win->wattr &= ~WA_LEFT;
    244       1.15     blymn 		if (attr & WA_RIGHT)
    245       1.15     blymn 			win->wattr &= ~WA_RIGHT;
    246       1.15     blymn 		if (attr & WA_HORIZONTAL)
    247       1.15     blymn 			win->wattr &= ~WA_HORIZONTAL;
    248       1.20       roy 	if (attr & WA_VERTICAL)
    249       1.15     blymn 			win->wattr &= ~WA_VERTICAL;
    250       1.15     blymn #endif /* HAVE_WCHAR */
    251        1.1       mrg 	}
    252       1.12       jdc 	if (attr & __STANDOUT)
    253        1.2     blymn 		wstandend(win);
    254       1.12       jdc 	if (attr & __UNDERSCORE)
    255        1.1       mrg 		wunderend(win);
    256        1.3       jdc 	if ((attr_t) attr & __COLOR) {
    257       1.20       roy 		if (max_colors != 0)
    258        1.3       jdc 			win->wattr &= ~__COLOR;
    259        1.3       jdc 	}
    260       1.12       jdc 	return OK;
    261       1.12       jdc }
    262       1.12       jdc 
    263       1.12       jdc /*
    264       1.12       jdc  * wattr_set --
    265       1.16       jdc  *	Set wide attributes and color pair on window
    266       1.12       jdc  */
    267       1.12       jdc int
    268       1.12       jdc wattr_set(WINDOW *win, attr_t attr, short pair, void *opt)
    269       1.12       jdc {
    270       1.12       jdc #ifdef DEBUG
    271       1.14       jdc 	__CTRACE(__CTRACE_ATTR, "wattr_set: win %p, attr %08x, pair %d\n",
    272       1.14       jdc 	    win, attr, pair);
    273       1.12       jdc #endif
    274  1.21.28.1  pgoyette 	wattr_off(win, __ATTRIBUTES, opt);
    275       1.12       jdc 	/*
    276       1.15     blymn 	 * This overwrites any colour setting from the attributes
    277       1.12       jdc 	 * and is compatible with ncurses.
    278       1.12       jdc 	 */
    279  1.21.28.1  pgoyette 	attr = (attr & ~__COLOR) | COLOR_PAIR(pair);
    280  1.21.28.1  pgoyette 	wattr_on(win, attr, opt);
    281       1.12       jdc 	return OK;
    282       1.12       jdc }
    283       1.12       jdc 
    284       1.12       jdc /*
    285       1.12       jdc  * wattron --
    286       1.12       jdc  *	Test and set attributes.
    287       1.12       jdc  */
    288       1.12       jdc int
    289       1.12       jdc wattron(WINDOW *win, int attr)
    290       1.12       jdc {
    291       1.12       jdc #ifdef DEBUG
    292       1.14       jdc 	__CTRACE(__CTRACE_ATTR, "wattron: win %p, attr %08x\n", win, attr);
    293       1.12       jdc #endif
    294       1.12       jdc 	return wattr_on(win, (attr_t) attr, NULL);
    295       1.12       jdc }
    296       1.12       jdc 
    297       1.12       jdc /*
    298       1.12       jdc  * wattroff --
    299       1.12       jdc  *	Test and unset attributes.
    300       1.12       jdc  */
    301       1.12       jdc int
    302       1.12       jdc wattroff(WINDOW *win, int attr)
    303       1.12       jdc {
    304       1.12       jdc #ifdef DEBUG
    305       1.14       jdc 	__CTRACE(__CTRACE_ATTR, "wattroff: win %p, attr %08x\n", win, attr);
    306       1.12       jdc #endif
    307       1.12       jdc 	return wattr_off(win, (attr_t) attr, NULL);
    308        1.1       mrg }
    309        1.1       mrg 
    310        1.1       mrg /*
    311        1.8       jdc  * wattrset --
    312        1.1       mrg  *	Set specific attribute modes.
    313        1.1       mrg  *	Unset others.
    314        1.1       mrg  */
    315        1.1       mrg int
    316        1.4     blymn wattrset(WINDOW *win, int attr)
    317        1.1       mrg {
    318        1.5       jdc #ifdef DEBUG
    319       1.14       jdc 	__CTRACE(__CTRACE_ATTR, "wattrset: win %p, attr %08x\n", win, attr);
    320        1.5       jdc #endif
    321       1.15     blymn 	wattr_off(win, __ATTRIBUTES, NULL);
    322       1.12       jdc 	wattr_on(win, (attr_t) attr, NULL);
    323       1.12       jdc 	return OK;
    324       1.12       jdc }
    325       1.12       jdc 
    326       1.12       jdc /*
    327       1.12       jdc  * wcolor_set --
    328       1.12       jdc  *	Set color pair on window
    329       1.12       jdc  */
    330       1.12       jdc /* ARGSUSED */
    331       1.12       jdc int
    332       1.12       jdc wcolor_set(WINDOW *win, short pair, void *opt)
    333       1.12       jdc {
    334       1.12       jdc #ifdef DEBUG
    335       1.14       jdc 	__CTRACE(__CTRACE_COLOR, "wolor_set: win %p, pair %d\n", win, pair);
    336       1.12       jdc #endif
    337       1.12       jdc 	__wcolor_set(win, (attr_t) COLOR_PAIR(pair));
    338       1.12       jdc 	return OK;
    339        1.8       jdc }
    340        1.8       jdc 
    341        1.8       jdc /*
    342        1.8       jdc  * getattrs --
    343       1.16       jdc  *	Get window attributes.
    344        1.8       jdc  */
    345        1.8       jdc chtype
    346        1.8       jdc getattrs(WINDOW *win)
    347        1.8       jdc {
    348        1.8       jdc #ifdef DEBUG
    349       1.14       jdc 	__CTRACE(__CTRACE_ATTR, "getattrs: win %p\n", win);
    350        1.8       jdc #endif
    351        1.8       jdc 	return((chtype) win->wattr);
    352       1.12       jdc }
    353       1.12       jdc 
    354       1.12       jdc /*
    355       1.16       jdc  * termattrs --
    356       1.16       jdc  *	Get terminal attributes
    357       1.16       jdc  */
    358       1.16       jdc chtype
    359       1.16       jdc termattrs(void)
    360       1.16       jdc {
    361       1.19      yamt 	chtype ch = 0;
    362       1.19      yamt 
    363       1.16       jdc #ifdef DEBUG
    364       1.16       jdc 	__CTRACE(__CTRACE_ATTR, "termattrs\n");
    365       1.16       jdc #endif
    366       1.20       roy 	if (exit_attribute_mode != NULL) {
    367       1.21     blymn #ifdef DEBUG
    368       1.21     blymn 	__CTRACE(__CTRACE_ATTR, "termattrs: have exit attribute mode\n");
    369       1.21     blymn #endif
    370       1.20       roy 		if (enter_blink_mode != NULL)
    371       1.16       jdc 			ch |= __BLINK;
    372       1.20       roy 		if (enter_bold_mode != NULL)
    373       1.16       jdc 			ch |= __BOLD;
    374       1.20       roy 		if (enter_dim_mode != NULL)
    375       1.16       jdc 			ch |= __DIM;
    376       1.20       roy 		if (enter_secure_mode != NULL)
    377       1.16       jdc 			ch |= __BLANK;
    378       1.20       roy 		if (enter_protected_mode != NULL)
    379       1.16       jdc 			ch |= __PROTECT;
    380       1.20       roy 		if (enter_reverse_mode != NULL)
    381       1.16       jdc 			ch |= __REVERSE;
    382       1.16       jdc 	}
    383       1.20       roy 	if (enter_standout_mode != NULL && exit_standout_mode != NULL)
    384       1.16       jdc 		ch |= __STANDOUT;
    385       1.20       roy 	if (enter_underline_mode != NULL && exit_underline_mode != NULL)
    386       1.16       jdc 		ch |= __UNDERSCORE;
    387       1.20       roy 	if (enter_alt_charset_mode != NULL && exit_alt_charset_mode != NULL)
    388       1.16       jdc 		ch |= __ALTCHARSET;
    389       1.16       jdc 
    390       1.16       jdc 	return ch;
    391       1.16       jdc }
    392       1.16       jdc 
    393       1.16       jdc /*
    394       1.16       jdc  * term_attrs --
    395       1.16       jdc  *	Get terminal wide attributes
    396       1.16       jdc  */
    397       1.16       jdc attr_t
    398       1.16       jdc term_attrs(void)
    399       1.16       jdc {
    400       1.19      yamt 	attr_t attr = 0;
    401       1.19      yamt 
    402       1.16       jdc #ifdef DEBUG
    403       1.16       jdc 	__CTRACE(__CTRACE_ATTR, "term_attrs\n");
    404       1.16       jdc #endif
    405       1.20       roy 	if (exit_attribute_mode != NULL) {
    406       1.20       roy 		if (enter_blink_mode != NULL)
    407       1.17       jdc 			attr |= __BLINK;
    408       1.20       roy 		if (enter_bold_mode != NULL)
    409       1.17       jdc 			attr |= __BOLD;
    410       1.20       roy 		if (enter_dim_mode != NULL)
    411       1.17       jdc 			attr |= __DIM;
    412       1.20       roy 		if (enter_secure_mode != NULL)
    413       1.17       jdc 			attr |= __BLANK;
    414       1.20       roy 		if (enter_protected_mode != NULL)
    415       1.17       jdc 			attr |= __PROTECT;
    416       1.20       roy 		if (enter_reverse_mode != NULL)
    417       1.17       jdc 			attr |= __REVERSE;
    418       1.16       jdc #ifdef HAVE_WCHAR
    419       1.20       roy 		if (enter_low_hl_mode != NULL)
    420       1.16       jdc 			attr |= WA_LOW;
    421       1.20       roy 		if (enter_top_hl_mode != NULL)
    422       1.16       jdc 			attr |= WA_TOP;
    423       1.20       roy 		if (enter_left_hl_mode != NULL)
    424       1.16       jdc 			attr |= WA_LEFT;
    425       1.20       roy 		if (enter_right_hl_mode != NULL)
    426       1.16       jdc 			attr |= WA_RIGHT;
    427       1.20       roy 		if (enter_horizontal_hl_mode != NULL)
    428       1.16       jdc 			attr |= WA_HORIZONTAL;
    429       1.20       roy 		if (enter_vertical_hl_mode != NULL)
    430       1.16       jdc 			attr |= WA_VERTICAL;
    431       1.16       jdc #endif /* HAVE_WCHAR */
    432       1.16       jdc 	}
    433       1.20       roy 	if (enter_standout_mode != NULL && exit_standout_mode != NULL)
    434       1.17       jdc 		attr |= __STANDOUT;
    435       1.20       roy 	if (enter_underline_mode != NULL && exit_underline_mode != NULL)
    436       1.17       jdc 		attr |= __UNDERSCORE;
    437       1.20       roy 	if (enter_alt_charset_mode != NULL && exit_alt_charset_mode != NULL)
    438       1.17       jdc 		attr |= __ALTCHARSET;
    439       1.16       jdc 
    440       1.16       jdc 	return attr;
    441       1.16       jdc }
    442       1.16       jdc 
    443       1.16       jdc /*
    444       1.12       jdc  * __wcolor_set --
    445       1.12       jdc  * Set color attribute on window
    446       1.12       jdc  */
    447       1.12       jdc void
    448       1.12       jdc __wcolor_set(WINDOW *win, attr_t attr)
    449       1.12       jdc {
    450  1.21.28.2  pgoyette 	const TERMINAL *t = win->screen->term;
    451  1.21.28.2  pgoyette 
    452       1.12       jdc 	/* If another color pair is set, turn that off first. */
    453       1.12       jdc 	win->wattr &= ~__COLOR;
    454       1.12       jdc 	/* If can do color video, set the color pair bits. */
    455  1.21.28.2  pgoyette 	if (t_max_colors(t) != 0 && attr & __COLOR)
    456       1.12       jdc 		win->wattr |= attr & __COLOR;
    457        1.1       mrg }
    458