* src/roff/troff/env.cpp (hyphen_trie::read_patterns_file): Fix loop
[s-roff.git] / src / roff / troff / charinfo.h
blob4123fbadd5ecae9cd0eee5b6edf25b1b087856f7
1 // -*- C++ -*-
2 /* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002
3 Free Software Foundation, Inc.
4 Written by James Clark (jjc@jclark.com)
6 This file is part of groff.
8 groff is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2, or (at your option) any later
11 version.
13 groff is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License along
19 with groff; see the file COPYING. If not, write to the Free Software
20 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22 class macro;
24 class charinfo {
25 static int next_index;
26 charinfo *translation;
27 int index;
28 int number;
29 macro *mac;
30 unsigned char special_translation;
31 unsigned char hyphenation_code;
32 unsigned char flags;
33 unsigned char ascii_code;
34 unsigned char asciify_code;
35 char not_found;
36 char transparent_translate; // non-zero means translation applies
37 // to transparent throughput
38 char translate_input; // non-zero means that asciify_code is
39 // active for .asciify (set by .trin)
40 char_mode mode;
41 public:
42 enum {
43 ENDS_SENTENCE = 1,
44 BREAK_BEFORE = 2,
45 BREAK_AFTER = 4,
46 OVERLAPS_HORIZONTALLY = 8,
47 OVERLAPS_VERTICALLY = 16,
48 TRANSPARENT = 32,
49 NUMBERED = 64
51 enum {
52 TRANSLATE_NONE,
53 TRANSLATE_SPACE,
54 TRANSLATE_DUMMY,
55 TRANSLATE_STRETCHABLE_SPACE,
56 TRANSLATE_HYPHEN_INDICATOR
58 symbol nm;
59 charinfo(symbol s);
60 int get_index();
61 int ends_sentence();
62 int overlaps_vertically();
63 int overlaps_horizontally();
64 int can_break_before();
65 int can_break_after();
66 int transparent();
67 unsigned char get_hyphenation_code();
68 unsigned char get_ascii_code();
69 unsigned char get_asciify_code();
70 void set_hyphenation_code(unsigned char);
71 void set_ascii_code(unsigned char);
72 void set_asciify_code(unsigned char);
73 void set_translation_input();
74 int get_translation_input();
75 charinfo *get_translation(int = 0);
76 void set_translation(charinfo *, int, int);
77 void set_flags(unsigned char);
78 void set_special_translation(int, int);
79 int get_special_translation(int = 0);
80 macro *set_macro(macro *);
81 macro *setx_macro(macro *, char_mode);
82 macro *get_macro();
83 int first_time_not_found();
84 void set_number(int);
85 int get_number();
86 int numbered();
87 int is_normal();
88 int is_fallback();
89 int is_special();
90 symbol *get_symbol();
93 charinfo *get_charinfo(symbol);
94 extern charinfo *charset_table[];
95 charinfo *get_charinfo_by_number(int);
97 inline int charinfo::overlaps_horizontally()
99 return flags & OVERLAPS_HORIZONTALLY;
102 inline int charinfo::overlaps_vertically()
104 return flags & OVERLAPS_VERTICALLY;
107 inline int charinfo::can_break_before()
109 return flags & BREAK_BEFORE;
112 inline int charinfo::can_break_after()
114 return flags & BREAK_AFTER;
117 inline int charinfo::ends_sentence()
119 return flags & ENDS_SENTENCE;
122 inline int charinfo::transparent()
124 return flags & TRANSPARENT;
127 inline int charinfo::numbered()
129 return flags & NUMBERED;
132 inline int charinfo::is_normal()
134 return mode == CHAR_NORMAL;
137 inline int charinfo::is_fallback()
139 return mode == CHAR_FALLBACK;
142 inline int charinfo::is_special()
144 return mode == CHAR_SPECIAL;
147 inline charinfo *charinfo::get_translation(int transparent_throughput)
149 return (transparent_throughput && !transparent_translate
151 : translation);
154 inline unsigned char charinfo::get_hyphenation_code()
156 return hyphenation_code;
159 inline unsigned char charinfo::get_ascii_code()
161 return ascii_code;
164 inline unsigned char charinfo::get_asciify_code()
166 return (translate_input ? asciify_code : 0);
169 inline void charinfo::set_flags(unsigned char c)
171 flags = c;
174 inline int charinfo::get_index()
176 return index;
179 inline void charinfo::set_translation_input()
181 translate_input = 1;
184 inline int charinfo::get_translation_input()
186 return translate_input;
189 inline int charinfo::get_special_translation(int transparent_throughput)
191 return (transparent_throughput && !transparent_translate
192 ? int(TRANSLATE_NONE)
193 : special_translation);
196 inline macro *charinfo::get_macro()
198 return mac;
201 inline int charinfo::first_time_not_found()
203 if (not_found)
204 return 0;
205 else {
206 not_found = 1;
207 return 1;
211 inline symbol *charinfo::get_symbol()
213 return( &nm );