2 /* Copyright (C) 1989, 1990, 1991, 1992, 2000, 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
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
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. */
25 unsigned char breakable;
26 unsigned char hyphenation_code;
28 hyphen_list(unsigned char code, hyphen_list *p = 0);
31 void hyphenate(hyphen_list *, unsigned);
33 enum hyphenation_type { HYPHEN_MIDDLE, HYPHEN_BOUNDARY, HYPHEN_INHIBIT };
35 class ascii_output_file;
43 class troff_output_file;
48 class diverted_space_node;
56 node *add_char(charinfo *c, environment *, hunits *widthp, int *spacep);
59 virtual node *copy() = 0;
60 virtual int set_unformat_flag();
61 virtual int force_tprint() = 0;
62 virtual hunits width();
63 virtual hunits subscript_correction();
64 virtual hunits italic_correction();
65 virtual hunits left_italic_correction();
66 virtual hunits skew();
67 virtual int nspaces();
68 virtual int merge_space(hunits, hunits, hunits);
69 virtual vunits vertical_width();
70 virtual node *last_char_node();
71 virtual void vertical_extent(vunits *min, vunits *max);
72 virtual int character_type();
73 virtual void set_vertical_size(vertical_size *);
74 virtual int ends_sentence();
75 virtual node *merge_self(node *);
76 virtual node *add_discretionary_hyphen();
77 virtual node *add_self(node *, hyphen_list **);
78 virtual hyphen_list *get_hyphen_list(hyphen_list *s = 0);
79 virtual void ascii_print(ascii_output_file *);
80 virtual void asciify(macro *);
81 virtual int discardable();
82 virtual void spread_space(int *, hunits *);
83 virtual void freeze_space();
84 virtual void is_escape_colon();
85 virtual breakpoint *get_breakpoints(hunits width, int nspaces,
88 virtual int nbreaks();
89 virtual void split(int, node **, node **);
90 virtual hyphenation_type get_hyphenation_type();
91 virtual int reread(int *);
92 virtual token_node *get_token_node();
93 virtual int overlaps_vertically();
94 virtual int overlaps_horizontally();
96 virtual int interpret(macro *);
98 virtual node *merge_glyph_node(glyph_node *);
99 virtual tfont *get_tfont();
100 virtual color *get_glyph_color();
101 virtual color *get_fill_color();
102 virtual void tprint(troff_output_file *);
103 virtual void zero_width_tprint(troff_output_file *);
105 node *add_italic_correction(hunits *);
107 virtual int same(node *) = 0;
108 virtual const char *type() = 0;
116 inline node::node(node *n)
125 // 0 means it doesn't, 1 means it does, 2 means it's transparent
127 int node_list_ends_sentence(node *);
138 class line_start_node : public node {
141 node *copy() { return new line_start_node; }
145 void asciify(macro *);
148 class space_node : public node {
151 enum { BLOCK = 1024 };
152 static space_node *free_list;
153 void operator delete(void *);
158 char was_escape_colon;
159 color *col; /* for grotty */
160 space_node(hunits, int, int, color *, node * = 0);
162 space_node(hunits, color *, node * = 0);
165 void *operator new(size_t);
171 int merge_space(hunits, hunits, hunits);
173 void is_escape_colon();
174 void spread_space(int *, hunits *);
175 void tprint(troff_output_file *);
176 breakpoint *get_breakpoints(hunits width, int nspaces, breakpoint *rest = 0,
179 void split(int, node **, node **);
180 void ascii_print(ascii_output_file *);
182 void asciify(macro *);
185 hyphenation_type get_hyphenation_type();
190 hunits sentence_width;
192 width_list(hunits, hunits);
193 width_list(width_list *);
196 class word_space_node : public space_node {
198 width_list *orig_width;
199 unsigned char unformat;
200 word_space_node(hunits, int, color *, width_list *, int, node * = 0);
202 word_space_node(hunits, color *, width_list *, node * = 0);
206 int set_unformat_flag();
207 void tprint(troff_output_file *);
209 void asciify(macro *);
211 int merge_space(hunits, hunits, hunits);
215 class unbreakable_space_node : public word_space_node {
216 unbreakable_space_node(hunits, int, color *, node * = 0);
218 unbreakable_space_node(hunits, color *, node * = 0);
222 void asciify(macro *);
225 breakpoint *get_breakpoints(hunits width, int nspaces, breakpoint *rest = 0,
228 void split(int, node **, node **);
229 int merge_space(hunits, hunits, hunits);
230 node *add_self(node *, hyphen_list **);
231 hyphen_list *get_hyphen_list(hyphen_list *ss = 0);
232 hyphenation_type get_hyphenation_type();
235 class diverted_space_node : public node {
238 diverted_space_node(vunits d, node *p = 0);
246 class diverted_copy_file_node : public node {
250 diverted_copy_file_node(symbol s, node *p = 0);
258 class extra_size_node : public node {
261 extra_size_node(vunits i) : n(i) {}
262 void set_vertical_size(vertical_size *);
269 class vertical_size_node : public node {
272 vertical_size_node(vunits i) : n(i) {}
273 void set_vertical_size(vertical_size *);
274 void asciify(macro *);
276 int set_unformat_flag();
282 class hmotion_node : public node {
285 unsigned char was_tab;
286 unsigned char unformat;
287 color *col; /* for grotty */
289 hmotion_node(hunits i, color *c, node *next = 0)
290 : node(next), n(i), was_tab(0), unformat(0), col(c) {}
291 hmotion_node(hunits i, int flag1, int flag2, color *c, node *next = 0)
292 : node(next), n(i), was_tab(flag1), unformat(flag2), col(c) {}
295 int set_unformat_flag();
296 void asciify(macro *);
297 void tprint(troff_output_file *);
299 void ascii_print(ascii_output_file *);
303 node *add_self(node *, hyphen_list **);
304 hyphen_list *get_hyphen_list(hyphen_list *ss = 0);
305 hyphenation_type get_hyphenation_type();
308 class space_char_hmotion_node : public hmotion_node {
310 space_char_hmotion_node(hunits, color *, node * = 0);
312 void ascii_print(ascii_output_file *);
313 void asciify(macro *);
317 node *add_self(node *, hyphen_list **);
318 hyphen_list *get_hyphen_list(hyphen_list *ss = 0);
319 hyphenation_type get_hyphenation_type();
322 class vmotion_node : public node {
324 color *col; /* for grotty */
326 vmotion_node(vunits i, color *c) : n(i), col(c) {}
327 void tprint(troff_output_file *);
329 vunits vertical_width();
335 class hline_node : public node {
339 hline_node(hunits i, node *c, node *next = 0) : node(next), x(i), n(c) {}
343 void tprint(troff_output_file *);
349 class vline_node : public node {
353 vline_node(vunits i, node *c, node *next= 0) : node(next), x(i), n(c) {}
356 void tprint(troff_output_file *);
358 vunits vertical_width();
359 void vertical_extent(vunits *, vunits *);
366 class dummy_node : public node {
368 dummy_node(node *nd = 0) : node(nd) {}
373 hyphenation_type get_hyphenation_type();
376 class transparent_dummy_node : public node {
378 transparent_dummy_node(node *nd = 0) : node(nd) {}
384 hyphenation_type get_hyphenation_type();
387 class zero_width_node : public node {
390 zero_width_node(node *gn);
393 void tprint(troff_output_file *);
398 int character_type();
399 void vertical_extent(vunits *min, vunits *max);
402 class left_italic_corrected_node : public node {
406 left_italic_corrected_node(node * = 0);
407 ~left_italic_corrected_node();
408 void tprint(troff_output_file *);
409 void ascii_print(ascii_output_file *);
410 void asciify(macro *);
416 node *last_char_node();
417 void vertical_extent(vunits *, vunits *);
419 int overlaps_horizontally();
420 int overlaps_vertically();
421 hyphenation_type get_hyphenation_type();
423 int character_type();
425 hunits italic_correction();
426 hunits subscript_correction();
427 hyphen_list *get_hyphen_list(hyphen_list *ss = 0);
428 node *add_self(node *, hyphen_list **);
429 node *merge_glyph_node(glyph_node *);
432 class overstrike_node : public node {
439 void tprint(troff_output_file *);
440 void overstrike(node *); // add another node to be overstruck
445 node *add_self(node *, hyphen_list **);
446 hyphen_list *get_hyphen_list(hyphen_list *ss = 0);
447 hyphenation_type get_hyphenation_type();
450 class bracket_node : public node {
457 void tprint(troff_output_file *);
458 void bracket(node *); // add another node to be overstruck
465 class special_node : public node {
471 void tprint_start(troff_output_file *);
472 void tprint_char(troff_output_file *, unsigned char);
473 void tprint_end(troff_output_file *);
475 special_node(const macro &, int = 0);
476 special_node(const macro &, tfont *, color *, color *, int = 0);
478 void tprint(troff_output_file *);
486 class suppress_node : public node {
488 int emit_limits; // must we issue the extent of the area written out?
493 suppress_node(int, int);
494 suppress_node(symbol f, char p, int id);
495 suppress_node(int, int, symbol f, char p, int id);
497 void tprint(troff_output_file *);
503 void put(troff_output_file *out, const char *s);
512 class draw_node : public node {
520 draw_node(char, hvpair *, int, font_size, color *, color *);
523 vunits vertical_width();
525 void tprint(troff_output_file *);
532 node *make_node(charinfo *ci, environment *);
533 int character_exists(charinfo *, environment *);
535 int same_node_list(node *n1, node *n2);
536 node *reverse_node_list(node *n);
537 void delete_node_list(node *);
538 node *copy_node_list(node *);
540 int get_bold_fontno(int f);
542 inline hyphen_list::hyphen_list(unsigned char code, hyphen_list *p)
543 : hyphen(0), breakable(0), hyphenation_code(code), next(p)
547 extern void read_desc();
548 extern int mount_font(int n, symbol, symbol = NULL_SYMBOL);
549 extern void mount_style(int n, symbol);
550 extern int is_good_fontno(int n);
551 extern int symbol_fontno(symbol);
552 extern int next_available_font_position();
553 extern void init_size_table(int *);
554 extern int get_underline_fontno();
557 char make_g_plus_plus_shut_up;
560 virtual ~output_file();
561 virtual void trailer(vunits page_length);
562 virtual void flush() = 0;
563 virtual void transparent_char(unsigned char) = 0;
564 virtual void print_line(hunits x, vunits y, node *n,
565 vunits before, vunits after, hunits width) = 0;
566 virtual void begin_page(int pageno, vunits page_length) = 0;
567 virtual void copy_file(hunits x, vunits y, const char *filename) = 0;
568 virtual int is_printing() = 0;
569 virtual void put_filename(const char *filename);
573 virtual void vjustify(vunits, symbol);
577 #ifndef POPEN_MISSING
578 extern char *pipe_command;
581 extern output_file *the_output;
582 extern void init_output();
583 int in_output_page_list(int n);
592 int make_definite(int);
593 static void invalidate_fontno(int);
596 font_family *lookup_family(symbol);
597 symbol get_font_name(int, environment *);