Sync-to-go: update copyright for 2015
[s-roff.git] / src / troff / charinfo.h
blob0b5ad6690ae99e2f8466559be63595f3eb5cbd99
1 /*@
2 * Copyright (c) 2014 - 2015 Steffen (Daode) Nurpmeso <sdaoden@users.sf.net>.
4 * Copyright (C) 1989 - 1992, 2001, 2002, 2006
5 * Free Software Foundation, Inc.
6 * Written by James Clark (jjc@jclark.com)
8 * This 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 * This 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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.
22 #ifndef _CHARINFO_H
23 #define _CHARINFO_H
25 #include "config.h"
26 #include "troff-config.h"
28 class macro;
30 class charinfo
31 : glyph
33 static int next_index;
35 charinfo *translation;
36 macro *mac;
37 unsigned char special_translation;
38 unsigned char hyphenation_code;
39 unsigned char flags;
40 unsigned char ascii_code;
41 unsigned char asciify_code;
42 char not_found;
43 char transparent_translate; // non-zero means translation applies
44 // to transparent throughput
45 char translate_input; // non-zero means that asciify_code is
46 // active for .asciify (set by .trin)
47 char_mode mode;
49 public:
50 enum { // Values for the flags bitmask. See groff
51 // manual, description of the `.cflags' request.
52 ENDS_SENTENCE = 1,
53 BREAK_BEFORE = 2,
54 BREAK_AFTER = 4,
55 OVERLAPS_HORIZONTALLY = 8,
56 OVERLAPS_VERTICALLY = 16,
57 TRANSPARENT = 32,
58 IGNORE_HCODES = 64
60 enum {
61 TRANSLATE_NONE,
62 TRANSLATE_SPACE,
63 TRANSLATE_DUMMY,
64 TRANSLATE_STRETCHABLE_SPACE,
65 TRANSLATE_HYPHEN_INDICATOR
68 symbol nm;
70 charinfo(symbol);
71 glyph *as_glyph();
72 int ends_sentence();
73 int overlaps_vertically();
74 int overlaps_horizontally();
75 int can_break_before();
76 int can_break_after();
77 int transparent();
78 int ignore_hcodes();
79 unsigned char get_hyphenation_code();
80 unsigned char get_ascii_code();
81 unsigned char get_asciify_code();
82 void set_hyphenation_code(unsigned char);
83 void set_ascii_code(unsigned char);
84 void set_asciify_code(unsigned char);
85 void set_translation_input();
86 int get_translation_input();
87 charinfo *get_translation(int = 0);
88 void set_translation(charinfo *, int, int);
89 void set_flags(unsigned char);
90 void set_special_translation(int, int);
91 int get_special_translation(int = 0);
92 macro *set_macro(macro *);
93 macro *setx_macro(macro *, char_mode);
94 macro *get_macro();
95 int first_time_not_found();
96 void set_number(int);
97 int get_number();
98 int numbered();
99 int is_normal();
100 int is_fallback();
101 int is_special();
102 symbol *get_symbol();
105 charinfo *get_charinfo(symbol);
106 extern charinfo *charset_table[];
107 charinfo *get_charinfo_by_number(int);
109 inline int charinfo::overlaps_horizontally()
111 return flags & OVERLAPS_HORIZONTALLY;
114 inline int charinfo::overlaps_vertically()
116 return flags & OVERLAPS_VERTICALLY;
119 inline int charinfo::can_break_before()
121 return flags & BREAK_BEFORE;
124 inline int charinfo::can_break_after()
126 return flags & BREAK_AFTER;
129 inline int charinfo::ends_sentence()
131 return flags & ENDS_SENTENCE;
134 inline int charinfo::transparent()
136 return flags & TRANSPARENT;
139 inline int charinfo::ignore_hcodes()
141 return flags & IGNORE_HCODES;
144 inline int charinfo::numbered()
146 return number >= 0;
149 inline int charinfo::is_normal()
151 return mode == CHAR_NORMAL;
154 inline int charinfo::is_fallback()
156 return mode == CHAR_FALLBACK;
159 inline int charinfo::is_special()
161 return mode == CHAR_SPECIAL;
164 inline charinfo *charinfo::get_translation(int transparent_throughput)
166 return (transparent_throughput && !transparent_translate
168 : translation);
171 inline unsigned char charinfo::get_hyphenation_code()
173 return hyphenation_code;
176 inline unsigned char charinfo::get_ascii_code()
178 return ascii_code;
181 inline unsigned char charinfo::get_asciify_code()
183 return (translate_input ? asciify_code : 0);
186 inline void charinfo::set_flags(unsigned char c)
188 flags = c;
191 inline glyph *charinfo::as_glyph()
193 return this;
196 inline void charinfo::set_translation_input()
198 translate_input = 1;
201 inline int charinfo::get_translation_input()
203 return translate_input;
206 inline int charinfo::get_special_translation(int transparent_throughput)
208 return (transparent_throughput && !transparent_translate
209 ? int(TRANSLATE_NONE)
210 : special_translation);
213 inline macro *charinfo::get_macro()
215 return mac;
218 inline int charinfo::first_time_not_found()
220 if (not_found)
221 return 0;
222 else {
223 not_found = 1;
224 return 1;
228 inline symbol *charinfo::get_symbol()
230 return( &nm );
233 #endif // _CHARINFO_H
234 // s-it2-mode