2 * Copyright (c) 2014 - 2017 Steffen (Daode) Nurpmeso <steffen@sdaoden.eu>.
4 * Copyright (C) 1989 - 1992, 2001, 2002, 2004, 2005
5 * Free Software Foundation, Inc.
6 * Written by James Clark (jjc@jclark.com)
8 * This 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 * This 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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.
26 #include "troff-config.h"
28 void do_divert(int append
, int boxing
);
29 void end_diversions();
34 friend void do_divert(int append
, int boxing
);
35 friend void end_diversions();
39 hunits saved_width_total
;
40 int saved_space_total
;
41 hunits saved_saved_indent
;
42 hunits saved_target_text_length
;
43 int saved_prev_line_interrupted
;
47 vunits vertical_position
;
48 vunits high_water_mark
;
57 int saved_suppress_next_eol
;
58 state_set modified_tag
;
61 diversion(symbol s
= NULL_SYMBOL
);
63 virtual void output(node
*nd
, int retain_size
, vunits vs
, vunits post_vs
,
65 virtual void transparent_output(unsigned char) = 0;
66 virtual void transparent_output(node
*) = 0;
67 virtual void space(vunits distance
, int forced
= 0) = 0;
69 virtual void vjustify(symbol
) = 0;
71 vunits
get_vertical_position() { return vertical_position
; }
72 vunits
get_high_water_mark() { return high_water_mark
; }
73 virtual vunits
distance_to_next_trap() = 0;
75 const char *get_diversion_name() { return nm
.contents(); }
76 virtual void set_diversion_trap(symbol
, vunits
) = 0;
77 virtual void clear_diversion_trap() = 0;
78 virtual void copy_file(const char *filename
) = 0;
79 virtual int is_diversion() = 0;
89 symbol diversion_trap
;
90 vunits diversion_trap_pos
;
93 macro_diversion(symbol
, int);
95 void output(node
*nd
, int retain_size
, vunits vs
, vunits post_vs
,
97 void transparent_output(unsigned char);
98 void transparent_output(node
*);
99 void space(vunits distance
, int forced
= 0);
101 void vjustify(symbol
);
103 vunits
distance_to_next_trap();
104 void set_diversion_trap(symbol
, vunits
);
105 void clear_diversion_trap();
106 void copy_file(const char *filename
);
107 int is_diversion() { return 1; }
117 trap(symbol
, vunits
, trap
*);
122 class top_level_diversion
129 hunits prev_page_offset
;
131 trap
*page_trap_list
;
132 int have_next_page_number
;
133 int next_page_number
;
134 int ejecting_page
; // Is the current page being ejected?
136 trap
*find_next_trap(vunits
*);
139 int before_first_page
;
140 top_level_diversion();
142 void output(node
*nd
, int retain_size
, vunits vs
, vunits post_vs
,
144 void transparent_output(unsigned char);
145 void transparent_output(node
*);
146 void space(vunits distance
, int forced
= 0);
148 void vjustify(symbol
);
150 hunits
get_page_offset() { return page_offset
; }
151 vunits
get_page_length() { return page_length
; }
152 vunits
distance_to_next_trap();
153 void add_trap(symbol nm
, vunits pos
);
154 void change_trap(symbol nm
, vunits pos
);
155 void remove_trap(symbol
);
156 void remove_trap_at(vunits pos
);
158 int get_page_count() { return page_count
; }
159 int get_page_number() { return page_number
; }
160 int get_next_page_number();
161 void set_page_number(int n
) { page_number
= n
; }
162 int begin_page(vunits
= V0
);
163 void set_next_page_number(int);
164 void set_page_length(vunits
);
165 void copy_file(const char *filename
);
166 int get_ejecting() { return ejecting_page
; }
167 void set_ejecting() { ejecting_page
= 1; }
168 friend void page_offset();
169 void set_diversion_trap(symbol
, vunits
);
170 void clear_diversion_trap();
171 void set_last_page() { last_page_count
= page_count
; }
172 int is_diversion() { return 0; }
175 extern top_level_diversion
*topdiv
;
176 extern diversion
*curdiv
;
178 extern int exit_started
;
179 extern int done_end_macro
;
180 extern int last_page_number
;
181 extern int seen_last_page_ejector
;
183 void spring_trap(symbol
); // implemented by input.c
184 extern int trap_sprung_flag
;
185 void postpone_traps();
186 int unpostpone_traps();
188 void push_page_ejector();
189 void continue_page_eject();
190 void handle_first_page_transition();
194 extern void cleanup_and_exit(int);