2 /* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002
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 2, or (at your option) any later
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 along
19 with groff; see the file COPYING. If not, write to the Free Software
20 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
23 friend void do_divert(int append
, int boxing
);
24 friend void end_diversions();
27 hunits saved_width_total
;
28 int saved_space_total
;
29 hunits saved_saved_indent
;
30 hunits saved_target_text_length
;
31 int saved_prev_line_interrupted
;
34 vunits vertical_position
;
35 vunits high_water_mark
;
39 diversion(symbol s
= NULL_SYMBOL
);
41 virtual void output(node
*nd
, int retain_size
, vunits vs
, vunits post_vs
,
43 virtual void transparent_output(unsigned char) = 0;
44 virtual void transparent_output(node
*) = 0;
45 virtual void space(vunits distance
, int forced
= 0) = 0;
47 virtual void vjustify(symbol
) = 0;
49 vunits
get_vertical_position() { return vertical_position
; }
50 vunits
get_high_water_mark() { return high_water_mark
; }
51 virtual vunits
distance_to_next_trap() = 0;
53 const char *get_diversion_name() { return nm
.contents(); }
54 virtual void set_diversion_trap(symbol
, vunits
) = 0;
55 virtual void clear_diversion_trap() = 0;
56 virtual void copy_file(const char *filename
) = 0;
61 class macro_diversion
: public diversion
{
64 symbol diversion_trap
;
65 vunits diversion_trap_pos
;
67 macro_diversion(symbol
, int);
69 void output(node
*nd
, int retain_size
, vunits vs
, vunits post_vs
,
71 void transparent_output(unsigned char);
72 void transparent_output(node
*);
73 void space(vunits distance
, int forced
= 0);
75 void vjustify(symbol
);
77 vunits
distance_to_next_trap();
78 void set_diversion_trap(symbol
, vunits
);
79 void clear_diversion_trap();
80 void copy_file(const char *filename
);
87 trap(symbol
, vunits
, trap
*);
92 class top_level_diversion
: public diversion
{
97 hunits prev_page_offset
;
100 trap
*find_next_trap(vunits
*);
101 int have_next_page_number
;
102 int next_page_number
;
103 int ejecting_page
; // Is the current page being ejected?
105 int before_first_page
;
106 top_level_diversion();
107 void output(node
*nd
, int retain_size
, vunits vs
, vunits post_vs
,
109 void transparent_output(unsigned char);
110 void transparent_output(node
*);
111 void space(vunits distance
, int forced
= 0);
113 void vjustify(symbol
);
115 hunits
get_page_offset() { return page_offset
; }
116 vunits
get_page_length() { return page_length
; }
117 vunits
distance_to_next_trap();
118 void add_trap(symbol nm
, vunits pos
);
119 void change_trap(symbol nm
, vunits pos
);
120 void remove_trap(symbol
);
121 void remove_trap_at(vunits pos
);
123 int get_page_count() { return page_count
; }
124 int get_page_number() { return page_number
; }
125 int get_next_page_number();
126 void set_page_number(int n
) { page_number
= n
; }
127 int begin_page(vunits
= V0
);
128 void set_next_page_number(int);
129 void set_page_length(vunits
);
130 void copy_file(const char *filename
);
131 int get_ejecting() { return ejecting_page
; }
132 void set_ejecting() { ejecting_page
= 1; }
133 friend void page_offset();
134 void set_diversion_trap(symbol
, vunits
);
135 void clear_diversion_trap();
136 void set_last_page() { last_page_count
= page_count
; }
139 extern top_level_diversion
*topdiv
;
140 extern diversion
*curdiv
;
142 extern int exit_started
;
143 extern int done_end_macro
;
144 extern int last_page_number
;
145 extern int seen_last_page_ejector
;
147 void spring_trap(symbol
); // implemented by input.c
148 extern int trap_sprung_flag
;
149 void postpone_traps();
150 int unpostpone_traps();
152 void push_page_ejector();
153 void continue_page_eject();
154 void handle_first_page_transition();
157 void end_diversions();
159 extern void cleanup_and_exit(int);