2 /* Copyright (C) 1989-2014 Free Software Foundation, Inc.
3 Written by James Clark (jjc@jclark.com)
5 This file is part of groff.
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 3 of the License, or
10 (at your option) any later version.
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
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
28 static size_range *size_table;
33 font_size(int points);
35 int to_scaled_points();
37 int operator==(font_size);
38 int operator!=(font_size);
39 static void init_size_table(int *sizes);
42 inline font_size::font_size() : p(0)
46 inline int font_size::operator==(font_size fs)
51 inline int font_size::operator!=(font_size fs)
56 inline int font_size::to_scaled_points()
61 inline int font_size::to_points()
68 hunits env_digit_width(environment *);
69 hunits env_space_width(environment *);
70 hunits env_sentence_space_width(environment *);
71 hunits env_narrow_space_width(environment *);
72 hunits env_half_narrow_space_width(environment *);
73 int env_get_zoom(environment *);
77 enum tab_type { TAB_NONE, TAB_LEFT, TAB_CENTER, TAB_RIGHT };
84 tab_stops(hunits distance, tab_type type);
85 tab_stops(const tab_stops &);
87 void operator=(const tab_stops &);
88 tab_type distance_to_next_tab(hunits pos, hunits *distance);
89 tab_type distance_to_next_tab(hunits curpos, hunits *distance, hunits *leftpos);
91 void add_tab(hunits pos, tab_type type, int repeated);
92 const char *to_string();
95 const unsigned MARGIN_CHARACTER_ON = 1;
96 const unsigned MARGIN_CHARACTER_NEXT = 2;
102 class pending_output_line;
104 // declarations to avoid friend name injection problems
112 void right_justify();
113 void vertical_spacing();
114 void post_vertical_spacing();
118 void temporary_indent();
119 void do_underline(int);
120 void do_input_trap(int);
122 void margin_character();
125 void leader_character();
126 void tab_character();
127 void hyphenate_request();
129 void hyphen_line_max_request();
130 void hyphenation_space_request();
131 void hyphenation_margin_request();
137 void line_tabs_request();
140 void widow_control_request();
141 #endif /* WIDOW_CONTROL */
143 void do_divert(int append, int boxing);
146 int dummy; // dummy environment used for \w
147 hunits prev_line_length;
149 hunits prev_title_length;
154 int prev_requested_size;
159 font_family *prev_family;
161 int space_size; // in 36ths of an em
162 int sentence_space_size; // same but for spaces at the end of sentences
166 int prev_line_interrupted;
168 int right_justify_lines;
169 vunits prev_vertical_spacing;
170 vunits vertical_spacing;
171 vunits prev_post_vertical_spacing;
172 vunits post_vertical_spacing;
173 int prev_line_spacing;
177 hunits temporary_indent;
178 int have_temporary_indent;
180 hunits target_text_length;
181 int pre_underline_fontno;
183 int underline_spaces;
185 int input_trap_count;
186 int continued_input_trap;
187 node *line; // in reverse order
188 hunits prev_text_length;
191 hunits input_line_start;
196 tab_type current_tab;
199 charinfo *leader_char;
200 int current_field; // is there a current field?
201 hunits field_distance;
202 hunits pre_field_width;
204 int tab_field_spaces;
205 int tab_precedes_field;
207 int spread_flag; // set by \p
208 unsigned margin_character_flags;
209 node *margin_character_node;
210 hunits margin_character_distance;
211 node *numbering_nodes;
212 hunits line_number_digit_width;
213 int number_text_separation; // in digit spaces
214 int line_number_indent; // in digit spaces
215 int line_number_multiple;
217 unsigned hyphenation_flags;
218 int hyphen_line_count;
220 hunits hyphenation_space;
221 hunits hyphenation_margin;
222 int composite; // used for construction of composite char?
223 pending_output_line *pending_lines;
226 #endif /* WIDOW_CONTROL */
228 color *prev_glyph_color;
230 color *prev_fill_color;
232 tab_type distance_to_next_tab(hunits *);
233 tab_type distance_to_next_tab(hunits *distance, hunits *leftpos);
235 void output_line(node *, hunits, int);
236 void output(node *nd, int retain_size, vunits vs, vunits post_vs,
237 hunits width, int was_centered);
238 void output_title(node *nd, int retain_size, vunits vs, vunits post_vs,
241 void mark_last_line();
242 #endif /* WIDOW_CONTROL */
243 breakpoint *choose_breakpoint();
244 void hyphenate_line(int start_here = 0);
246 void wrap_up_field();
248 node *make_tab_node(hunits d, node *next = 0);
249 node *get_prev_char();
253 int suppress_next_eol;
257 unsigned char control_char;
258 unsigned char no_break_control_char;
259 charinfo *hyphen_indicator_char;
262 environment(const environment *); // for temporary environment
264 statem *construct_state(int only_eol);
266 void copy(const environment *);
267 int is_dummy() { return dummy; }
269 int is_composite() { return composite; }
270 void set_composite() { composite = 1; }
271 vunits get_vertical_spacing(); // .v
272 vunits get_post_vertical_spacing(); // .pvs
273 int get_line_spacing(); // .L
274 vunits total_post_vertical_spacing();
275 int get_point_size() { return size.to_scaled_points(); }
276 font_size get_font_size() { return size; }
277 int get_size() { return size.to_units(); }
278 int get_requested_point_size() { return requested_size; }
279 int get_char_height() { return char_height; }
280 int get_char_slant() { return char_slant; }
281 hunits get_digit_width();
282 int get_font() { return fontno; }; // .f
283 int get_zoom(); // .zoom
284 font_family *get_family() { return family; }
285 int get_bold(); // .b
286 int get_adjust_mode(); // .j
287 int get_fill(); // .u
288 hunits get_indent(); // .i
289 hunits get_temporary_indent();
290 hunits get_line_length(); // .l
291 hunits get_saved_line_length(); // .ll
292 hunits get_saved_indent(); // .in
293 hunits get_title_length();
294 hunits get_prev_char_width(); // .w
295 hunits get_prev_char_skew();
296 vunits get_prev_char_height();
297 vunits get_prev_char_depth();
298 hunits get_text_length(); // .k
299 hunits get_prev_text_length(); // .n
300 hunits get_space_width() { return env_space_width(this); }
301 int get_space_size() { return space_size; } // in ems/36
302 int get_sentence_space_size() { return sentence_space_size; }
303 hunits get_narrow_space_width() { return env_narrow_space_width(this); }
304 hunits get_half_narrow_space_width()
305 { return env_half_narrow_space_width(this); }
306 hunits get_input_line_position();
307 const char *get_tabs();
309 int get_hyphenation_flags();
310 int get_hyphen_line_max();
311 int get_hyphen_line_count();
312 hunits get_hyphenation_space();
313 hunits get_hyphenation_margin();
314 int get_center_lines();
315 int get_right_justify_lines();
316 int get_prev_line_interrupted() { return prev_line_interrupted; }
317 color *get_fill_color();
318 color *get_glyph_color();
319 color *get_prev_glyph_color();
320 color *get_prev_fill_color();
321 void set_glyph_color(color *c);
322 void set_fill_color(color *c);
323 node *make_char_node(charinfo *);
324 node *extract_output_line();
325 void width_registers();
328 void set_font(symbol);
329 void set_family(symbol);
331 void set_char_height(int);
332 void set_char_slant(int);
333 void set_input_line_position(hunits); // used by \n(hp
335 void spread() { spread_flag = 1; }
336 void possibly_break_line(int start_here = 0, int forced = 0);
337 void do_break(int spread = 0); // .br
339 node *make_tag(const char *name, int i);
341 void handle_tab(int is_leader = 0); // do a tab or leader
342 void add_node(node *);
343 void add_char(charinfo *);
344 void add_hyphen_indicator();
345 void add_italic_correction();
347 void space(hunits, hunits);
348 void space_newline();
349 const char *get_glyph_color_string();
350 const char *get_fill_color_string();
351 const char *get_font_family_string();
352 const char *get_font_name_string();
353 const char *get_style_name_string();
354 const char *get_name_string();
355 const char *get_point_size_string();
356 const char *get_requested_point_size_string();
357 void output_pending_lines();
358 void construct_format_state(node *n, int was_centered, int fill);
359 void construct_new_line_state(node *n);
360 void dump_troff_state();
362 friend void title_length();
363 friend void space_size();
365 friend void no_fill();
366 friend void adjust();
367 friend void no_adjust();
368 friend void center();
369 friend void right_justify();
370 friend void vertical_spacing();
371 friend void post_vertical_spacing();
372 friend void line_spacing();
373 friend void line_length();
374 friend void indent();
375 friend void temporary_indent();
376 friend void do_underline(int);
377 friend void do_input_trap(int);
378 friend void set_tabs();
379 friend void margin_character();
380 friend void no_number();
381 friend void number_lines();
382 friend void leader_character();
383 friend void tab_character();
384 friend void hyphenate_request();
385 friend void no_hyphenate();
386 friend void hyphen_line_max_request();
387 friend void hyphenation_space_request();
388 friend void hyphenation_margin_request();
389 friend void line_width();
391 friend void tabs_save();
392 friend void tabs_restore();
394 friend void line_tabs_request();
397 friend void widow_control_request();
398 #endif /* WIDOW_CONTROL */
400 friend void do_divert(int append, int boxing);
403 extern environment *curenv;
404 extern void pop_env();
405 extern void push_env(int);
407 void init_environments();
408 void read_hyphen_file(const char *name);
410 extern double spread_limit;
412 extern int break_flag;
413 extern symbol default_family;
414 extern int translate_space_to_dummy;
416 extern unsigned char hpf_code_table[];