/contrib/groff/src/roff/troff/div.h

https://bitbucket.org/freebsd/freebsd-head/ · C++ Header · 172 lines · 140 code · 12 blank · 20 comment · 0 complexity · 4a9ecdea04da9bb55b7909173bb60bc6 MD5 · raw file

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