groff: update vendor branch to v1.20.1
[dragonfly.git] / contrib / groff / src / roff / troff / div.h
CommitLineData
92d0a6a6 1// -*- C++ -*-
4d3e9548 2/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002, 2004, 2005, 2009
92d0a6a6
JR
3 Free Software Foundation, Inc.
4 Written by James Clark (jjc@jclark.com)
5
6This file is part of groff.
7
8groff is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free
4d3e9548
JL
10Software Foundation, either version 3 of the License, or
11(at your option) any later version.
92d0a6a6
JR
12
13groff is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16for more details.
17
4d3e9548
JL
18You should have received a copy of the GNU General Public License
19along with this program. If not, see <http://www.gnu.org/licenses/>. */
465b256c
JR
20
21void do_divert(int append, int boxing);
22void end_diversions();
23void page_offset();
92d0a6a6
JR
24
25class diversion {
26 friend void do_divert(int append, int boxing);
27 friend void end_diversions();
28 diversion *prev;
29 node *saved_line;
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;
35protected:
36 symbol nm;
37 vunits vertical_position;
38 vunits high_water_mark;
39public:
465b256c 40 int any_chars_added;
92d0a6a6 41 int no_space_mode;
465b256c
JR
42 int needs_push;
43 int saved_seen_break;
44 int saved_seen_space;
45 int saved_seen_eol;
46 int saved_suppress_next_eol;
47 state_set modified_tag;
92d0a6a6
JR
48 vunits marked_place;
49 diversion(symbol s = NULL_SYMBOL);
50 virtual ~diversion();
51 virtual void output(node *nd, int retain_size, vunits vs, vunits post_vs,
52 hunits width) = 0;
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;
56#ifdef COLUMN
57 virtual void vjustify(symbol) = 0;
58#endif /* COLUMN */
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;
62 void need(vunits);
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;
465b256c 67 virtual int is_diversion() = 0;
92d0a6a6
JR
68};
69
70class macro;
71
72class macro_diversion : public diversion {
73 macro *mac;
74 hunits max_width;
75 symbol diversion_trap;
76 vunits diversion_trap_pos;
77public:
78 macro_diversion(symbol, int);
79 ~macro_diversion();
80 void output(node *nd, int retain_size, vunits vs, vunits post_vs,
81 hunits width);
82 void transparent_output(unsigned char);
83 void transparent_output(node *);
84 void space(vunits distance, int forced = 0);
85#ifdef COLUMN
86 void vjustify(symbol);
87#endif /* COLUMN */
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);
465b256c 92 int is_diversion() { return 1; }
92d0a6a6
JR
93};
94
95struct trap {
96 trap *next;
97 vunits position;
98 symbol nm;
99 trap(symbol, vunits, trap *);
100};
101
102class output_file;
103
104class top_level_diversion : public diversion {
105 int page_number;
106 int page_count;
107 int last_page_count;
108 vunits page_length;
109 hunits prev_page_offset;
110 hunits 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?
116public:
117 int before_first_page;
118 top_level_diversion();
119 void output(node *nd, int retain_size, vunits vs, vunits post_vs,
120 hunits width);
121 void transparent_output(unsigned char);
122 void transparent_output(node *);
123 void space(vunits distance, int forced = 0);
124#ifdef COLUMN
125 void vjustify(symbol);
126#endif /* COLUMN */
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);
134 void print_traps();
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; }
465b256c 149 int is_diversion() { return 0; }
92d0a6a6
JR
150};
151
152extern top_level_diversion *topdiv;
153extern diversion *curdiv;
154
155extern int exit_started;
156extern int done_end_macro;
157extern int last_page_number;
158extern int seen_last_page_ejector;
159
160void spring_trap(symbol); // implemented by input.c
161extern int trap_sprung_flag;
162void postpone_traps();
163int unpostpone_traps();
164
165void push_page_ejector();
166void continue_page_eject();
167void handle_first_page_transition();
168void blank_line();
169void begin_page();
170
171extern void cleanup_and_exit(int);