* src/roff/troff/env.cpp (hyphen_trie::read_patterns_file): Fix loop
[s-roff.git] / src / roff / troff / div.h
blobbde41a8f85416cbe1740bc223928aaf8de3f5e7a
1 // -*- C++ -*-
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
11 version.
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
16 for more details.
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. */
22 class diversion {
23 friend void do_divert(int append, int boxing);
24 friend void end_diversions();
25 diversion *prev;
26 node *saved_line;
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;
32 protected:
33 symbol nm;
34 vunits vertical_position;
35 vunits high_water_mark;
36 public:
37 int no_space_mode;
38 vunits marked_place;
39 diversion(symbol s = NULL_SYMBOL);
40 virtual ~diversion();
41 virtual void output(node *nd, int retain_size, vunits vs, vunits post_vs,
42 hunits width) = 0;
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;
46 #ifdef COLUMN
47 virtual void vjustify(symbol) = 0;
48 #endif /* COLUMN */
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;
52 void need(vunits);
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;
59 class macro;
61 class macro_diversion : public diversion {
62 macro *mac;
63 hunits max_width;
64 symbol diversion_trap;
65 vunits diversion_trap_pos;
66 public:
67 macro_diversion(symbol, int);
68 ~macro_diversion();
69 void output(node *nd, int retain_size, vunits vs, vunits post_vs,
70 hunits width);
71 void transparent_output(unsigned char);
72 void transparent_output(node *);
73 void space(vunits distance, int forced = 0);
74 #ifdef COLUMN
75 void vjustify(symbol);
76 #endif /* COLUMN */
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);
83 struct trap {
84 trap *next;
85 vunits position;
86 symbol nm;
87 trap(symbol, vunits, trap *);
90 struct output_file;
92 class top_level_diversion : public diversion {
93 int page_number;
94 int page_count;
95 int last_page_count;
96 vunits page_length;
97 hunits prev_page_offset;
98 hunits page_offset;
99 trap *page_trap_list;
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?
104 public:
105 int before_first_page;
106 top_level_diversion();
107 void output(node *nd, int retain_size, vunits vs, vunits post_vs,
108 hunits width);
109 void transparent_output(unsigned char);
110 void transparent_output(node *);
111 void space(vunits distance, int forced = 0);
112 #ifdef COLUMN
113 void vjustify(symbol);
114 #endif /* COLUMN */
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);
122 void print_traps();
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();
155 void blank_line();
156 void begin_page();
157 void end_diversions();
159 extern void cleanup_and_exit(int);