1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright (c) 1995, by Sun Microsystems, Inc. 24 * All rights reserved. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 /* 30 * termattr.c 31 * 32 * XCurses Library 33 * 34 * Copyright 1990, 1995 by Mortice Kern Systems Inc. All rights reserved. 35 * 36 */ 37 38 #if M_RCSID 39 #ifndef lint 40 static char rcsID[] = "$Header: /rd/src/libc/xcurses/rcs/termattr.c 1.1 1995/07/10 16:09:34 ant Exp $"; 41 #endif 42 #endif 43 44 #include <private.h> 45 #include <ctype.h> 46 47 chtype 48 termattrs() 49 { 50 chtype ch; 51 cchar_t cc; 52 53 #ifdef M_CURSES_TRACE 54 __m_trace("termattrs(void)"); 55 #endif 56 57 cc = __m_screen->_newscr->_bg; 58 cc._at = term_attrs(); 59 ch = __m_cc_chtype(&cc) & A_ATTRIBUTES & ~A_COLOR; 60 61 62 return __m_return_chtype("termattrs", ch); 63 } 64 65 attr_t 66 term_attrs() 67 { 68 char *p; 69 attr_t at; 70 71 #ifdef M_CURSES_TRACE 72 __m_trace("term_attrs(void)"); 73 #endif 74 75 if (set_attributes) { 76 for (p = set_attributes; *p != '\0'; ++p) { 77 if (p[0] != '%' || p[1] != 'p' || !isdigit(p[2])) 78 continue; 79 80 p += 2; 81 switch (*p) { 82 case 1: 83 at |= WA_STANDOUT; 84 break; 85 case 2: 86 at |= WA_UNDERLINE; 87 break; 88 case 3: 89 at |= WA_REVERSE; 90 break; 91 case 4: 92 at |= WA_BLINK; 93 break; 94 case 5: 95 at |= WA_DIM; 96 break; 97 case 6: 98 at |= WA_BOLD; 99 break; 100 case 7: 101 at |= WA_INVIS; 102 break; 103 case 8: 104 at |= WA_PROTECT; 105 break; 106 case 9: 107 at |= WA_ALTCHARSET; 108 break; 109 } 110 } 111 } 112 113 if (set_a_attributes) { 114 for (p = set_a_attributes; *p != '\0'; ++p) { 115 if (p[0] != '%' || p[1] != 'p' || !isdigit(p[2])) 116 continue; 117 118 p += 2; 119 switch (*p) { 120 case 1: 121 at |= WA_HORIZONTAL; 122 break; 123 case 2: 124 at |= WA_LEFT; 125 break; 126 case 3: 127 at |= WA_LOW; 128 break; 129 case 4: 130 at |= WA_RIGHT; 131 break; 132 case 5: 133 at |= WA_TOP; 134 break; 135 case 6: 136 at |= WA_VERTICAL; 137 break; 138 } 139 } 140 } 141 142 if (enter_alt_charset_mode != (char *) 0) 143 at |= WA_ALTCHARSET; 144 145 if (enter_blink_mode != (char *) 0) 146 at |= WA_BLINK; 147 148 if (enter_bold_mode != (char *) 0) 149 at |= WA_BOLD; 150 151 if (enter_secure_mode != (char *) 0) 152 at |= WA_INVIS; 153 154 if (enter_dim_mode != (char *) 0) 155 at |= WA_DIM; 156 157 if (enter_protected_mode != (char *) 0) 158 at |= WA_PROTECT; 159 160 if (enter_reverse_mode != (char *) 0) 161 at |= WA_REVERSE; 162 163 if (enter_standout_mode != (char *) 0) 164 at |= WA_STANDOUT; 165 166 if (enter_underline_mode != (char *) 0) 167 at |= WA_UNDERLINE; 168 169 if (enter_horizontal_hl_mode != (char *) 0) 170 at |= WA_HORIZONTAL; 171 172 if (enter_left_hl_mode != (char *) 0) 173 at |= WA_LEFT; 174 175 if (enter_low_hl_mode != (char *) 0) 176 at |= WA_LOW; 177 178 if (enter_right_hl_mode != (char *) 0) 179 at |= WA_RIGHT; 180 181 if (enter_top_hl_mode != (char *) 0) 182 at |= WA_TOP; 183 184 if (enter_vertical_hl_mode != (char *) 0) 185 at |= WA_VERTICAL; 186 187 return __m_return_chtype("term_attrs", (chtype) at); 188 } 189