2 /* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002, 2004, 2005, 2009
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 3 of the License, or
11 (at your option) any later version.
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
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 void do_divert(int append, int boxing);
22 void end_diversions();
26 friend void do_divert(int append, int boxing);
27 friend void end_diversions();
30 hunits saved_width_total;
31 int saved_space_total;
32 hunits saved_saved_indent;
33 hunits saved_target_text_length;
34 int saved_prev_line_interrupted;
37 vunits vertical_position;
38 vunits high_water_mark;
46 int saved_suppress_next_eol;
47 state_set modified_tag;
49 diversion(symbol s = NULL_SYMBOL);
51 virtual void output(node *nd, int retain_size, vunits vs, vunits post_vs,
53 virtual void transparent_output(unsigned char) = 0;
54 virtual void transparent_output(node *) = 0;
55 virtual void space(vunits distance, int forced = 0) = 0;
57 virtual void vjustify(symbol) = 0;
59 vunits get_vertical_position() { return vertical_position; }
60 vunits get_high_water_mark() { return high_water_mark; }
61 virtual vunits distance_to_next_trap() = 0;
63 const char *get_diversion_name() { return nm.contents(); }
64 virtual void set_diversion_trap(symbol, vunits) = 0;
65 virtual void clear_diversion_trap() = 0;
66 virtual void copy_file(const char *filename) = 0;
67 virtual int is_diversion() = 0;
72 class macro_diversion : public diversion {
75 symbol diversion_trap;
76 vunits diversion_trap_pos;
78 macro_diversion(symbol, int);
80 void output(node *nd, int retain_size, vunits vs, vunits post_vs,
82 void transparent_output(unsigned char);
83 void transparent_output(node *);
84 void space(vunits distance, int forced = 0);
86 void vjustify(symbol);
88 vunits distance_to_next_trap();
89 void set_diversion_trap(symbol, vunits);
90 void clear_diversion_trap();
91 void copy_file(const char *filename);
92 int is_diversion() { return 1; }
99 trap(symbol, vunits, trap *);
104 class top_level_diversion : public diversion {
109 hunits prev_page_offset;
111 trap *page_trap_list;
112 trap *find_next_trap(vunits *);
113 int have_next_page_number;
114 int next_page_number;
115 int ejecting_page; // Is the current page being ejected?
117 int before_first_page;
118 top_level_diversion();
119 void output(node *nd, int retain_size, vunits vs, vunits post_vs,
121 void transparent_output(unsigned char);
122 void transparent_output(node *);
123 void space(vunits distance, int forced = 0);
125 void vjustify(symbol);
127 hunits get_page_offset() { return page_offset; }
128 vunits get_page_length() { return page_length; }
129 vunits distance_to_next_trap();
130 void add_trap(symbol nm, vunits pos);
131 void change_trap(symbol nm, vunits pos);
132 void remove_trap(symbol);
133 void remove_trap_at(vunits pos);
135 int get_page_count() { return page_count; }
136 int get_page_number() { return page_number; }
137 int get_next_page_number();
138 void set_page_number(int n) { page_number = n; }
139 int begin_page(vunits = V0);
140 void set_next_page_number(int);
141 void set_page_length(vunits);
142 void copy_file(const char *filename);
143 int get_ejecting() { return ejecting_page; }
144 void set_ejecting() { ejecting_page = 1; }
145 friend void page_offset();
146 void set_diversion_trap(symbol, vunits);
147 void clear_diversion_trap();
148 void set_last_page() { last_page_count = page_count; }
149 int is_diversion() { return 0; }
152 extern top_level_diversion *topdiv;
153 extern diversion *curdiv;
155 extern int exit_started;
156 extern int done_end_macro;
157 extern int last_page_number;
158 extern int seen_last_page_ejector;
160 void spring_trap(symbol); // implemented by input.c
161 extern int trap_sprung_flag;
162 void postpone_traps();
163 int unpostpone_traps();
165 void push_page_ejector();
166 void continue_page_eject();
167 void handle_first_page_transition();
171 extern void cleanup_and_exit(int);