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
5 *
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 2, or (at your option)
9 * any later version.
10 *
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.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program (see the file COPYING); if not, write to the
18 * Free Software Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
20 *
21 ****************************************************************
22 * $Id: ansi.h,v 1.6 1994/05/31 12:31:28 mlschroe Exp $ FAU
23 */
24
25#define NATTR		6
26
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 */
33
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))
41
42#define ATYP_M		(1<<0)
43#define ATYP_S		(1<<1)
44#define ATYP_U		(1<<2)
45
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
53
54/*
55 *  Parser state
56 */
57/* keep state_t and state_t_string in sync! */
58enum state_t
59{
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 */
69};
70
71/* keep string_t and string_t_string in sync! */
72enum string_t
73{
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 */
83};
84
85/*
86 *  Types of movement used by GotoPos()
87 */
88enum 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 */
100};
101
102#define EXPENSIVE	 1000
103
104#define G0			 0
105#define G1			 1
106#define G2			 2
107#define G3			 3
108
109#define ASCII		 0
110
111#ifdef TOPSTAT
112#define STATLINE	 (0)
113#else
114#define STATLINE	 (D_height-1)
115#endif
116
117#ifdef ENCODINGS
118
119#define KANJI		('B' & 037)
120#define KANJI0212	('D' & 037)
121#define KANA    'I'
122
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
131
132#define EUC	EUC_JP
133
134#endif
135
136#ifdef UTF8
137#undef UTF8
138#define UTF8	8
139#endif
140
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
146
147#ifdef DW_CHARS
148# define is_dw_font(f) ((f) && ((f) & 0x60) == 0)
149
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 \
154	)
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 \
158	)
159# else
160#  define dw_left(ml, x, enc) ( \
161	((unsigned char)(ml)->font[x] & 0x1f) != 0 && ((unsigned char)(ml)->font[x] & 0xe0) == 0 \
162	)
163#  define dw_right(ml, x, enc) ( \
164	((unsigned char)(ml)->font[x] & 0xe0) == 0x80 \
165	)
166# endif /* UTF8 */
167#else
168# define dw_left(ml, x, enc) 0
169# define dw_right(ml, x, enc) 0
170#endif
171