2 /* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2004, 2005
3 Free Software Foundation, Inc.
4 Written by James Clark (jjc@jclark.com)
6 This file is part of groff.
8 groff is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2, or (at your option) any later
13 groff is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License along
19 with groff; see the file COPYING. If not, write to the Free Software
20 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
30 static size_range *size_table;
35 font_size(int points);
37 int to_scaled_points();
39 int operator==(font_size);
40 int operator!=(font_size);
41 static void init_size_table(int *sizes);
44 inline font_size::font_size() : p(0)
48 inline int font_size::operator==(font_size fs)
53 inline int font_size::operator!=(font_size fs)
58 inline int font_size::to_scaled_points()
63 inline int font_size::to_points()
70 hunits env_digit_width(environment *);
71 hunits env_space_width(environment *);
72 hunits env_sentence_space_width(environment *);
73 hunits env_narrow_space_width(environment *);
74 hunits env_half_narrow_space_width(environment *);
78 enum tab_type { TAB_NONE, TAB_LEFT, TAB_CENTER, TAB_RIGHT };
85 tab_stops(hunits distance, tab_type type);
86 tab_stops(const tab_stops &);
88 void operator=(const tab_stops &);
89 tab_type distance_to_next_tab(hunits pos, hunits *distance);
90 tab_type distance_to_next_tab(hunits curpos, hunits *distance, hunits *leftpos);
92 void add_tab(hunits pos, tab_type type, int repeated);
93 const char *to_string();
96 const unsigned MARGIN_CHARACTER_ON = 1;
97 const unsigned MARGIN_CHARACTER_NEXT = 2;
103 class pending_output_line;
105 // declarations to avoid friend name injection problems
113 void right_justify();
114 void vertical_spacing();
115 void post_vertical_spacing();
119 void temporary_indent();
120 void do_underline(int);
121 void do_input_trap(int);
123 void margin_character();
126 void leader_character();
127 void tab_character();
128 void hyphenate_request();
130 void hyphen_line_max_request();
131 void hyphenation_space_request();
132 void hyphenation_margin_request();
138 void line_tabs_request();
141 void widow_control_request();
142 #endif /* WIDOW_CONTROL */
144 void do_divert(int append, int boxing);
147 int dummy; // dummy environment used for \w
148 hunits prev_line_length;
150 hunits prev_title_length;
155 int prev_requested_size;
160 font_family *prev_family;
162 int space_size; // in 36ths of an em
163 int sentence_space_size; // same but for spaces at the end of sentences
167 int prev_line_interrupted;
169 int right_justify_lines;
170 vunits prev_vertical_spacing;
171 vunits vertical_spacing;
172 vunits prev_post_vertical_spacing;
173 vunits post_vertical_spacing;
174 int prev_line_spacing;
178 hunits temporary_indent;
179 int have_temporary_indent;
181 hunits target_text_length;
182 int pre_underline_fontno;
184 int underline_spaces;
186 int input_trap_count;
187 int continued_input_trap;
188 node *line; // in reverse order
189 hunits prev_text_length;
192 hunits input_line_start;
197 tab_type current_tab;
200 charinfo *leader_char;
201 int current_field; // is there a current field?
202 hunits field_distance;
203 hunits pre_field_width;
205 int tab_field_spaces;
206 int tab_precedes_field;
208 int spread_flag; // set by \p
209 unsigned margin_character_flags;
210 node *margin_character_node;
211 hunits margin_character_distance;
212 node *numbering_nodes;
213 hunits line_number_digit_width;
214 int number_text_separation; // in digit spaces
215 int line_number_indent; // in digit spaces
216 int line_number_multiple;
218 unsigned hyphenation_flags;
219 int hyphen_line_count;
221 hunits hyphenation_space;
222 hunits hyphenation_margin;
223 int composite; // used for construction of composite char?
224 pending_output_line *pending_lines;
227 #endif /* WIDOW_CONTROL */
229 color *prev_glyph_color;
231 color *prev_fill_color;
233 tab_type distance_to_next_tab(hunits *);
234 tab_type distance_to_next_tab(hunits *distance, hunits *leftpos);
236 void output_line(node *, hunits, int);
237 void output(node *nd, int retain_size, vunits vs, vunits post_vs,
238 hunits width, int was_centered);
239 void output_title(node *nd, int retain_size, vunits vs, vunits post_vs,
242 void mark_last_line();
243 #endif /* WIDOW_CONTROL */
244 breakpoint *choose_breakpoint();
245 void hyphenate_line(int start_here = 0);
247 void wrap_up_field();
249 node *make_tab_node(hunits d, node *next = 0);
250 node *get_prev_char();
254 int suppress_next_eol;
258 unsigned char control_char;
259 unsigned char no_break_control_char;
260 charinfo *hyphen_indicator_char;
263 environment(const environment *); // for temporary environment
265 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 font_family *get_family() { return family; }
284 int get_bold(); // .b
285 int get_adjust_mode(); // .j
286 int get_fill(); // .u
287 hunits get_indent(); // .i
288 hunits get_temporary_indent();
289 hunits get_line_length(); // .l
290 hunits get_saved_line_length(); // .ll
291 hunits get_saved_indent(); // .in
292 hunits get_title_length();
293 hunits get_prev_char_width(); // .w
294 hunits get_prev_char_skew();
295 vunits get_prev_char_height();
296 vunits get_prev_char_depth();
297 hunits get_text_length(); // .k
298 hunits get_prev_text_length(); // .n
299 hunits get_space_width() { return env_space_width(this); }
300 int get_space_size() { return space_size; } // in ems/36
301 int get_sentence_space_size() { return sentence_space_size; }
302 hunits get_narrow_space_width() { return env_narrow_space_width(this); }
303 hunits get_half_narrow_space_width()
304 { return env_half_narrow_space_width(this); }
305 hunits get_input_line_position();
306 const char *get_tabs();
308 int get_hyphenation_flags();
309 int get_hyphen_line_max();
310 int get_hyphen_line_count();
311 hunits get_hyphenation_space();
312 hunits get_hyphenation_margin();
313 int get_center_lines();
314 int get_right_justify_lines();
315 int get_prev_line_interrupted() { return prev_line_interrupted; }
316 color *get_fill_color();
317 color *get_glyph_color();
318 color *get_prev_glyph_color();
319 color *get_prev_fill_color();
320 void set_glyph_color(color *c);
321 void set_fill_color(color *c);
322 node *make_char_node(charinfo *);
323 node *extract_output_line();
324 void width_registers();
327 void set_font(symbol);
328 void set_family(symbol);
330 void set_char_height(int);
331 void set_char_slant(int);
332 void set_input_line_position(hunits); // used by \n(hp
334 void spread() { spread_flag = 1; }
335 void possibly_break_line(int start_here = 0, int forced = 0);
336 void do_break(int spread = 0); // .br
338 node *make_tag(const char *name, int i);
340 void handle_tab(int is_leader = 0); // do a tab or leader
341 void add_node(node *);
342 void add_char(charinfo *);
343 void add_hyphen_indicator();
344 void add_italic_correction();
346 void space(hunits, hunits);
347 void space_newline();
348 const char *get_glyph_color_string();
349 const char *get_fill_color_string();
350 const char *get_font_family_string();
351 const char *get_font_name_string();
352 const char *get_style_name_string();
353 const char *get_name_string();
354 const char *get_point_size_string();
355 const char *get_requested_point_size_string();
356 void output_pending_lines();
357 void construct_format_state(node *n, int was_centered, int fill);
358 void construct_new_line_state(node *n);
359 void dump_troff_state();
361 friend void title_length();
362 friend void space_size();
364 friend void no_fill();
365 friend void adjust();
366 friend void no_adjust();
367 friend void center();
368 friend void right_justify();
369 friend void vertical_spacing();
370 friend void post_vertical_spacing();
371 friend void line_spacing();
372 friend void line_length();
373 friend void indent();
374 friend void temporary_indent();
375 friend void do_underline(int);
376 friend void do_input_trap(int);
377 friend void set_tabs();
378 friend void margin_character();
379 friend void no_number();
380 friend void number_lines();
381 friend void leader_character();
382 friend void tab_character();
383 friend void hyphenate_request();
384 friend void no_hyphenate();
385 friend void hyphen_line_max_request();
386 friend void hyphenation_space_request();
387 friend void hyphenation_margin_request();
388 friend void line_width();
390 friend void tabs_save();
391 friend void tabs_restore();
393 friend void line_tabs_request();
396 friend void widow_control_request();
397 #endif /* WIDOW_CONTROL */
399 friend void do_divert(int append, int boxing);
402 extern environment *curenv;
403 extern void pop_env();
404 extern void push_env(int);
406 void init_environments();
407 void read_hyphen_file(const char *name);
409 extern double spread_limit;
411 extern int break_flag;
412 extern symbol default_family;
413 extern int translate_space_to_dummy;
415 extern unsigned char hpf_code_table[];