2 /* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2004, 2005,
4 Free Software Foundation, Inc.
5 Written by James Clark (jjc@jclark.com)
7 This file is part of groff.
9 groff is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 groff is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
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 *);
75 int env_get_zoom(environment *);
79 enum tab_type { TAB_NONE, TAB_LEFT, TAB_CENTER, TAB_RIGHT };
86 tab_stops(hunits distance, tab_type type);
87 tab_stops(const tab_stops &);
89 void operator=(const tab_stops &);
90 tab_type distance_to_next_tab(hunits pos, hunits *distance);
91 tab_type distance_to_next_tab(hunits curpos, hunits *distance, hunits *leftpos);
93 void add_tab(hunits pos, tab_type type, int repeated);
94 const char *to_string();
97 const unsigned MARGIN_CHARACTER_ON = 1;
98 const unsigned MARGIN_CHARACTER_NEXT = 2;
104 class pending_output_line;
106 // declarations to avoid friend name injection problems
114 void right_justify();
115 void vertical_spacing();
116 void post_vertical_spacing();
120 void temporary_indent();
121 void do_underline(int);
122 void do_input_trap(int);
124 void margin_character();
127 void leader_character();
128 void tab_character();
129 void hyphenate_request();
131 void hyphen_line_max_request();
132 void hyphenation_space_request();
133 void hyphenation_margin_request();
139 void line_tabs_request();
142 void widow_control_request();
143 #endif /* WIDOW_CONTROL */
145 void do_divert(int append, int boxing);
148 int dummy; // dummy environment used for \w
149 hunits prev_line_length;
151 hunits prev_title_length;
156 int prev_requested_size;
161 font_family *prev_family;
163 int space_size; // in 36ths of an em
164 int sentence_space_size; // same but for spaces at the end of sentences
168 int prev_line_interrupted;
170 int right_justify_lines;
171 vunits prev_vertical_spacing;
172 vunits vertical_spacing;
173 vunits prev_post_vertical_spacing;
174 vunits post_vertical_spacing;
175 int prev_line_spacing;
179 hunits temporary_indent;
180 int have_temporary_indent;
182 hunits target_text_length;
183 int pre_underline_fontno;
185 int underline_spaces;
187 int input_trap_count;
188 int continued_input_trap;
189 node *line; // in reverse order
190 hunits prev_text_length;
193 hunits input_line_start;
198 tab_type current_tab;
201 charinfo *leader_char;
202 int current_field; // is there a current field?
203 hunits field_distance;
204 hunits pre_field_width;
206 int tab_field_spaces;
207 int tab_precedes_field;
209 int spread_flag; // set by \p
210 unsigned margin_character_flags;
211 node *margin_character_node;
212 hunits margin_character_distance;
213 node *numbering_nodes;
214 hunits line_number_digit_width;
215 int number_text_separation; // in digit spaces
216 int line_number_indent; // in digit spaces
217 int line_number_multiple;
219 unsigned hyphenation_flags;
220 int hyphen_line_count;
222 hunits hyphenation_space;
223 hunits hyphenation_margin;
224 int composite; // used for construction of composite char?
225 pending_output_line *pending_lines;
228 #endif /* WIDOW_CONTROL */
230 color *prev_glyph_color;
232 color *prev_fill_color;
234 tab_type distance_to_next_tab(hunits *);
235 tab_type distance_to_next_tab(hunits *distance, hunits *leftpos);
237 void output_line(node *, hunits, int);
238 void output(node *nd, int retain_size, vunits vs, vunits post_vs,
239 hunits width, int was_centered);
240 void output_title(node *nd, int retain_size, vunits vs, vunits post_vs,
243 void mark_last_line();
244 #endif /* WIDOW_CONTROL */
245 breakpoint *choose_breakpoint();
246 void hyphenate_line(int start_here = 0);
248 void wrap_up_field();
250 node *make_tab_node(hunits d, node *next = 0);
251 node *get_prev_char();
255 int suppress_next_eol;
259 unsigned char control_char;
260 unsigned char no_break_control_char;
261 charinfo *hyphen_indicator_char;
264 environment(const environment *); // for temporary environment
266 statem *construct_state(int only_eol);
268 void copy(const environment *);
269 int is_dummy() { return dummy; }
271 int is_composite() { return composite; }
272 void set_composite() { composite = 1; }
273 vunits get_vertical_spacing(); // .v
274 vunits get_post_vertical_spacing(); // .pvs
275 int get_line_spacing(); // .L
276 vunits total_post_vertical_spacing();
277 int get_point_size() { return size.to_scaled_points(); }
278 font_size get_font_size() { return size; }
279 int get_size() { return size.to_units(); }
280 int get_requested_point_size() { return requested_size; }
281 int get_char_height() { return char_height; }
282 int get_char_slant() { return char_slant; }
283 hunits get_digit_width();
284 int get_font() { return fontno; }; // .f
285 int get_zoom(); // .zoom
286 font_family *get_family() { return family; }
287 int get_bold(); // .b
288 int get_adjust_mode(); // .j
289 int get_fill(); // .u
290 hunits get_indent(); // .i
291 hunits get_temporary_indent();
292 hunits get_line_length(); // .l
293 hunits get_saved_line_length(); // .ll
294 hunits get_saved_indent(); // .in
295 hunits get_title_length();
296 hunits get_prev_char_width(); // .w
297 hunits get_prev_char_skew();
298 vunits get_prev_char_height();
299 vunits get_prev_char_depth();
300 hunits get_text_length(); // .k
301 hunits get_prev_text_length(); // .n
302 hunits get_space_width() { return env_space_width(this); }
303 int get_space_size() { return space_size; } // in ems/36
304 int get_sentence_space_size() { return sentence_space_size; }
305 hunits get_narrow_space_width() { return env_narrow_space_width(this); }
306 hunits get_half_narrow_space_width()
307 { return env_half_narrow_space_width(this); }
308 hunits get_input_line_position();
309 const char *get_tabs();
311 int get_hyphenation_flags();
312 int get_hyphen_line_max();
313 int get_hyphen_line_count();
314 hunits get_hyphenation_space();
315 hunits get_hyphenation_margin();
316 int get_center_lines();
317 int get_right_justify_lines();
318 int get_prev_line_interrupted() { return prev_line_interrupted; }
319 color *get_fill_color();
320 color *get_glyph_color();
321 color *get_prev_glyph_color();
322 color *get_prev_fill_color();
323 void set_glyph_color(color *c);
324 void set_fill_color(color *c);
325 node *make_char_node(charinfo *);
326 node *extract_output_line();
327 void width_registers();
330 void set_font(symbol);
331 void set_family(symbol);
333 void set_char_height(int);
334 void set_char_slant(int);
335 void set_input_line_position(hunits); // used by \n(hp
337 void spread() { spread_flag = 1; }
338 void possibly_break_line(int start_here = 0, int forced = 0);
339 void do_break(int spread = 0); // .br
341 node *make_tag(const char *name, int i);
343 void handle_tab(int is_leader = 0); // do a tab or leader
344 void add_node(node *);
345 void add_char(charinfo *);
346 void add_hyphen_indicator();
347 void add_italic_correction();
349 void space(hunits, hunits);
350 void space_newline();
351 const char *get_glyph_color_string();
352 const char *get_fill_color_string();
353 const char *get_font_family_string();
354 const char *get_font_name_string();
355 const char *get_style_name_string();
356 const char *get_name_string();
357 const char *get_point_size_string();
358 const char *get_requested_point_size_string();
359 void output_pending_lines();
360 void construct_format_state(node *n, int was_centered, int fill);
361 void construct_new_line_state(node *n);
362 void dump_troff_state();
364 friend void title_length();
365 friend void space_size();
367 friend void no_fill();
368 friend void adjust();
369 friend void no_adjust();
370 friend void center();
371 friend void right_justify();
372 friend void vertical_spacing();
373 friend void post_vertical_spacing();
374 friend void line_spacing();
375 friend void line_length();
376 friend void indent();
377 friend void temporary_indent();
378 friend void do_underline(int);
379 friend void do_input_trap(int);
380 friend void set_tabs();
381 friend void margin_character();
382 friend void no_number();
383 friend void number_lines();
384 friend void leader_character();
385 friend void tab_character();
386 friend void hyphenate_request();
387 friend void no_hyphenate();
388 friend void hyphen_line_max_request();
389 friend void hyphenation_space_request();
390 friend void hyphenation_margin_request();
391 friend void line_width();
393 friend void tabs_save();
394 friend void tabs_restore();
396 friend void line_tabs_request();
399 friend void widow_control_request();
400 #endif /* WIDOW_CONTROL */
402 friend void do_divert(int append, int boxing);
405 extern environment *curenv;
406 extern void pop_env();
407 extern void push_env(int);
409 void init_environments();
410 void read_hyphen_file(const char *name);
412 extern double spread_limit;
414 extern int break_flag;
415 extern symbol default_family;
416 extern int translate_space_to_dummy;
418 extern unsigned char hpf_code_table[];