1 /* $NetBSD: charinfo.h,v 1.1.1.1 2016/01/13 18:41:48 christos Exp $ */ 2 3 // -*- C++ -*- 4 /* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002 5 Free Software Foundation, Inc. 6 Written by James Clark (jjc@jclark.com) 7 8 This file is part of groff. 9 10 groff is free software; you can redistribute it and/or modify it under 11 the terms of the GNU General Public License as published by the Free 12 Software Foundation; either version 2, or (at your option) any later 13 version. 14 15 groff is distributed in the hope that it will be useful, but WITHOUT ANY 16 WARRANTY; without even the implied warranty of MERCHANTABILITY or 17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 18 for more details. 19 20 You should have received a copy of the GNU General Public License along 21 with groff; see the file COPYING. If not, write to the Free Software 22 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */ 23 24 class macro; 25 26 class charinfo { 27 static int next_index; 28 charinfo *translation; 29 int index; 30 int number; 31 macro *mac; 32 unsigned char special_translation; 33 unsigned char hyphenation_code; 34 unsigned char flags; 35 unsigned char ascii_code; 36 unsigned char asciify_code; 37 char not_found; 38 char transparent_translate; // non-zero means translation applies 39 // to transparent throughput 40 char translate_input; // non-zero means that asciify_code is 41 // active for .asciify (set by .trin) 42 char_mode mode; 43 public: 44 enum { 45 ENDS_SENTENCE = 1, 46 BREAK_BEFORE = 2, 47 BREAK_AFTER = 4, 48 OVERLAPS_HORIZONTALLY = 8, 49 OVERLAPS_VERTICALLY = 16, 50 TRANSPARENT = 32, 51 NUMBERED = 64 52 }; 53 enum { 54 TRANSLATE_NONE, 55 TRANSLATE_SPACE, 56 TRANSLATE_DUMMY, 57 TRANSLATE_STRETCHABLE_SPACE, 58 TRANSLATE_HYPHEN_INDICATOR 59 }; 60 symbol nm; 61 charinfo(symbol s); 62 int get_index(); 63 int ends_sentence(); 64 int overlaps_vertically(); 65 int overlaps_horizontally(); 66 int can_break_before(); 67 int can_break_after(); 68 int transparent(); 69 unsigned char get_hyphenation_code(); 70 unsigned char get_ascii_code(); 71 unsigned char get_asciify_code(); 72 void set_hyphenation_code(unsigned char); 73 void set_ascii_code(unsigned char); 74 void set_asciify_code(unsigned char); 75 void set_translation_input(); 76 int get_translation_input(); 77 charinfo *get_translation(int = 0); 78 void set_translation(charinfo *, int, int); 79 void set_flags(unsigned char); 80 void set_special_translation(int, int); 81 int get_special_translation(int = 0); 82 macro *set_macro(macro *); 83 macro *setx_macro(macro *, char_mode); 84 macro *get_macro(); 85 int first_time_not_found(); 86 void set_number(int); 87 int get_number(); 88 int numbered(); 89 int is_normal(); 90 int is_fallback(); 91 int is_special(); 92 symbol *get_symbol(); 93 }; 94 95 charinfo *get_charinfo(symbol); 96 extern charinfo *charset_table[]; 97 charinfo *get_charinfo_by_number(int); 98 99 inline int charinfo::overlaps_horizontally() 100 { 101 return flags & OVERLAPS_HORIZONTALLY; 102 } 103 104 inline int charinfo::overlaps_vertically() 105 { 106 return flags & OVERLAPS_VERTICALLY; 107 } 108 109 inline int charinfo::can_break_before() 110 { 111 return flags & BREAK_BEFORE; 112 } 113 114 inline int charinfo::can_break_after() 115 { 116 return flags & BREAK_AFTER; 117 } 118 119 inline int charinfo::ends_sentence() 120 { 121 return flags & ENDS_SENTENCE; 122 } 123 124 inline int charinfo::transparent() 125 { 126 return flags & TRANSPARENT; 127 } 128 129 inline int charinfo::numbered() 130 { 131 return flags & NUMBERED; 132 } 133 134 inline int charinfo::is_normal() 135 { 136 return mode == CHAR_NORMAL; 137 } 138 139 inline int charinfo::is_fallback() 140 { 141 return mode == CHAR_FALLBACK; 142 } 143 144 inline int charinfo::is_special() 145 { 146 return mode == CHAR_SPECIAL; 147 } 148 149 inline charinfo *charinfo::get_translation(int transparent_throughput) 150 { 151 return (transparent_throughput && !transparent_translate 152 ? 0 153 : translation); 154 } 155 156 inline unsigned char charinfo::get_hyphenation_code() 157 { 158 return hyphenation_code; 159 } 160 161 inline unsigned char charinfo::get_ascii_code() 162 { 163 return ascii_code; 164 } 165 166 inline unsigned char charinfo::get_asciify_code() 167 { 168 return (translate_input ? asciify_code : 0); 169 } 170 171 inline void charinfo::set_flags(unsigned char c) 172 { 173 flags = c; 174 } 175 176 inline int charinfo::get_index() 177 { 178 return index; 179 } 180 181 inline void charinfo::set_translation_input() 182 { 183 translate_input = 1; 184 } 185 186 inline int charinfo::get_translation_input() 187 { 188 return translate_input; 189 } 190 191 inline int charinfo::get_special_translation(int transparent_throughput) 192 { 193 return (transparent_throughput && !transparent_translate 194 ? int(TRANSLATE_NONE) 195 : special_translation); 196 } 197 198 inline macro *charinfo::get_macro() 199 { 200 return mac; 201 } 202 203 inline int charinfo::first_time_not_found() 204 { 205 if (not_found) 206 return 0; 207 else { 208 not_found = 1; 209 return 1; 210 } 211 } 212 213 inline symbol *charinfo::get_symbol() 214 { 215 return( &nm ); 216 } 217