2 /* Copyright (C) 1989-2018 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 3 of the License, or
10 (at your option) any later 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
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 unsigned char breakable;
23 unsigned char hyphenation_code;
25 hyphen_list(unsigned char code, hyphen_list *p = 0);
28 void hyphenate(hyphen_list *, unsigned);
30 enum hyphenation_type { HYPHEN_MIDDLE, HYPHEN_BOUNDARY, HYPHEN_INHIBIT };
32 class ascii_output_file;
40 class troff_output_file;
45 class diverted_space_node;
57 node(node *, statem *, int);
58 node *add_char(charinfo *, environment *, hunits *, int *, node ** = 0);
61 virtual node *copy() = 0;
62 virtual int set_unformat_flag();
63 virtual int force_tprint() = 0;
64 virtual int is_tag() = 0;
65 virtual int get_break_code();
66 virtual hunits width();
67 virtual hunits subscript_correction();
68 virtual hunits italic_correction();
69 virtual hunits left_italic_correction();
70 virtual hunits skew();
71 virtual int nspaces();
72 virtual int merge_space(hunits, hunits, hunits);
73 virtual vunits vertical_width();
74 virtual node *last_char_node();
75 virtual void vertical_extent(vunits *, vunits *);
76 virtual int character_type();
77 virtual void set_vertical_size(vertical_size *);
78 virtual int ends_sentence();
79 virtual node *merge_self(node *);
80 virtual node *add_discretionary_hyphen();
81 virtual node *add_self(node *, hyphen_list **);
82 virtual hyphen_list *get_hyphen_list(hyphen_list *, int *);
83 virtual void ascii_print(ascii_output_file *);
84 virtual void asciify(macro *);
85 virtual int discardable();
86 virtual void spread_space(int *, hunits *);
87 virtual void freeze_space();
88 virtual void is_escape_colon();
89 virtual breakpoint *get_breakpoints(hunits, int, breakpoint * = 0, int = 0);
90 virtual int nbreaks();
91 virtual void split(int, node **, node **);
92 virtual hyphenation_type get_hyphenation_type();
93 virtual int reread(int *);
94 virtual token_node *get_token_node();
95 virtual int overlaps_vertically();
96 virtual int overlaps_horizontally();
98 virtual int interpret(macro *);
100 virtual node *merge_glyph_node(glyph_node *);
101 virtual tfont *get_tfont();
102 virtual color *get_glyph_color();
103 virtual color *get_fill_color();
104 virtual void tprint(troff_output_file *);
105 virtual void zero_width_tprint(troff_output_file *);
107 node *add_italic_correction(hunits *);
109 virtual int same(node *) = 0;
110 virtual const char *type() = 0;
111 virtual void debug_node();
112 virtual void debug_node_list();
116 : next(0), last(0), state(0), push_state(0), div_nest_level(0), is_special(0)
120 inline node::node(node *n)
121 : next(n), last(0), state(0), push_state(0), div_nest_level(0), is_special(0)
125 inline node::node(node *n, statem *s, int divlevel)
126 : next(n), last(0), push_state(0), div_nest_level(divlevel), is_special(0)
129 state = new statem(s);
142 // 0 means it doesn't, 1 means it does, 2 means it's transparent
144 int node_list_ends_sentence(node *);
155 class line_start_node : public node {
158 node *copy() { return new line_start_node; }
163 void asciify(macro *);
166 class space_node : public node {
171 char was_escape_colon;
172 color *col; /* for grotty */
173 space_node(hunits, int, int, color *, statem *, int, node * = 0);
175 space_node(hunits, color *, node * = 0);
180 int merge_space(hunits, hunits, hunits);
182 void is_escape_colon();
183 void spread_space(int *, hunits *);
184 void tprint(troff_output_file *);
185 breakpoint *get_breakpoints(hunits, int, breakpoint * = 0, int = 0);
187 void split(int, node **, node **);
188 void ascii_print(ascii_output_file *);
190 void asciify(macro *);
194 hyphenation_type get_hyphenation_type();
199 hunits sentence_width;
201 width_list(hunits, hunits);
202 width_list(width_list *);
205 class word_space_node : public space_node {
207 width_list *orig_width;
208 unsigned char unformat;
209 word_space_node(hunits, int, color *, width_list *, int, statem *, int,
212 word_space_node(hunits, color *, width_list *, node * = 0);
216 int set_unformat_flag();
217 void tprint(troff_output_file *);
219 void asciify(macro *);
221 int merge_space(hunits, hunits, hunits);
226 class unbreakable_space_node : public word_space_node {
227 unbreakable_space_node(hunits, int, color *, statem *, int, node * = 0);
229 unbreakable_space_node(hunits, color *, node * = 0);
232 void tprint(troff_output_file *);
234 void asciify(macro *);
238 breakpoint *get_breakpoints(hunits, int, breakpoint * = 0, int = 0);
240 void split(int, node **, node **);
241 int merge_space(hunits, hunits, hunits);
242 node *add_self(node *, hyphen_list **);
243 hyphen_list *get_hyphen_list(hyphen_list *, int *);
244 hyphenation_type get_hyphenation_type();
247 class diverted_space_node : public node {
250 diverted_space_node(vunits, node * = 0);
251 diverted_space_node(vunits, statem *, int, node * = 0);
260 class diverted_copy_file_node : public node {
264 diverted_copy_file_node(symbol, node * = 0);
265 diverted_copy_file_node(symbol, statem *, int, node * = 0);
274 class extra_size_node : public node {
277 extra_size_node(vunits);
278 extra_size_node(vunits, statem *, int);
279 void set_vertical_size(vertical_size *);
287 class vertical_size_node : public node {
290 vertical_size_node(vunits, statem *, int);
291 vertical_size_node(vunits);
292 void set_vertical_size(vertical_size *);
293 void asciify(macro *);
295 int set_unformat_flag();
302 class hmotion_node : public node {
305 unsigned char was_tab;
306 unsigned char unformat;
307 color *col; /* for grotty */
309 hmotion_node(hunits i, color *c, node *nxt = 0)
310 : node(nxt), n(i), was_tab(0), unformat(0), col(c) {}
311 hmotion_node(hunits i, color *c, statem *s, int divlevel, node *nxt = 0)
312 : node(nxt, s, divlevel), n(i), was_tab(0), unformat(0), col(c) {}
313 hmotion_node(hunits i, int flag1, int flag2, color *c, statem *s,
314 int divlevel, node *nxt = 0)
315 : node(nxt, s, divlevel), n(i), was_tab(flag1), unformat(flag2),
317 hmotion_node(hunits i, int flag1, int flag2, color *c, node *nxt = 0)
318 : node(nxt), n(i), was_tab(flag1), unformat(flag2), col(c) {}
321 int set_unformat_flag();
322 void asciify(macro *);
323 void tprint(troff_output_file *);
325 void ascii_print(ascii_output_file *);
330 node *add_self(node *, hyphen_list **);
331 hyphen_list *get_hyphen_list(hyphen_list *, int *);
332 hyphenation_type get_hyphenation_type();
335 class space_char_hmotion_node : public hmotion_node {
337 space_char_hmotion_node(hunits, color *, node * = 0);
338 space_char_hmotion_node(hunits, color *, statem *, int, node * = 0);
340 void ascii_print(ascii_output_file *);
341 void asciify(macro *);
342 void tprint(troff_output_file *);
347 node *add_self(node *, hyphen_list **);
348 hyphen_list *get_hyphen_list(hyphen_list *, int *);
349 hyphenation_type get_hyphenation_type();
352 class vmotion_node : public node {
354 color *col; /* for grotty */
356 vmotion_node(vunits, color *);
357 vmotion_node(vunits, color *, statem *, int);
358 void tprint(troff_output_file *);
360 vunits vertical_width();
367 class hline_node : public node {
371 hline_node(hunits, node *, node * = 0);
372 hline_node(hunits, node *, statem *, int, node * = 0);
376 void tprint(troff_output_file *);
383 class vline_node : public node {
387 vline_node(vunits, node *, node * = 0);
388 vline_node(vunits, node *, statem *, int, node * = 0);
391 void tprint(troff_output_file *);
393 vunits vertical_width();
394 void vertical_extent(vunits *, vunits *);
401 class dummy_node : public node {
403 dummy_node(node *nd = 0) : node(nd) {}
409 hyphenation_type get_hyphenation_type();
412 class transparent_dummy_node : public node {
414 transparent_dummy_node(node *nd = 0) : node(nd) {}
421 hyphenation_type get_hyphenation_type();
424 class zero_width_node : public node {
427 zero_width_node(node *);
428 zero_width_node(node *, statem *, int);
431 void tprint(troff_output_file *);
437 int character_type();
438 void vertical_extent(vunits *, vunits *);
441 class left_italic_corrected_node : public node {
445 left_italic_corrected_node(node * = 0);
446 left_italic_corrected_node(statem *, int, node * = 0);
447 ~left_italic_corrected_node();
448 void tprint(troff_output_file *);
449 void ascii_print(ascii_output_file *);
450 void asciify(macro *);
457 node *last_char_node();
458 void vertical_extent(vunits *, vunits *);
460 int overlaps_horizontally();
461 int overlaps_vertically();
462 hyphenation_type get_hyphenation_type();
464 int character_type();
466 hunits italic_correction();
467 hunits subscript_correction();
468 hyphen_list *get_hyphen_list(hyphen_list *, int *);
469 node *add_self(node *, hyphen_list **);
470 node *merge_glyph_node(glyph_node *);
473 class overstrike_node : public node {
478 overstrike_node(statem *, int);
481 void tprint(troff_output_file *);
482 void overstrike(node *); // add another node to be overstruck
488 node *add_self(node *, hyphen_list **);
489 hyphen_list *get_hyphen_list(hyphen_list *, int *);
490 hyphenation_type get_hyphenation_type();
493 class bracket_node : public node {
498 bracket_node(statem *, int);
501 void tprint(troff_output_file *);
502 void bracket(node *); // add another node to be overstruck
510 class special_node : public node {
516 void tprint_start(troff_output_file *);
517 void tprint_char(troff_output_file *, unsigned char);
518 void tprint_end(troff_output_file *);
520 special_node(const macro &, int = 0);
521 special_node(const macro &, tfont *, color *, color *, statem *, int,
524 void tprint(troff_output_file *);
533 class suppress_node : public node {
535 int emit_limits; // must we issue the extent of the area written out?
540 suppress_node(int, int);
541 suppress_node(symbol, char, int);
542 suppress_node(int, int, symbol, char, int, statem *, int);
543 suppress_node(int, int, symbol, char, int);
545 void tprint(troff_output_file *);
552 void put(troff_output_file *, const char *);
555 class tag_node : public node {
560 tag_node(string, int);
561 tag_node(string, statem *, int, int);
563 void tprint(troff_output_file *);
577 class draw_node : public node {
585 draw_node(char, hvpair *, int, font_size, color *, color *);
586 draw_node(char, hvpair *, int, font_size, color *, color *, statem *, int);
589 vunits vertical_width();
591 void tprint(troff_output_file *);
599 node *make_node(charinfo *, environment *);
600 int character_exists(charinfo *, environment *);
602 int same_node_list(node *, node *);
603 node *reverse_node_list(node *);
604 void delete_node_list(node *);
605 node *copy_node_list(node *);
607 int get_bold_fontno(int);
609 inline hyphen_list::hyphen_list(unsigned char code, hyphen_list *p)
610 : hyphen(0), breakable(0), hyphenation_code(code), next(p)
614 extern void read_desc();
615 extern int mount_font(int, symbol, symbol = NULL_SYMBOL);
616 extern int check_font(symbol, symbol);
617 extern int check_style(symbol);
618 extern void mount_style(int, symbol);
619 extern int is_good_fontno(int);
620 extern int symbol_fontno(symbol);
621 extern int next_available_font_position();
622 extern void init_size_table(int *);
623 extern int get_underline_fontno();
626 char make_g_plus_plus_shut_up;
629 virtual ~output_file();
630 virtual void trailer(vunits);
631 virtual void flush() = 0;
632 virtual void transparent_char(unsigned char) = 0;
633 virtual void print_line(hunits x, vunits y, node *n,
634 vunits before, vunits after, hunits width) = 0;
635 virtual void begin_page(int pageno, vunits page_length) = 0;
636 virtual void copy_file(hunits x, vunits y, const char *filename) = 0;
637 virtual int is_printing() = 0;
638 virtual void put_filename(const char *, int);
642 virtual void vjustify(vunits, symbol);
647 #ifndef POPEN_MISSING
648 extern char *pipe_command;
651 extern output_file *the_output;
652 extern void init_output();
653 int in_output_page_list(int);
662 int make_definite(int);
663 static void invalidate_fontno(int);
666 font_family *lookup_family(symbol);
667 symbol get_font_name(int, environment *);
668 symbol get_style_name(int);
669 extern search_path include_search_path;