Home | History | Annotate | Line # | Download | only in wscons
wsemul_vt100_chars.c revision 1.7
      1  1.7     lukem /* $NetBSD: wsemul_vt100_chars.c,v 1.7 2001/11/13 06:17:47 lukem Exp $ */
      2  1.1  drochner 
      3  1.1  drochner /*
      4  1.1  drochner  * Copyright (c) 1998
      5  1.1  drochner  *	Matthias Drochner.  All rights reserved.
      6  1.1  drochner  *
      7  1.1  drochner  * Redistribution and use in source and binary forms, with or without
      8  1.1  drochner  * modification, are permitted provided that the following conditions
      9  1.1  drochner  * are met:
     10  1.1  drochner  * 1. Redistributions of source code must retain the above copyright
     11  1.1  drochner  *    notice, this list of conditions and the following disclaimer.
     12  1.1  drochner  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  drochner  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  drochner  *    documentation and/or other materials provided with the distribution.
     15  1.1  drochner  * 3. All advertising materials mentioning features or use of this software
     16  1.1  drochner  *    must display the following acknowledgement:
     17  1.1  drochner  *	This product includes software developed for the NetBSD Project
     18  1.1  drochner  *	by Matthias Drochner.
     19  1.1  drochner  * 4. The name of the author may not be used to endorse or promote products
     20  1.1  drochner  *    derived from this software without specific prior written permission.
     21  1.1  drochner  *
     22  1.1  drochner  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23  1.1  drochner  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24  1.1  drochner  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25  1.1  drochner  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     26  1.1  drochner  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     27  1.1  drochner  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28  1.1  drochner  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29  1.1  drochner  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30  1.1  drochner  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     31  1.1  drochner  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  1.1  drochner  *
     33  1.1  drochner  */
     34  1.7     lukem 
     35  1.7     lukem #include <sys/cdefs.h>
     36  1.7     lukem __KERNEL_RCSID(0, "$NetBSD: wsemul_vt100_chars.c,v 1.7 2001/11/13 06:17:47 lukem Exp $");
     37  1.1  drochner 
     38  1.1  drochner #include <sys/param.h>
     39  1.1  drochner #include <sys/systm.h>
     40  1.1  drochner #include <dev/wscons/wsdisplayvar.h>
     41  1.1  drochner #include <dev/wscons/wsksymvar.h>
     42  1.1  drochner #include <dev/wscons/wsemulvar.h>
     43  1.1  drochner #include <dev/wscons/wsemul_vt100var.h>
     44  1.4  drochner #include <dev/wscons/unicode.h>
     45  1.1  drochner 
     46  1.5  jdolecek static const u_int16_t decspcgr2uni[128] = {
     47  1.1  drochner 	0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
     48  1.1  drochner 	0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
     49  1.1  drochner 	0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
     50  1.1  drochner 	0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
     51  1.1  drochner /* 2 */	0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
     52  1.1  drochner 	0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
     53  1.1  drochner 	0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
     54  1.1  drochner 	0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
     55  1.1  drochner /* 4 */	0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
     56  1.1  drochner 	0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
     57  1.1  drochner 	0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
     58  1.1  drochner 	0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x00a0,
     59  1.1  drochner /* 6 */	0x25c6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 0x00b1,
     60  1.4  drochner 	_e006U, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, _e001U,
     61  1.4  drochner 	_e002U, _e003U, _e004U, _e005U, 0x251c, 0x2524, 0x2534, 0x252c,
     62  1.1  drochner 	0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3, 0x00b7, 0x007f,
     63  1.1  drochner };
     64  1.1  drochner 
     65  1.5  jdolecek static const u_int16_t dectech2uni[128] = {
     66  1.1  drochner 	0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
     67  1.1  drochner 	0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
     68  1.1  drochner 	0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
     69  1.1  drochner 	0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
     70  1.2  drochner /* 2 */	0x0020, 0x221a, 0x250c, 0x2212, 0x2320, 0x2321, 0x2502, 0x2308,
     71  1.4  drochner 	0x230a, 0x2309, 0x230b, _e007U, _e008U, _e009U, _e00aU, _e00bU,
     72  1.4  drochner 	_e00cU, _e00dU, _e00eU, 0x2216, 0x2215, 0x00ac, _e00fU, 0x232a,
     73  1.4  drochner 	_e000U, _e000U, _e000U, _e000U, 0x2264, 0x2260, 0x2265, 0x222b,
     74  1.1  drochner /* 4 */	0x2234, 0x221d, 0x221e, 0x00f7, 0x2206, 0x2207, 0x03a6, 0x0393,
     75  1.1  drochner 	0x223c, 0x2243, 0x0398, 0x00d7, 0x039b, 0x21d4, 0x21d2, 0x2261,
     76  1.4  drochner 	0x03a0, 0x03a8, _e000U, 0x03a3, _e000U, _e000U, 0x221a, 0x03a9,
     77  1.1  drochner 	0x039e, 0x03a5, 0x2282, 0x2283, 0x2229, 0x222a, 0x2227, 0x2228,
     78  1.4  drochner /* 6 */	0x00ac, 0x03b1, 0x03b2, 0x03c7, 0x03b4, 0x03b5, 0x03c6, 0x03b3,
     79  1.4  drochner 	0x03b7, 0x03b9, 0x03b8, 0x03ba, 0x03bb, _e000U, 0x03bd, 0x2202,
     80  1.4  drochner 	0x03c0, 0x03c8, 0x03c1, 0x03c3, 0x03c4, _e000U, 0x0192, 0x03c9,
     81  1.1  drochner 	0x03be, 0x03c5, 0x03b6, 0x2190, 0x2191, 0x2192, 0x2193, 0x007f,
     82  1.1  drochner };
     83  1.1  drochner 
     84  1.1  drochner void
     85  1.6  augustss vt100_initchartables(struct wsemul_vt100_emuldata *edp)
     86  1.1  drochner {
     87  1.1  drochner 	int i;
     88  1.1  drochner 
     89  1.1  drochner 	for (i = 0; i < 128; i++)
     90  1.3  drochner 		(*edp->emulops->mapchar)(edp->emulcookie, 128 + i,
     91  1.3  drochner 					 &edp->isolatin1tab[i]);
     92  1.1  drochner 	for (i = 0; i < 128; i++)
     93  1.3  drochner 		(*edp->emulops->mapchar)(edp->emulcookie, decspcgr2uni[i],
     94  1.3  drochner 					 &edp->decgraphtab[i]);
     95  1.1  drochner 	for (i = 0; i < 128; i++)
     96  1.3  drochner 		(*edp->emulops->mapchar)(edp->emulcookie, dectech2uni[i],
     97  1.3  drochner 					 &edp->dectechtab[i]);
     98  1.1  drochner 	vt100_setnrc(edp, 0);
     99  1.1  drochner }
    100  1.1  drochner 
    101  1.5  jdolecek static const int nrcovlpos[12] = {
    102  1.1  drochner     0x23, 0x40, 0x5b, 0x5c, 0x5d, 0x5e,	/* #@[\]^ */
    103  1.1  drochner     0x5f, 0x60, 0x7b, 0x7c, 0x7d, 0x7e	/* _`{|}~ */
    104  1.1  drochner };
    105  1.5  jdolecek static const struct {
    106  1.1  drochner 	u_int16_t c[12];
    107  1.1  drochner } nrctable[] = {
    108  1.1  drochner 	/* british */
    109  1.1  drochner 	{{0x00a3, 0x0040, 0x005b, 0x005c, 0x005d, 0x005e,
    110  1.1  drochner 	0x005f, 0x0060, 0x007b, 0x007c, 0x007d, 0x007e}},
    111  1.1  drochner 	/* dutch */
    112  1.1  drochner 	{{0x00a3, 0x00be, 0x00dc, 0x00ab, 0x007c, 0x005e,
    113  1.1  drochner 	0x005f, 0x0060, 0x00a8, 0x0192, 0x00bc, 0x00b4}},
    114  1.1  drochner 	/* finnish */
    115  1.1  drochner 	{{0x0023, 0x0040, 0x00c4, 0x00d6, 0x00c5, 0x00dc,
    116  1.1  drochner 	0x005f, 0x00e9, 0x00e4, 0x00f6, 0x00e5, 0x00fc}},
    117  1.1  drochner 	/* french */
    118  1.1  drochner 	{{0x00a3, 0x00e0, 0x00b0, 0x00e7, 0x00a7, 0x005e,
    119  1.1  drochner 	0x005f, 0x0060, 0x00e9, 0x00f9, 0x00e8, 0x00a8}},
    120  1.1  drochner 	/* french canadian */
    121  1.1  drochner 	{{0x0023, 0x00e0, 0x00e2, 0x00e7, 0x00ea, 0x00ee,
    122  1.1  drochner 	0x005f, 0x00f4, 0x00e9, 0x00f9, 0x00e8, 0x00fb}},
    123  1.1  drochner 	/* german */
    124  1.1  drochner 	{{0x0023, 0x00a7, 0x00c4, 0x00d6, 0x00dc, 0x005e,
    125  1.1  drochner 	0x005f, 0x0060, 0x00e4, 0x00f6, 0x00fc, 0x00df}},
    126  1.1  drochner 	/* italian */
    127  1.1  drochner 	{{0x00a3, 0x00a7, 0x00b0, 0x00e7, 0x00e9, 0x005e,
    128  1.1  drochner 	0x005f, 0x00f9, 0x00e0, 0x00f2, 0x00e8, 0x00ec}},
    129  1.1  drochner 	/* norwegian /danish */
    130  1.1  drochner 	{{0x0023, 0x0040, 0x00c6, 0x00d8, 0x00c5, 0x005e,
    131  1.1  drochner 	0x005f, 0x0060, 0x00e6, 0x00f8, 0x00e5, 0x007e}},
    132  1.1  drochner 	/* portugese */
    133  1.1  drochner 	{{0x0023, 0x0040, 0x00c3, 0x00c7, 0x00d5, 0x005e,
    134  1.1  drochner 	0x005f, 0x0060, 0x00e3, 0x00e7, 0x00f5, 0x007e}},
    135  1.1  drochner 	/* spanish */
    136  1.1  drochner 	{{0x00a3, 0x00a7, 0x00a1, 0x00d1, 0x00bf, 0x005e,
    137  1.1  drochner 	0x005f, 0x0060, 0x0060, 0x00b0, 0x00f1, 0x00e7}},
    138  1.1  drochner 	/* swedish */
    139  1.1  drochner 	{{0x0023, 0x00c9, 0x00c4, 0x00d6, 0x00c5, 0x00dc,
    140  1.1  drochner 	0x005f, 0x00e9, 0x00e4, 0x00f6, 0x00e5, 0x00fc}},
    141  1.1  drochner 	/* swiss */
    142  1.1  drochner 	{{0x00f9, 0x00e0, 0x00e9, 0x00e7, 0x00ea, 0x00ee,
    143  1.1  drochner 	0x00e8, 0x00f4, 0x00e4, 0x00f6, 0x00fc, 0x00fb}},
    144  1.1  drochner };
    145  1.1  drochner 
    146  1.1  drochner void
    147  1.6  augustss vt100_setnrc(struct wsemul_vt100_emuldata *edp, int nrc)
    148  1.1  drochner {
    149  1.1  drochner 	int i;
    150  1.1  drochner 
    151  1.1  drochner 	KASSERT(nrc < sizeof(nrctable) / sizeof(nrctable[0]));
    152  1.1  drochner 
    153  1.1  drochner 	for (i = 0; i < 128; i++)
    154  1.3  drochner 		(*edp->emulops->mapchar)(edp->emulcookie, i, &edp->nrctab[i]);
    155  1.1  drochner 	for (i = 0; i < 12; i++)
    156  1.3  drochner 		(*edp->emulops->mapchar)(edp->emulcookie, nrctable[nrc].c[i],
    157  1.3  drochner 					 &edp->nrctab[nrcovlpos[i]]);
    158  1.1  drochner }
    159