teken_scs.h revision 197520
1238909Smm/*-
2238909Smm * Copyright (c) 2009 Ed Schouten <ed@FreeBSD.org>
3238909Smm * All rights reserved.
4238909Smm *
5238909Smm * Redistribution and use in source and binary forms, with or without
6238909Smm * modification, are permitted provided that the following conditions
7238909Smm * are met:
8238909Smm * 1. Redistributions of source code must retain the above copyright
9238909Smm *    notice, this list of conditions and the following disclaimer.
10238909Smm * 2. Redistributions in binary form must reproduce the above copyright
11238909Smm *    notice, this list of conditions and the following disclaimer in the
12238909Smm *    documentation and/or other materials provided with the distribution.
13238909Smm *
14238909Smm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15238909Smm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16238909Smm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17238909Smm * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18238909Smm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19238909Smm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20238909Smm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21238909Smm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22238909Smm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23238909Smm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24238909Smm * SUCH DAMAGE.
25238909Smm *
26238909Smm * $FreeBSD: head/sys/teken/teken_scs.h 197520 2009-09-26 15:03:42Z ed $
27238909Smm */
28238909Smm
29238909Smmstatic inline teken_char_t
30238909Smmteken_scs_process(teken_t *t, teken_char_t c)
31238909Smm{
32238909Smm
33238909Smm	return (t->t_scs[t->t_curscs](t, c));
34238909Smm}
35238909Smm
36238909Smm/* Unicode points for VT100 box drawing. */
37238909Smmstatic const uint16_t teken_boxdrawing_unicode[31] = {
38238909Smm    0x25c6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 0x00b1,
39238909Smm    0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 0x23ba,
40238909Smm    0x23bb, 0x2500, 0x23bc, 0x23bd, 0x251c, 0x2524, 0x2534, 0x252c,
41238909Smm    0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3, 0x00b7
42238909Smm};
43238909Smm
44238909Smm/* CP437 points for VT100 box drawing. */
45238909Smmstatic const uint8_t teken_boxdrawing_8bit[31] = {
46299529Smm    0x04, 0xb1, 0x48, 0x46, 0x43, 0x4c, 0xf8, 0xf1,
47238909Smm    0x4e, 0x56, 0xd9, 0xbf, 0xda, 0xc0, 0xc5, 0xc4,
48238909Smm    0xc4, 0xc4, 0xc4, 0xc4, 0xc3, 0xb4, 0xc1, 0xc2,
49238909Smm    0xb3, 0xf3, 0xf2, 0xe3, 0xd8, 0x9c, 0xfa,
50238909Smm};
51238909Smm
52238909Smmstatic teken_char_t
53238909Smmteken_scs_special_graphics(teken_t *t, teken_char_t c)
54238909Smm{
55238909Smm
56238909Smm	/* Box drawing. */
57238909Smm	if (c >= '`' && c <= '~')
58238909Smm		return (t->t_stateflags & TS_8BIT ?
59238909Smm		    teken_boxdrawing_8bit[c - '`'] :
60238909Smm		    teken_boxdrawing_unicode[c - '`']);
61238909Smm	return (c);
62238909Smm}
63238909Smm
64238909Smmstatic teken_char_t
65238909Smmteken_scs_uk_national(teken_t *t, teken_char_t c)
66238909Smm{
67238909Smm
68238909Smm	/* Pound sign. */
69238909Smm	if (c == '#')
70238909Smm		return (t->t_stateflags & TS_8BIT ? 0x9c : 0xa3);
71238909Smm	return (c);
72238909Smm}
73238909Smm
74238909Smmstatic teken_char_t
75238909Smmteken_scs_us_ascii(teken_t *t __unused, teken_char_t c)
76238909Smm{
77238909Smm
78238909Smm	/* No processing. */
79238909Smm	return (c);
80238909Smm}
81238909Smm