4 /* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2003, 2004
5 Free Software Foundation, Inc.
6 Written by James Clark (jjc@jclark.com)
8 This file is part of groff.
10 groff is free software; you can redistribute it and/or modify it under
11 the terms of the GNU General Public License as published by the Free
12 Software Foundation; either version 2, or (at your option) any later
15 groff is distributed in the hope that it will be useful, but WITHOUT ANY
16 WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 You should have received a copy of the GNU General Public License along
21 with groff; see the file COPYING. If not, write to the Free Software
22 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
26 unsigned char breakable
;
27 unsigned char hyphenation_code
;
29 hyphen_list(unsigned char code
, hyphen_list
*p
= 0);
32 void hyphenate(hyphen_list
*, unsigned);
34 enum hyphenation_type
{ HYPHEN_MIDDLE
, HYPHEN_BOUNDARY
, HYPHEN_INHIBIT
};
36 class ascii_output_file
;
44 class troff_output_file
;
49 class diverted_space_node
;
61 node(node
*, statem
*, int);
62 node
*add_char(charinfo
*, environment
*, hunits
*, int *, node
** = 0);
65 virtual node
*copy() = 0;
66 virtual int set_unformat_flag();
67 virtual int force_tprint() = 0;
68 virtual int is_tag() = 0;
69 virtual hunits
width();
70 virtual hunits
subscript_correction();
71 virtual hunits
italic_correction();
72 virtual hunits
left_italic_correction();
73 virtual hunits
skew();
74 virtual int nspaces();
75 virtual int merge_space(hunits
, hunits
, hunits
);
76 virtual vunits
vertical_width();
77 virtual node
*last_char_node();
78 virtual void vertical_extent(vunits
*, vunits
*);
79 virtual int character_type();
80 virtual void set_vertical_size(vertical_size
*);
81 virtual int ends_sentence();
82 virtual node
*merge_self(node
*);
83 virtual node
*add_discretionary_hyphen();
84 virtual node
*add_self(node
*, hyphen_list
**);
85 virtual hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
86 virtual void ascii_print(ascii_output_file
*);
87 virtual void asciify(macro
*);
88 virtual int discardable();
89 virtual void spread_space(int *, hunits
*);
90 virtual void freeze_space();
91 virtual void is_escape_colon();
92 virtual breakpoint
*get_breakpoints(hunits
, int, breakpoint
* = 0, int = 0);
93 virtual int nbreaks();
94 virtual void split(int, node
**, node
**);
95 virtual hyphenation_type
get_hyphenation_type();
96 virtual int reread(int *);
97 virtual token_node
*get_token_node();
98 virtual int overlaps_vertically();
99 virtual int overlaps_horizontally();
100 virtual units
size();
101 virtual int interpret(macro
*);
103 virtual node
*merge_glyph_node(glyph_node
*);
104 virtual tfont
*get_tfont();
105 virtual color
*get_glyph_color();
106 virtual color
*get_fill_color();
107 virtual void tprint(troff_output_file
*);
108 virtual void zero_width_tprint(troff_output_file
*);
110 node
*add_italic_correction(hunits
*);
112 virtual int same(node
*) = 0;
113 virtual const char *type() = 0;
114 virtual void debug_node();
115 virtual void debug_node_list();
119 : next(0), last(0), state(0), push_state(0), div_nest_level(0), is_special(0)
123 inline node::node(node
*n
)
124 : next(n
), last(0), state(0), push_state(0), div_nest_level(0), is_special(0)
128 inline node::node(node
*n
, statem
*s
, int divlevel
)
129 : next(n
), last(0), push_state(0), div_nest_level(divlevel
), is_special(0)
132 state
= new statem(s
);
141 // 0 means it doesn't, 1 means it does, 2 means it's transparent
143 int node_list_ends_sentence(node
*);
154 class line_start_node
: public node
{
157 node
*copy() { return new line_start_node
; }
162 void asciify(macro
*);
165 class space_node
: public node
{
168 enum { BLOCK
= 1024 };
169 static space_node
*free_list
;
170 void operator delete(void *);
175 char was_escape_colon
;
176 color
*col
; /* for grotty */
177 space_node(hunits
, int, int, color
*, statem
*, int, node
* = 0);
179 space_node(hunits
, color
*, statem
*, int, node
* = 0);
180 space_node(hunits
, color
*, node
* = 0);
183 void *operator new(size_t);
189 int merge_space(hunits
, hunits
, hunits
);
191 void is_escape_colon();
192 void spread_space(int *, hunits
*);
193 void tprint(troff_output_file
*);
194 breakpoint
*get_breakpoints(hunits
, int, breakpoint
* = 0, int = 0);
196 void split(int, node
**, node
**);
197 void ascii_print(ascii_output_file
*);
199 void asciify(macro
*);
203 hyphenation_type
get_hyphenation_type();
208 hunits sentence_width
;
210 width_list(hunits
, hunits
);
211 width_list(width_list
*);
214 class word_space_node
: public space_node
{
216 width_list
*orig_width
;
217 unsigned char unformat
;
218 word_space_node(hunits
, int, color
*, width_list
*, int, statem
*, int,
221 word_space_node(hunits
, color
*, width_list
*, node
* = 0);
225 int set_unformat_flag();
226 void tprint(troff_output_file
*);
228 void asciify(macro
*);
230 int merge_space(hunits
, hunits
, hunits
);
235 class unbreakable_space_node
: public word_space_node
{
236 unbreakable_space_node(hunits
, int, color
*, statem
*, int, node
* = 0);
238 unbreakable_space_node(hunits
, color
*, node
* = 0);
241 void tprint(troff_output_file
*);
243 void asciify(macro
*);
247 breakpoint
*get_breakpoints(hunits
, int, breakpoint
* = 0, int = 0);
249 void split(int, node
**, node
**);
250 int merge_space(hunits
, hunits
, hunits
);
251 node
*add_self(node
*, hyphen_list
**);
252 hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
253 hyphenation_type
get_hyphenation_type();
256 class diverted_space_node
: public node
{
259 diverted_space_node(vunits
, node
* = 0);
260 diverted_space_node(vunits
, statem
*, int, node
* = 0);
269 class diverted_copy_file_node
: public node
{
273 diverted_copy_file_node(symbol
, node
* = 0);
274 diverted_copy_file_node(symbol
, statem
*, int, node
* = 0);
283 class extra_size_node
: public node
{
286 extra_size_node(vunits
);
287 extra_size_node(vunits
, statem
*, int);
288 void set_vertical_size(vertical_size
*);
296 class vertical_size_node
: public node
{
299 vertical_size_node(vunits
, statem
*, int);
300 vertical_size_node(vunits
);
301 void set_vertical_size(vertical_size
*);
302 void asciify(macro
*);
304 int set_unformat_flag();
311 class hmotion_node
: public node
{
314 unsigned char was_tab
;
315 unsigned char unformat
;
316 color
*col
; /* for grotty */
318 hmotion_node(hunits i
, color
*c
, node
*nxt
= 0)
319 : node(nxt
), n(i
), was_tab(0), unformat(0), col(c
) {}
320 hmotion_node(hunits i
, color
*c
, statem
*s
, int divlevel
, node
*nxt
= 0)
321 : node(nxt
, s
, divlevel
), n(i
), was_tab(0), unformat(0), col(c
) {}
322 hmotion_node(hunits i
, int flag1
, int flag2
, color
*c
, statem
*s
,
323 int divlevel
, node
*nxt
= 0)
324 : node(nxt
, s
, divlevel
), n(i
), was_tab(flag1
), unformat(flag2
),
326 hmotion_node(hunits i
, int flag1
, int flag2
, color
*c
, node
*nxt
= 0)
327 : node(nxt
), n(i
), was_tab(flag1
), unformat(flag2
), col(c
) {}
330 int set_unformat_flag();
331 void asciify(macro
*);
332 void tprint(troff_output_file
*);
334 void ascii_print(ascii_output_file
*);
339 node
*add_self(node
*, hyphen_list
**);
340 hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
341 hyphenation_type
get_hyphenation_type();
344 class space_char_hmotion_node
: public hmotion_node
{
346 space_char_hmotion_node(hunits
, color
*, node
* = 0);
347 space_char_hmotion_node(hunits
, color
*, statem
*, int, node
* = 0);
349 void ascii_print(ascii_output_file
*);
350 void asciify(macro
*);
351 void tprint(troff_output_file
*);
356 node
*add_self(node
*, hyphen_list
**);
357 hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
358 hyphenation_type
get_hyphenation_type();
361 class vmotion_node
: public node
{
363 color
*col
; /* for grotty */
365 vmotion_node(vunits
, color
*);
366 vmotion_node(vunits
, color
*, statem
*, int);
367 void tprint(troff_output_file
*);
369 vunits
vertical_width();
376 class hline_node
: public node
{
380 hline_node(hunits
, node
*, node
* = 0);
381 hline_node(hunits
, node
*, statem
*, int, node
* = 0);
385 void tprint(troff_output_file
*);
392 class vline_node
: public node
{
396 vline_node(vunits
, node
*, node
* = 0);
397 vline_node(vunits
, node
*, statem
*, int, node
* = 0);
400 void tprint(troff_output_file
*);
402 vunits
vertical_width();
403 void vertical_extent(vunits
*, vunits
*);
410 class dummy_node
: public node
{
412 dummy_node(node
*nd
= 0) : node(nd
) {}
418 hyphenation_type
get_hyphenation_type();
421 class transparent_dummy_node
: public node
{
423 transparent_dummy_node(node
*nd
= 0) : node(nd
) {}
430 hyphenation_type
get_hyphenation_type();
433 class zero_width_node
: public node
{
436 zero_width_node(node
*);
437 zero_width_node(node
*, statem
*, int);
440 void tprint(troff_output_file
*);
446 int character_type();
447 void vertical_extent(vunits
*, vunits
*);
450 class left_italic_corrected_node
: public node
{
454 left_italic_corrected_node(node
* = 0);
455 left_italic_corrected_node(statem
*, int, node
* = 0);
456 ~left_italic_corrected_node();
457 void tprint(troff_output_file
*);
458 void ascii_print(ascii_output_file
*);
459 void asciify(macro
*);
466 node
*last_char_node();
467 void vertical_extent(vunits
*, vunits
*);
469 int overlaps_horizontally();
470 int overlaps_vertically();
471 hyphenation_type
get_hyphenation_type();
473 int character_type();
475 hunits
italic_correction();
476 hunits
subscript_correction();
477 hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
478 node
*add_self(node
*, hyphen_list
**);
479 node
*merge_glyph_node(glyph_node
*);
482 class overstrike_node
: public node
{
487 overstrike_node(statem
*, int);
490 void tprint(troff_output_file
*);
491 void overstrike(node
*); // add another node to be overstruck
497 node
*add_self(node
*, hyphen_list
**);
498 hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
499 hyphenation_type
get_hyphenation_type();
502 class bracket_node
: public node
{
507 bracket_node(statem
*, int);
510 void tprint(troff_output_file
*);
511 void bracket(node
*); // add another node to be overstruck
519 class special_node
: public node
{
525 void tprint_start(troff_output_file
*);
526 void tprint_char(troff_output_file
*, unsigned char);
527 void tprint_end(troff_output_file
*);
529 special_node(const macro
&, int = 0);
530 special_node(const macro
&, tfont
*, color
*, color
*, statem
*, int,
533 void tprint(troff_output_file
*);
542 class suppress_node
: public node
{
544 int emit_limits
; // must we issue the extent of the area written out?
549 suppress_node(int, int);
550 suppress_node(symbol
, char, int);
551 suppress_node(int, int, symbol
, char, int, statem
*, int);
552 suppress_node(int, int, symbol
, char, int);
554 void tprint(troff_output_file
*);
561 void put(troff_output_file
*, const char *);
564 class tag_node
: public node
{
569 tag_node(string
, int);
570 tag_node(string
, statem
*, int, int);
572 void tprint(troff_output_file
*);
586 class draw_node
: public node
{
594 draw_node(char, hvpair
*, int, font_size
, color
*, color
*);
595 draw_node(char, hvpair
*, int, font_size
, color
*, color
*, statem
*, int);
598 vunits
vertical_width();
600 void tprint(troff_output_file
*);
608 node
*make_node(charinfo
*, environment
*);
609 int character_exists(charinfo
*, environment
*);
611 int same_node_list(node
*, node
*);
612 node
*reverse_node_list(node
*);
613 void delete_node_list(node
*);
614 node
*copy_node_list(node
*);
616 int get_bold_fontno(int);
618 inline hyphen_list::hyphen_list(unsigned char code
, hyphen_list
*p
)
619 : hyphen(0), breakable(0), hyphenation_code(code
), next(p
)
623 extern void read_desc();
624 extern int mount_font(int, symbol
, symbol
= NULL_SYMBOL
);
625 extern int check_font(symbol
, symbol
);
626 extern int check_style(symbol
);
627 extern void mount_style(int, symbol
);
628 extern int is_good_fontno(int);
629 extern int symbol_fontno(symbol
);
630 extern int next_available_font_position();
631 extern void init_size_table(int *);
632 extern int get_underline_fontno();
635 char make_g_plus_plus_shut_up
;
638 virtual ~output_file();
639 virtual void trailer(vunits
);
640 virtual void flush() = 0;
641 virtual void transparent_char(unsigned char) = 0;
642 virtual void print_line(hunits x
, vunits y
, node
*n
,
643 vunits before
, vunits after
, hunits width
) = 0;
644 virtual void begin_page(int pageno
, vunits page_length
) = 0;
645 virtual void copy_file(hunits x
, vunits y
, const char *filename
) = 0;
646 virtual int is_printing() = 0;
647 virtual void put_filename(const char *);
651 virtual void vjustify(vunits
, symbol
);
656 #ifndef POPEN_MISSING
657 extern char *pipe_command
;
660 extern output_file
*the_output
;
661 extern void init_output();
662 int in_output_page_list(int);
671 int make_definite(int);
672 static void invalidate_fontno(int);
675 font_family
*lookup_family(symbol
);
676 symbol
get_font_name(int, environment
*);
677 symbol
get_style_name(int);
678 extern search_path include_search_path
;