4 /* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002, 2004, 2005
5 Free Software Foundation, Inc.
6 Written by James Clark (jjc@jclark.com)
8 This file is part of groff.
10 groff is free software; you can redistribute it and/or modify it under
11 the terms of the GNU General Public License as published by the Free
12 Software Foundation; either version 2, or (at your option) any later
15 groff is distributed in the hope that it will be useful, but WITHOUT ANY
16 WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 You should have received a copy of the GNU General Public License along
21 with groff; see the file COPYING. If not, write to the Free Software
22 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
24 void do_divert(int append
, int boxing
);
25 void end_diversions();
29 friend void do_divert(int append
, int boxing
);
30 friend void end_diversions();
33 hunits saved_width_total
;
34 int saved_space_total
;
35 hunits saved_saved_indent
;
36 hunits saved_target_text_length
;
37 int saved_prev_line_interrupted
;
40 vunits vertical_position
;
41 vunits high_water_mark
;
49 int saved_suppress_next_eol
;
50 state_set modified_tag
;
52 diversion(symbol s
= NULL_SYMBOL
);
54 virtual void output(node
*nd
, int retain_size
, vunits vs
, vunits post_vs
,
56 virtual void transparent_output(unsigned char) = 0;
57 virtual void transparent_output(node
*) = 0;
58 virtual void space(vunits distance
, int forced
= 0) = 0;
60 virtual void vjustify(symbol
) = 0;
62 vunits
get_vertical_position() { return vertical_position
; }
63 vunits
get_high_water_mark() { return high_water_mark
; }
64 virtual vunits
distance_to_next_trap() = 0;
66 const char *get_diversion_name() { return nm
.contents(); }
67 virtual void set_diversion_trap(symbol
, vunits
) = 0;
68 virtual void clear_diversion_trap() = 0;
69 virtual void copy_file(const char *filename
) = 0;
70 virtual int is_diversion() = 0;
75 class macro_diversion
: public diversion
{
78 symbol diversion_trap
;
79 vunits diversion_trap_pos
;
81 macro_diversion(symbol
, int);
83 void output(node
*nd
, int retain_size
, vunits vs
, vunits post_vs
,
85 void transparent_output(unsigned char);
86 void transparent_output(node
*);
87 void space(vunits distance
, int forced
= 0);
89 void vjustify(symbol
);
91 vunits
distance_to_next_trap();
92 void set_diversion_trap(symbol
, vunits
);
93 void clear_diversion_trap();
94 void copy_file(const char *filename
);
95 int is_diversion() { return 1; }
102 trap(symbol
, vunits
, trap
*);
107 class top_level_diversion
: public diversion
{
112 hunits prev_page_offset
;
114 trap
*page_trap_list
;
115 trap
*find_next_trap(vunits
*);
116 int have_next_page_number
;
117 int next_page_number
;
118 int ejecting_page
; // Is the current page being ejected?
120 int before_first_page
;
121 top_level_diversion();
122 void output(node
*nd
, int retain_size
, vunits vs
, vunits post_vs
,
124 void transparent_output(unsigned char);
125 void transparent_output(node
*);
126 void space(vunits distance
, int forced
= 0);
128 void vjustify(symbol
);
130 hunits
get_page_offset() { return page_offset
; }
131 vunits
get_page_length() { return page_length
; }
132 vunits
distance_to_next_trap();
133 void add_trap(symbol nm
, vunits pos
);
134 void change_trap(symbol nm
, vunits pos
);
135 void remove_trap(symbol
);
136 void remove_trap_at(vunits pos
);
138 int get_page_count() { return page_count
; }
139 int get_page_number() { return page_number
; }
140 int get_next_page_number();
141 void set_page_number(int n
) { page_number
= n
; }
142 int begin_page(vunits
= V0
);
143 void set_next_page_number(int);
144 void set_page_length(vunits
);
145 void copy_file(const char *filename
);
146 int get_ejecting() { return ejecting_page
; }
147 void set_ejecting() { ejecting_page
= 1; }
148 friend void page_offset();
149 void set_diversion_trap(symbol
, vunits
);
150 void clear_diversion_trap();
151 void set_last_page() { last_page_count
= page_count
; }
152 int is_diversion() { return 0; }
155 extern top_level_diversion
*topdiv
;
156 extern diversion
*curdiv
;
158 extern int exit_started
;
159 extern int done_end_macro
;
160 extern int last_page_number
;
161 extern int seen_last_page_ejector
;
163 void spring_trap(symbol
); // implemented by input.c
164 extern int trap_sprung_flag
;
165 void postpone_traps();
166 int unpostpone_traps();
168 void push_page_ejector();
169 void continue_page_eject();
170 void handle_first_page_transition();
174 extern void cleanup_and_exit(int);