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