2 /* Copyright (C) 1989-2014 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/>. */
20 void do_divert(int append, int boxing);
21 void end_diversions();
25 friend void do_divert(int append, int boxing);
26 friend void end_diversions();
29 hunits saved_width_total;
30 int saved_space_total;
31 hunits saved_saved_indent;
32 hunits saved_target_text_length;
33 int saved_prev_line_interrupted;
36 vunits vertical_position;
37 vunits high_water_mark;
45 int saved_suppress_next_eol;
46 state_set modified_tag;
48 diversion(symbol s = NULL_SYMBOL);
50 virtual void output(node *nd, int retain_size, vunits vs, vunits post_vs,
52 virtual void transparent_output(unsigned char) = 0;
53 virtual void transparent_output(node *) = 0;
54 virtual void space(vunits distance, int forced = 0) = 0;
56 virtual void vjustify(symbol) = 0;
58 vunits get_vertical_position() { return vertical_position; }
59 vunits get_high_water_mark() { return high_water_mark; }
60 virtual vunits distance_to_next_trap() = 0;
62 const char *get_diversion_name() { return nm.contents(); }
63 virtual void set_diversion_trap(symbol, vunits) = 0;
64 virtual void clear_diversion_trap() = 0;
65 virtual void copy_file(const char *filename) = 0;
66 virtual int is_diversion() = 0;
71 class macro_diversion : public diversion {
74 symbol diversion_trap;
75 vunits diversion_trap_pos;
77 macro_diversion(symbol, int);
79 void output(node *nd, int retain_size, vunits vs, vunits post_vs,
81 void transparent_output(unsigned char);
82 void transparent_output(node *);
83 void space(vunits distance, int forced = 0);
85 void vjustify(symbol);
87 vunits distance_to_next_trap();
88 void set_diversion_trap(symbol, vunits);
89 void clear_diversion_trap();
90 void copy_file(const char *filename);
91 int is_diversion() { return 1; }
98 trap(symbol, vunits, trap *);
103 class top_level_diversion : public diversion {
108 hunits prev_page_offset;
110 trap *page_trap_list;
111 trap *find_next_trap(vunits *);
112 int have_next_page_number;
113 int next_page_number;
114 int ejecting_page; // Is the current page being ejected?
116 int before_first_page;
117 top_level_diversion();
118 void output(node *nd, int retain_size, vunits vs, vunits post_vs,
120 void transparent_output(unsigned char);
121 void transparent_output(node *);
122 void space(vunits distance, int forced = 0);
124 void vjustify(symbol);
126 hunits get_page_offset() { return page_offset; }
127 vunits get_page_length() { return page_length; }
128 vunits distance_to_next_trap();
129 void add_trap(symbol nm, vunits pos);
130 void change_trap(symbol nm, vunits pos);
131 void remove_trap(symbol);
132 void remove_trap_at(vunits pos);
134 int get_page_count() { return page_count; }
135 int get_page_number() { return page_number; }
136 int get_next_page_number();
137 void set_page_number(int n) { page_number = n; }
138 int begin_page(vunits = V0);
139 void set_next_page_number(int);
140 void set_page_length(vunits);
141 void copy_file(const char *filename);
142 int get_ejecting() { return ejecting_page; }
143 void set_ejecting() { ejecting_page = 1; }
144 friend void page_offset();
145 void set_diversion_trap(symbol, vunits);
146 void clear_diversion_trap();
147 void set_last_page() { last_page_count = page_count; }
148 int is_diversion() { return 0; }
151 extern top_level_diversion *topdiv;
152 extern diversion *curdiv;
154 extern int exit_started;
155 extern int done_end_macro;
156 extern int last_page_number;
157 extern int seen_last_page_ejector;
159 void spring_trap(symbol); // implemented by input.c
160 extern int trap_sprung_flag;
161 void postpone_traps();
162 int unpostpone_traps();
164 void push_page_ejector();
165 void continue_page_eject();
166 void handle_first_page_transition();
170 extern void cleanup_and_exit(int);