groff before CVS: release 1.07
[s-roff.git] / troff / charinfo.h
blob29a5b853d4b5fe4f804dc39121125e3e3b249ac4
1 // -*- C++ -*-
2 /* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
3 Written by James Clark (jjc@jclark.com)
5 This file is part of groff.
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.
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.
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. */
21 class macro;
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
46 enum {
47 TRANSLATE_NONE,
48 TRANSLATE_SPACE,
49 TRANSLATE_DUMMY,
50 TRANSLATE_STRETCHABLE_SPACE,
51 TRANSLATE_HYPHEN_INDICATOR
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();
79 charinfo *get_charinfo(symbol);
80 extern charinfo *charset_table[];
81 charinfo *get_charinfo_by_number(int);
83 inline int charinfo::overlaps_horizontally()
85 return flags & OVERLAPS_HORIZONTALLY;
88 inline int charinfo::overlaps_vertically()
90 return flags & OVERLAPS_VERTICALLY;
93 inline int charinfo::can_break_before()
95 return flags & BREAK_BEFORE;
98 inline int charinfo::can_break_after()
100 return flags & BREAK_AFTER;
103 inline int charinfo::ends_sentence()
105 return flags & ENDS_SENTENCE;
108 inline int charinfo::transparent()
110 return flags & TRANSPARENT;
113 inline int charinfo::numbered()
115 return flags & NUMBERED;
118 inline charinfo *charinfo::get_translation(int transparent_throughput)
120 return (transparent_throughput && !transparent_translate
122 : translation);
125 inline unsigned char charinfo::get_hyphenation_code()
127 return hyphenation_code;
130 inline unsigned char charinfo::get_ascii_code()
132 return ascii_code;
135 inline void charinfo::set_flags(unsigned char c)
137 flags = c;
140 inline int charinfo::get_index()
142 return index;
145 inline int charinfo::get_special_translation(int transparent_throughput)
147 return (transparent_throughput && !transparent_translate
148 ? TRANSLATE_NONE
149 : special_translation);
152 inline macro *charinfo::get_macro()
154 return mac;
157 inline int charinfo::first_time_not_found()
159 if (not_found)
160 return 0;
161 else {
162 not_found = 1;
163 return 1;