home *** CD-ROM | disk | FTP | other *** search
/ Aminet 10 / aminetcdnumber101996.iso / Aminet / util / gnu / groff_src.lha / groff-1.10src / troff / div.h < prev    next >
C/C++ Source or Header  |  1995-06-22  |  5KB  |  151 lines

  1. // -*- C++ -*-
  2. /* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
  3.      Written by James Clark (jjc@jclark.com)
  4.  
  5. This file is part of groff.
  6.  
  7. groff is free software; you can redistribute it and/or modify it under
  8. the terms of the GNU General Public License as published by the Free
  9. Software Foundation; either version 2, or (at your option) any later
  10. version.
  11.  
  12. groff is distributed in the hope that it will be useful, but WITHOUT ANY
  13. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License along
  18. with groff; see the file COPYING.  If not, write to the Free Software
  19. Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  20.  
  21. class diversion {
  22.   friend void do_divert(int append);
  23.   friend void end_diversions();
  24.   diversion *prev;
  25. protected:
  26.   symbol nm;
  27.   vunits vertical_position;
  28.   vunits high_water_mark;
  29. public:
  30.   vunits marked_place;
  31.   diversion(symbol s = NULL_SYMBOL);
  32.   virtual ~diversion();
  33.   virtual void output(node *nd, int retain_size, vunits vs, vunits post_vs,
  34.               hunits width) = 0;
  35.   virtual void transparent_output(unsigned char) = 0;
  36.   virtual void transparent_output(node *) = 0;
  37.   virtual void space(vunits distance, int forced = 0) = 0;
  38. #ifdef COLUMN
  39.   virtual void vjustify(symbol) = 0;
  40. #endif /* COLUMN */
  41.   vunits get_vertical_position() { return vertical_position; }
  42.   vunits get_high_water_mark() { return high_water_mark; }
  43.   virtual vunits distance_to_next_trap() = 0;
  44.   void need(vunits);
  45.   const char *get_diversion_name() { return nm.contents(); }
  46.   virtual void set_diversion_trap(symbol, vunits) = 0;
  47.   virtual void clear_diversion_trap() = 0;
  48.   virtual void copy_file(const char *filename) = 0;
  49. };
  50.  
  51. class macro;
  52.  
  53. class macro_diversion : public diversion {
  54.   macro *mac;
  55.   hunits max_width;
  56.   symbol diversion_trap;
  57.   vunits diversion_trap_pos;
  58. public:
  59.   macro_diversion(symbol, int);
  60.   ~macro_diversion();
  61.   void output(node *nd, int retain_size, vunits vs, vunits post_vs,
  62.           hunits width);
  63.   void transparent_output(unsigned char);
  64.   void transparent_output(node *);
  65.   void space(vunits distance, int forced = 0);
  66. #ifdef COLUMN
  67.   void vjustify(symbol);
  68. #endif /* COLUMN */
  69.   vunits distance_to_next_trap();
  70.   void set_diversion_trap(symbol, vunits);
  71.   void clear_diversion_trap();
  72.   void copy_file(const char *filename);
  73. };
  74.  
  75. struct trap {
  76.   trap *next;
  77.   vunits position;
  78.   symbol nm;
  79.   trap(symbol, vunits, trap *);
  80. };
  81.  
  82. struct output_file;
  83.  
  84. class top_level_diversion : public diversion {
  85.   int page_number;
  86.   int page_count;
  87.   int last_page_count;
  88.   vunits page_length;
  89.   hunits prev_page_offset;
  90.   hunits page_offset;
  91.   trap *page_trap_list;
  92.   trap *find_next_trap(vunits *);
  93.   int have_next_page_number;
  94.   int next_page_number;
  95.   int ejecting_page;        // Is the current page being ejected?
  96. public:
  97.   int before_first_page;
  98.   int no_space_mode;
  99.   top_level_diversion();
  100.   void output(node *nd, int retain_size, vunits vs, vunits post_vs,
  101.           hunits width);
  102.   void transparent_output(unsigned char);
  103.   void transparent_output(node *);
  104.   void space(vunits distance, int forced = 0);
  105. #ifdef COLUMN
  106.   void vjustify(symbol);
  107. #endif /* COLUMN */
  108.   hunits get_page_offset() { return page_offset; }
  109.   vunits get_page_length() { return page_length; }
  110.   vunits distance_to_next_trap();
  111.   void add_trap(symbol nm, vunits pos);
  112.   void change_trap(symbol nm, vunits pos);
  113.   void remove_trap(symbol);
  114.   void remove_trap_at(vunits pos);
  115.   void print_traps();
  116.   int get_page_count() { return page_count; }
  117.   int get_page_number() { return page_number; }
  118.   int get_next_page_number();
  119.   void set_page_number(int n) { page_number = n; }
  120.   int begin_page();
  121.   void set_next_page_number(int);
  122.   void set_page_length(vunits);
  123.   void copy_file(const char *filename);
  124.   int get_ejecting() { return ejecting_page; }
  125.   void set_ejecting() { ejecting_page = 1; }
  126.   friend void page_offset();
  127.   void set_diversion_trap(symbol, vunits);
  128.   void clear_diversion_trap();
  129.   void set_last_page() { last_page_count = page_count; }
  130. };
  131.  
  132. extern top_level_diversion *topdiv;
  133. extern diversion *curdiv;
  134.  
  135. extern int exit_started;
  136. extern int done_end_macro;
  137. extern int last_page_number;
  138. extern int seen_last_page_ejector;
  139.  
  140. void spring_trap(symbol);    // implemented by input.c
  141. extern int trap_sprung_flag;
  142. void postpone_traps();
  143. int unpostpone_traps();
  144.  
  145. void push_page_ejector();
  146. void continue_page_eject();
  147. void handle_first_page_transition();
  148. void blank_line();
  149.  
  150. extern void cleanup_and_exit(int);
  151.