No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / groff / src / roff / troff / div.h
blob0548d820d77d0e9bf005ebdb4966d66a0c4c7732
1 /* $NetBSD$ */
3 // -*- C++ -*-
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
13 version.
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
18 for more details.
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();
26 void page_offset();
28 class diversion {
29 friend void do_divert(int append, int boxing);
30 friend void end_diversions();
31 diversion *prev;
32 node *saved_line;
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;
38 protected:
39 symbol nm;
40 vunits vertical_position;
41 vunits high_water_mark;
42 public:
43 int any_chars_added;
44 int no_space_mode;
45 int needs_push;
46 int saved_seen_break;
47 int saved_seen_space;
48 int saved_seen_eol;
49 int saved_suppress_next_eol;
50 state_set modified_tag;
51 vunits marked_place;
52 diversion(symbol s = NULL_SYMBOL);
53 virtual ~diversion();
54 virtual void output(node *nd, int retain_size, vunits vs, vunits post_vs,
55 hunits width) = 0;
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;
59 #ifdef COLUMN
60 virtual void vjustify(symbol) = 0;
61 #endif /* COLUMN */
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;
65 void need(vunits);
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;
73 class macro;
75 class macro_diversion : public diversion {
76 macro *mac;
77 hunits max_width;
78 symbol diversion_trap;
79 vunits diversion_trap_pos;
80 public:
81 macro_diversion(symbol, int);
82 ~macro_diversion();
83 void output(node *nd, int retain_size, vunits vs, vunits post_vs,
84 hunits width);
85 void transparent_output(unsigned char);
86 void transparent_output(node *);
87 void space(vunits distance, int forced = 0);
88 #ifdef COLUMN
89 void vjustify(symbol);
90 #endif /* COLUMN */
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; }
98 struct trap {
99 trap *next;
100 vunits position;
101 symbol nm;
102 trap(symbol, vunits, trap *);
105 class output_file;
107 class top_level_diversion : public diversion {
108 int page_number;
109 int page_count;
110 int last_page_count;
111 vunits page_length;
112 hunits prev_page_offset;
113 hunits 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?
119 public:
120 int before_first_page;
121 top_level_diversion();
122 void output(node *nd, int retain_size, vunits vs, vunits post_vs,
123 hunits width);
124 void transparent_output(unsigned char);
125 void transparent_output(node *);
126 void space(vunits distance, int forced = 0);
127 #ifdef COLUMN
128 void vjustify(symbol);
129 #endif /* COLUMN */
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);
137 void print_traps();
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();
171 void blank_line();
172 void begin_page();
174 extern void cleanup_and_exit(int);