1 // -*- C++ -*-
2 /* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
3 Written by James Clark (jjc@jclark.com)
4
5 This file is part of groff.
6
7 groff is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 groff is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License along
18 with groff; see the file COPYING. If not, write to the Free Software
19 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21 class macro;
22
23 class charinfo {
24 static int next_index;
25 charinfo *translation;
26 int index;
27 int number;
28 macro *mac;
29 unsigned char special_translation;
30 unsigned char hyphenation_code;
31 unsigned char flags;
32 unsigned char ascii_code;
33 char not_found;
34 char transparent_translate; // non-zero means translation applies to
35 // to transparent throughput
36 public:
37 enum {
38 ENDS_SENTENCE = 1,
39 BREAK_BEFORE = 2,
40 BREAK_AFTER = 4,
41 OVERLAPS_HORIZONTALLY = 8,
42 OVERLAPS_VERTICALLY = 16,
43 TRANSPARENT = 32,
44 NUMBERED = 64
45 };
46 enum {
47 TRANSLATE_NONE,
48 TRANSLATE_SPACE,
49 TRANSLATE_DUMMY,
50 TRANSLATE_STRETCHABLE_SPACE,
51 TRANSLATE_HYPHEN_INDICATOR
52 };
53 symbol nm;
54 charinfo(symbol s);
55 int get_index();
56 int ends_sentence();
57 int overlaps_vertically();
58 int overlaps_horizontally();
59 int can_break_before();
60 int can_break_after();
61 int transparent();
62 unsigned char get_hyphenation_code();
63 unsigned char get_ascii_code();
64 void set_hyphenation_code(unsigned char);
65 void set_ascii_code(unsigned char);
66 charinfo *get_translation(int = 0);
67 void set_translation(charinfo *, int);
68 void set_flags(unsigned char);
69 void set_special_translation(int, int);
70 int get_special_translation(int = 0);
71 macro *set_macro(macro *);
72 macro *get_macro();
73 int first_time_not_found();
74 void set_number(int);
75 int get_number();
76 int numbered();
77 };
78
79 charinfo *get_charinfo(symbol);
80 extern charinfo *charset_table[];
81 charinfo *get_charinfo_by_number(int);
82
overlaps_horizontally()83 inline int charinfo::overlaps_horizontally()
84 {
85 return flags & OVERLAPS_HORIZONTALLY;
86 }
87
overlaps_vertically()88 inline int charinfo::overlaps_vertically()
89 {
90 return flags & OVERLAPS_VERTICALLY;
91 }
92
can_break_before()93 inline int charinfo::can_break_before()
94 {
95 return flags & BREAK_BEFORE;
96 }
97
can_break_after()98 inline int charinfo::can_break_after()
99 {
100 return flags & BREAK_AFTER;
101 }
102
ends_sentence()103 inline int charinfo::ends_sentence()
104 {
105 return flags & ENDS_SENTENCE;
106 }
107
transparent()108 inline int charinfo::transparent()
109 {
110 return flags & TRANSPARENT;
111 }
112
numbered()113 inline int charinfo::numbered()
114 {
115 return flags & NUMBERED;
116 }
117
get_translation(int transparent_throughput)118 inline charinfo *charinfo::get_translation(int transparent_throughput)
119 {
120 return (transparent_throughput && !transparent_translate
121 ? 0
122 : translation);
123 }
124
get_hyphenation_code()125 inline unsigned char charinfo::get_hyphenation_code()
126 {
127 return hyphenation_code;
128 }
129
get_ascii_code()130 inline unsigned char charinfo::get_ascii_code()
131 {
132 return ascii_code;
133 }
134
set_flags(unsigned char c)135 inline void charinfo::set_flags(unsigned char c)
136 {
137 flags = c;
138 }
139
get_index()140 inline int charinfo::get_index()
141 {
142 return index;
143 }
144
get_special_translation(int transparent_throughput)145 inline int charinfo::get_special_translation(int transparent_throughput)
146 {
147 return (transparent_throughput && !transparent_translate
148 ? TRANSLATE_NONE
149 : special_translation);
150 }
151
get_macro()152 inline macro *charinfo::get_macro()
153 {
154 return mac;
155 }
156
first_time_not_found()157 inline int charinfo::first_time_not_found()
158 {
159 if (not_found)
160 return 0;
161 else {
162 not_found = 1;
163 return 1;
164 }
165 }
166