1/* $NetBSD: div.h,v 1.1.1.1 2016/01/13 18:41:48 christos Exp $ */ 2 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) 7 8This file is part of groff. 9 10groff is free software; you can redistribute it and/or modify it under 11the terms of the GNU General Public License as published by the Free 12Software Foundation; either version 2, or (at your option) any later 13version. 14 15groff is distributed in the hope that it will be useful, but WITHOUT ANY 16WARRANTY; without even the implied warranty of MERCHANTABILITY or 17FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 18for more details. 19 20You should have received a copy of the GNU General Public License along 21with groff; see the file COPYING. If not, write to the Free Software 22Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */ 23 24void do_divert(int append, int boxing); 25void end_diversions(); 26void page_offset(); 27 28class 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; 38protected: 39 symbol nm; 40 vunits vertical_position; 41 vunits high_water_mark; 42public: 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; 71}; 72 73class macro; 74 75class macro_diversion : public diversion { 76 macro *mac; 77 hunits max_width; 78 symbol diversion_trap; 79 vunits diversion_trap_pos; 80public: 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; } 96}; 97 98struct trap { 99 trap *next; 100 vunits position; 101 symbol nm; 102 trap(symbol, vunits, trap *); 103}; 104 105class output_file; 106 107class 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? 119public: 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; } 153}; 154 155extern top_level_diversion *topdiv; 156extern diversion *curdiv; 157 158extern int exit_started; 159extern int done_end_macro; 160extern int last_page_number; 161extern int seen_last_page_ejector; 162 163void spring_trap(symbol); // implemented by input.c 164extern int trap_sprung_flag; 165void postpone_traps(); 166int unpostpone_traps(); 167 168void push_page_ejector(); 169void continue_page_eject(); 170void handle_first_page_transition(); 171void blank_line(); 172void begin_page(); 173 174extern void cleanup_and_exit(int); 175