div.h revision 114402
1// -*- C++ -*- 2/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002 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 10Software Foundation; either version 2, or (at your option) any later 11version. 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 18You should have received a copy of the GNU General Public License along 19with groff; see the file COPYING. If not, write to the Free Software 20Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 21 22class 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; 32protected: 33 symbol nm; 34 vunits vertical_position; 35 vunits high_water_mark; 36public: 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; 57}; 58 59class macro; 60 61class macro_diversion : public diversion { 62 macro *mac; 63 hunits max_width; 64 symbol diversion_trap; 65 vunits diversion_trap_pos; 66public: 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); 81}; 82 83struct trap { 84 trap *next; 85 vunits position; 86 symbol nm; 87 trap(symbol, vunits, trap *); 88}; 89 90struct output_file; 91 92class 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? 104public: 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; } 137}; 138 139extern top_level_diversion *topdiv; 140extern diversion *curdiv; 141 142extern int exit_started; 143extern int done_end_macro; 144extern int last_page_number; 145extern int seen_last_page_ejector; 146 147void spring_trap(symbol); // implemented by input.c 148extern int trap_sprung_flag; 149void postpone_traps(); 150int unpostpone_traps(); 151 152void push_page_ejector(); 153void continue_page_eject(); 154void handle_first_page_transition(); 155void blank_line(); 156void begin_page(); 157void end_diversions(); 158 159extern void cleanup_and_exit(int); 160