Start converting to GPL v3+ (ref: ticket #23900)
[screen-lua.git] / src / ansi.h
blob7d0240737cced2efe1326be635471f59ade449db
1 /* Copyright (c) 1993-2002
2 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
3 * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
4 * Copyright (c) 1987 Oliver Laumann
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3, or (at your option)
9 * any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program (see the file COPYING); if not, see
18 * http://www.gnu.org/licenses/, or contact Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
21 ****************************************************************
22 * $Id$ FAU
25 #define NATTR 6
27 #define ATTR_DI 0 /* Dim mode */
28 #define ATTR_US 1 /* Underscore mode */
29 #define ATTR_BD 2 /* Bold mode */
30 #define ATTR_RV 3 /* Reverse mode */
31 #define ATTR_SO 4 /* Standout mode */
32 #define ATTR_BL 5 /* Blinking */
34 #define A_DI (1<<ATTR_DI)
35 #define A_US (1<<ATTR_US)
36 #define A_BD (1<<ATTR_BD)
37 #define A_RV (1<<ATTR_RV)
38 #define A_SO (1<<ATTR_SO)
39 #define A_BL (1<<ATTR_BL)
40 #define A_MAX (1<<(NATTR-1))
42 #define ATYP_M (1<<0)
43 #define ATYP_S (1<<1)
44 #define ATYP_U (1<<2)
46 #ifdef COLORS16
47 /* pseudo attributes */
48 # define ATTR_BFG 6 /* bright foreground */
49 # define ATTR_BBG 7 /* bright background */
50 # define A_BFG (1<<ATTR_BFG)
51 # define A_BBG (1<<ATTR_BBG)
52 #endif
55 * Parser state
57 /* keep state_t and state_t_string in sync! */
58 enum state_t
60 LIT, /* Literal input */
61 ESC, /* Start of escape sequence */
62 ASTR, /* Start of control string */
63 STRESC, /* ESC seen in control string */
64 CSI, /* Reading arguments in "CSI Pn ;...*/
65 PRIN, /* Printer mode */
66 PRINESC, /* ESC seen in printer mode */
67 PRINCSI, /* CSI seen in printer mode */
68 PRIN4 /* CSI 4 seen in printer mode */
71 /* keep string_t and string_t_string in sync! */
72 enum string_t
74 NONE,
75 DCS, /* Device control string */
76 OSC, /* Operating system command */
77 APC, /* Application program command */
78 /* - used for status change */
79 PM, /* Privacy message */
80 AKA, /* title for current screen */
81 GM, /* Global message to every display */
82 STATUS /* User hardstatus line */
86 * Types of movement used by GotoPos()
88 enum move_t {
89 M_NONE,
90 M_UP,
91 M_CUP,
92 M_DO,
93 M_CDO,
94 M_LE,
95 M_CLE,
96 M_RI,
97 M_CRI,
98 M_RW,
99 M_CR /* CR and rewrite */
102 #define EXPENSIVE 1000
104 #define G0 0
105 #define G1 1
106 #define G2 2
107 #define G3 3
109 #define ASCII 0
111 #ifdef TOPSTAT
112 #define STATLINE (0)
113 #else
114 #define STATLINE (D_height-1)
115 #endif
117 #ifdef ENCODINGS
119 #define KANJI ('B' & 037)
120 #define KANJI0212 ('D' & 037)
121 #define KANA 'I'
123 #define EUC_JP 1
124 #define SJIS 2
125 #define EUC_KR 3
126 #define EUC_CN 4
127 #define BIG5 5
128 #define KOI8R 6
129 #define CP1251 7
130 #define GBK 20
132 #define EUC EUC_JP
134 #endif
136 #ifdef UTF8
137 #undef UTF8
138 #define UTF8 8
139 #endif
141 #ifdef UTF8
142 # define UCS_REPL 0xfffd /* character for illegal codes */
143 # define UCS_REPL_DW 0xff1f /* character for illegal codes */
144 # define UCS_HIDDEN 0xffff
145 #endif
147 #ifdef DW_CHARS
148 # define is_dw_font(f) ((f) && ((f) & 0x60) == 0)
150 # ifdef UTF8
151 # define dw_left(ml, x, enc) ((enc == UTF8) ? \
152 (unsigned char)(ml)->font[(x) + 1] == 0xff && (unsigned char)(ml)->image[(x) + 1] == 0xff : \
153 ((unsigned char)(ml)->font[x] & 0x1f) != 0 && ((unsigned char)(ml)->font[x] & 0xe0) == 0 \
155 # define dw_right(ml, x, enc) ((enc == UTF8) ? \
156 (unsigned char)(ml)->font[x] == 0xff && (unsigned char)(ml)->image[x] == 0xff : \
157 ((unsigned char)(ml)->font[x] & 0xe0) == 0x80 \
159 # else
160 # define dw_left(ml, x, enc) ( \
161 ((unsigned char)(ml)->font[x] & 0x1f) != 0 && ((unsigned char)(ml)->font[x] & 0xe0) == 0 \
163 # define dw_right(ml, x, enc) ( \
164 ((unsigned char)(ml)->font[x] & 0xe0) == 0x80 \
166 # endif /* UTF8 */
167 #else
168 # define dw_left(ml, x, enc) 0
169 # define dw_right(ml, x, enc) 0
170 #endif