Back to index

tetex-bin  3.0
lib_wacs.c
Go to the documentation of this file.
00001 /****************************************************************************
00002  * Copyright (c) 2002 Free Software Foundation, Inc.                        *
00003  *                                                                          *
00004  * Permission is hereby granted, free of charge, to any person obtaining a  *
00005  * copy of this software and associated documentation files (the            *
00006  * "Software"), to deal in the Software without restriction, including      *
00007  * without limitation the rights to use, copy, modify, merge, publish,      *
00008  * distribute, distribute with modifications, sublicense, and/or sell       *
00009  * copies of the Software, and to permit persons to whom the Software is    *
00010  * furnished to do so, subject to the following conditions:                 *
00011  *                                                                          *
00012  * The above copyright notice and this permission notice shall be included  *
00013  * in all copies or substantial portions of the Software.                   *
00014  *                                                                          *
00015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
00016  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
00017  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
00018  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
00019  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
00020  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
00021  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
00022  *                                                                          *
00023  * Except as contained in this notice, the name(s) of the above copyright   *
00024  * holders shall not be used in advertising or otherwise to promote the     *
00025  * sale, use or other dealings in this Software without prior written       *
00026  * authorization.                                                           *
00027  ****************************************************************************/
00028 
00029 /****************************************************************************
00030  *  Author: Thomas Dickey 2002                                              *
00031  ****************************************************************************/
00032 
00033 #include <curses.priv.h>
00034 #include <term.h>
00035 
00036 MODULE_ID("$Id: lib_wacs.c,v 1.6 2002/12/21 12:30:19 tom Exp $")
00037 
00038 NCURSES_EXPORT_VAR(cchar_t) * _nc_wacs = 0;
00039 
00040 NCURSES_EXPORT(void)
00041 _nc_init_wacs(void)
00042 {
00043     /* *INDENT-OFF* */
00044     static const struct {
00045        int    map;
00046        int    value[2];
00047     } table[] = {
00048        /* VT100 symbols */
00049        { 'l', { '+', 0x250c }},    /* upper left corner */
00050        { 'm', { '+', 0x2514 }},    /* lower left corner */
00051        { 'k', { '+', 0x2510 }},    /* upper right corner */
00052        { 'j', { '+', 0x2518 }},    /* lower right corner */
00053        { 't', { '+', 0x251c }},    /* tee pointing left */
00054        { 'u', { '+', 0x2524 }},    /* tee pointing right */
00055        { 'v', { '+', 0x2534 }},    /* tee pointing up */
00056        { 'w', { '+', 0x252c }},    /* tee pointing down */
00057        { 'q', { '-', 0x2500 }},    /* horizontal line */
00058        { 'x', { '|', 0x2502 }},    /* vertical line */
00059        { 'n', { '+', 0x253c }},    /* large plus or crossover */
00060        { 'o', { '~', 0x23ba }},    /* scan line 1 */
00061        { 's', { '_', 0x23bd }},    /* scan line 9 */
00062        { '`', { '+', 0x25c6 }},    /* diamond */
00063        { 'a', { ':', 0x2592 }},    /* checker board (stipple) */
00064        { 'f', { '\'',       0x00b0 }},    /* degree symbol */
00065        { 'g', { '#', 0x00b1 }},    /* plus/minus */
00066        { '~', { 'o', 0x00b7 }},    /* bullet */
00067        /* Teletype 5410v1 symbols */
00068        { ',', { '<', 0x2190 }},    /* arrow pointing left */
00069        { '+', { '>', 0x2192 }},    /* arrow pointing right */
00070        { '.', { 'v', 0x2193 }},    /* arrow pointing down */
00071        { '-', { '^', 0x2191 }},    /* arrow pointing up */
00072        { 'h', { '#', 0x2592 }},    /* board of squares */
00073        { 'i', { '#', 0x2603 }},    /* lantern symbol */
00074        { '0', { '#', 0x25ae }},    /* solid square block */
00075        /* these defaults were invented for ncurses */
00076        { 'p', { '-', 0x23bb }},    /* scan line 3 */
00077        { 'r', { '-', 0x23bc }},    /* scan line 7 */
00078        { 'y', { '<', 0x2264 }},    /* less-than-or-equal-to */
00079        { 'z', { '>', 0x2265 }},    /* greater-than-or-equal-to */
00080        { '{', { '*', 0x03c0 }},    /* greek pi */
00081        { '|', { '!', 0x2260 }},    /* not-equal */
00082        { '}', { 'f', 0x00a3 }},    /* pound-sterling symbol */
00083     };
00084     /* *INDENT-ON* */
00085 
00086     unsigned n, m;
00087     int active = _nc_unicode_locale();
00088 
00089     /*
00090      * If we're running in a UTF-8 locale, will use the Unicode equivalents
00091      * rather than the terminfo information.  Actually the terminfo should
00092      * be the rule, but there are people who are offended by the notion that
00093      * a Unicode-capable terminal would have something resembling a mode.
00094      * So the smacs/rmacs may be disabled -- sometime.
00095      */
00096     T(("initializing WIDE-ACS map (Unicode is%s active)",
00097        active ? "" : " not"));
00098 
00099     _nc_wacs = typeCalloc(cchar_t, ACS_LEN);
00100     for (n = 0; n < SIZEOF(table); ++n) {
00101        m = table[n].map;
00102        if (active) {
00103            SetChar(_nc_wacs[m], table[n].value[active], A_NORMAL);
00104        } else if (acs_map[m] & A_ALTCHARSET) {
00105            SetChar(_nc_wacs[m], m, A_ALTCHARSET);
00106        } else {
00107            SetChar(_nc_wacs[m], table[n].value[0], A_NORMAL);
00108        }
00109        T(("#%d, SetChar(%c, %#04x) = %s",
00110           n, m,
00111           table[n].value[active],
00112           _tracecchar_t(&_nc_wacs[m])));
00113     }
00114 }