197049Speter/**************************************************************************** 2166124Srafan * Copyright (c) 2002,2006 Free Software Foundation, Inc. * 397049Speter * * 497049Speter * Permission is hereby granted, free of charge, to any person obtaining a * 597049Speter * copy of this software and associated documentation files (the * 697049Speter * "Software"), to deal in the Software without restriction, including * 797049Speter * without limitation the rights to use, copy, modify, merge, publish, * 897049Speter * distribute, distribute with modifications, sublicense, and/or sell * 997049Speter * copies of the Software, and to permit persons to whom the Software is * 1097049Speter * furnished to do so, subject to the following conditions: * 1197049Speter * * 1297049Speter * The above copyright notice and this permission notice shall be included * 1397049Speter * in all copies or substantial portions of the Software. * 1497049Speter * * 1597049Speter * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 1697049Speter * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 1797049Speter * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 1897049Speter * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 1997049Speter * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 2097049Speter * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 2197049Speter * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 2297049Speter * * 2397049Speter * Except as contained in this notice, the name(s) of the above copyright * 2497049Speter * holders shall not be used in advertising or otherwise to promote the * 2597049Speter * sale, use or other dealings in this Software without prior written * 2697049Speter * authorization. * 2797049Speter ****************************************************************************/ 2897049Speter 2997049Speter/**************************************************************************** 3097049Speter * Author: Thomas Dickey 2002 * 3197049Speter ****************************************************************************/ 3297049Speter 3397049Speter#include <curses.priv.h> 3497049Speter#include <term.h> 3597049Speter 36166124SrafanMODULE_ID("$Id: lib_wacs.c,v 1.7 2006/12/17 15:16:17 tom Exp $") 3797049Speter 3897049SpeterNCURSES_EXPORT_VAR(cchar_t) * _nc_wacs = 0; 3997049Speter 4097049SpeterNCURSES_EXPORT(void) 4197049Speter_nc_init_wacs(void) 4297049Speter{ 4397049Speter /* *INDENT-OFF* */ 4497049Speter static const struct { 4597049Speter int map; 4697049Speter int value[2]; 4797049Speter } table[] = { 4897049Speter /* VT100 symbols */ 4997049Speter { 'l', { '+', 0x250c }}, /* upper left corner */ 5097049Speter { 'm', { '+', 0x2514 }}, /* lower left corner */ 5197049Speter { 'k', { '+', 0x2510 }}, /* upper right corner */ 5297049Speter { 'j', { '+', 0x2518 }}, /* lower right corner */ 5397049Speter { 't', { '+', 0x251c }}, /* tee pointing left */ 5497049Speter { 'u', { '+', 0x2524 }}, /* tee pointing right */ 5597049Speter { 'v', { '+', 0x2534 }}, /* tee pointing up */ 5697049Speter { 'w', { '+', 0x252c }}, /* tee pointing down */ 5797049Speter { 'q', { '-', 0x2500 }}, /* horizontal line */ 5897049Speter { 'x', { '|', 0x2502 }}, /* vertical line */ 5997049Speter { 'n', { '+', 0x253c }}, /* large plus or crossover */ 6097049Speter { 'o', { '~', 0x23ba }}, /* scan line 1 */ 6197049Speter { 's', { '_', 0x23bd }}, /* scan line 9 */ 62166124Srafan { '`', { '+', 0x25c6 }}, /* diamond */ 6397049Speter { 'a', { ':', 0x2592 }}, /* checker board (stipple) */ 6497049Speter { 'f', { '\'', 0x00b0 }}, /* degree symbol */ 6597049Speter { 'g', { '#', 0x00b1 }}, /* plus/minus */ 6697049Speter { '~', { 'o', 0x00b7 }}, /* bullet */ 6797049Speter /* Teletype 5410v1 symbols */ 6897049Speter { ',', { '<', 0x2190 }}, /* arrow pointing left */ 6997049Speter { '+', { '>', 0x2192 }}, /* arrow pointing right */ 7097049Speter { '.', { 'v', 0x2193 }}, /* arrow pointing down */ 7197049Speter { '-', { '^', 0x2191 }}, /* arrow pointing up */ 7297049Speter { 'h', { '#', 0x2592 }}, /* board of squares */ 7397049Speter { 'i', { '#', 0x2603 }}, /* lantern symbol */ 7497049Speter { '0', { '#', 0x25ae }}, /* solid square block */ 7597049Speter /* these defaults were invented for ncurses */ 7697049Speter { 'p', { '-', 0x23bb }}, /* scan line 3 */ 7797049Speter { 'r', { '-', 0x23bc }}, /* scan line 7 */ 7897049Speter { 'y', { '<', 0x2264 }}, /* less-than-or-equal-to */ 7997049Speter { 'z', { '>', 0x2265 }}, /* greater-than-or-equal-to */ 8097049Speter { '{', { '*', 0x03c0 }}, /* greek pi */ 8197049Speter { '|', { '!', 0x2260 }}, /* not-equal */ 8297049Speter { '}', { 'f', 0x00a3 }}, /* pound-sterling symbol */ 8397049Speter }; 8497049Speter /* *INDENT-ON* */ 8597049Speter 8697049Speter unsigned n, m; 8797049Speter int active = _nc_unicode_locale(); 8897049Speter 89166124Srafan /* 90166124Srafan * If we're running in a UTF-8 locale, will use the Unicode equivalents 91166124Srafan * rather than the terminfo information. Actually the terminfo should 92166124Srafan * be the rule, but there are people who are offended by the notion that 93166124Srafan * a Unicode-capable terminal would have something resembling a mode. 94166124Srafan * So the smacs/rmacs may be disabled -- sometime. 95166124Srafan */ 9697049Speter T(("initializing WIDE-ACS map (Unicode is%s active)", 9797049Speter active ? "" : " not")); 9897049Speter 9997049Speter _nc_wacs = typeCalloc(cchar_t, ACS_LEN); 10097049Speter for (n = 0; n < SIZEOF(table); ++n) { 101166124Srafan int wide = wcwidth(table[n].value[active]); 102166124Srafan 10397049Speter m = table[n].map; 104166124Srafan if (active && (wide == 1)) { 105166124Srafan SetChar(_nc_wacs[m], table[n].value[active], A_NORMAL); 106166124Srafan } else if (acs_map[m] & A_ALTCHARSET) { 107166124Srafan SetChar(_nc_wacs[m], m, A_ALTCHARSET); 108166124Srafan } else { 109166124Srafan SetChar(_nc_wacs[m], table[n].value[0], A_NORMAL); 110166124Srafan } 111166124Srafan 11297049Speter T(("#%d, SetChar(%c, %#04x) = %s", 11397049Speter n, m, 11497049Speter table[n].value[active], 11597049Speter _tracecchar_t(&_nc_wacs[m]))); 11697049Speter } 11797049Speter} 118