2 /* Copyright (C) 1989, 1990, 1991, 1992, 2001 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
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 along
18 with groff; see the file COPYING. If not, write to the Free Software
19 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22 friend void do_divert(int append, int boxing);
23 friend void end_diversions();
26 hunits saved_width_total;
27 int saved_space_total;
28 hunits saved_saved_indent;
29 hunits saved_target_text_length;
30 int saved_prev_line_interrupted;
33 vunits vertical_position;
34 vunits high_water_mark;
38 diversion(symbol s = NULL_SYMBOL);
40 virtual void output(node *nd, int retain_size, vunits vs, vunits post_vs,
42 virtual void transparent_output(unsigned char) = 0;
43 virtual void transparent_output(node *) = 0;
44 virtual void space(vunits distance, int forced = 0) = 0;
46 virtual void vjustify(symbol) = 0;
48 vunits get_vertical_position() { return vertical_position; }
49 vunits get_high_water_mark() { return high_water_mark; }
50 virtual vunits distance_to_next_trap() = 0;
52 const char *get_diversion_name() { return nm.contents(); }
53 virtual void set_diversion_trap(symbol, vunits) = 0;
54 virtual void clear_diversion_trap() = 0;
55 virtual void copy_file(const char *filename) = 0;
60 class macro_diversion : public diversion {
63 symbol diversion_trap;
64 vunits diversion_trap_pos;
66 macro_diversion(symbol, int);
68 void output(node *nd, int retain_size, vunits vs, vunits post_vs,
70 void transparent_output(unsigned char);
71 void transparent_output(node *);
72 void space(vunits distance, int forced = 0);
74 void vjustify(symbol);
76 vunits distance_to_next_trap();
77 void set_diversion_trap(symbol, vunits);
78 void clear_diversion_trap();
79 void copy_file(const char *filename);
86 trap(symbol, vunits, trap *);
91 class top_level_diversion : public diversion {
96 hunits prev_page_offset;
99 trap *find_next_trap(vunits *);
100 int have_next_page_number;
101 int next_page_number;
102 int ejecting_page; // Is the current page being ejected?
104 int before_first_page;
105 top_level_diversion();
106 void output(node *nd, int retain_size, vunits vs, vunits post_vs,
108 void transparent_output(unsigned char);
109 void transparent_output(node *);
110 void space(vunits distance, int forced = 0);
112 void vjustify(symbol);
114 hunits get_page_offset() { return page_offset; }
115 vunits get_page_length() { return page_length; }
116 vunits distance_to_next_trap();
117 void add_trap(symbol nm, vunits pos);
118 void change_trap(symbol nm, vunits pos);
119 void remove_trap(symbol);
120 void remove_trap_at(vunits pos);
122 int get_page_count() { return page_count; }
123 int get_page_number() { return page_number; }
124 int get_next_page_number();
125 void set_page_number(int n) { page_number = n; }
127 void set_next_page_number(int);
128 void set_page_length(vunits);
129 void copy_file(const char *filename);
130 int get_ejecting() { return ejecting_page; }
131 void set_ejecting() { ejecting_page = 1; }
132 friend void page_offset();
133 void set_diversion_trap(symbol, vunits);
134 void clear_diversion_trap();
135 void set_last_page() { last_page_count = page_count; }
138 extern top_level_diversion *topdiv;
139 extern diversion *curdiv;
141 extern int exit_started;
142 extern int done_end_macro;
143 extern int last_page_number;
144 extern int seen_last_page_ejector;
146 void spring_trap(symbol); // implemented by input.c
147 extern int trap_sprung_flag;
148 void postpone_traps();
149 int unpostpone_traps();
151 void push_page_ejector();
152 void continue_page_eject();
153 void handle_first_page_transition();
156 void end_diversions();
158 extern void cleanup_and_exit(int);