2 /* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2003
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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
24 unsigned char breakable
;
25 unsigned char hyphenation_code
;
27 hyphen_list(unsigned char code
, hyphen_list
*p
= 0);
30 void hyphenate(hyphen_list
*, unsigned);
32 enum hyphenation_type
{ HYPHEN_MIDDLE
, HYPHEN_BOUNDARY
, HYPHEN_INHIBIT
};
34 class ascii_output_file
;
42 class troff_output_file
;
47 class diverted_space_node
;
55 node
*add_char(charinfo
*c
, environment
*, hunits
*widthp
, int *spacep
);
58 virtual node
*copy() = 0;
59 virtual int set_unformat_flag();
60 virtual int force_tprint() = 0;
61 virtual hunits
width();
62 virtual hunits
subscript_correction();
63 virtual hunits
italic_correction();
64 virtual hunits
left_italic_correction();
65 virtual hunits
skew();
66 virtual int nspaces();
67 virtual int merge_space(hunits
, hunits
, hunits
);
68 virtual vunits
vertical_width();
69 virtual node
*last_char_node();
70 virtual void vertical_extent(vunits
*min
, vunits
*max
);
71 virtual int character_type();
72 virtual void set_vertical_size(vertical_size
*);
73 virtual int ends_sentence();
74 virtual node
*merge_self(node
*);
75 virtual node
*add_discretionary_hyphen();
76 virtual node
*add_self(node
*, hyphen_list
**);
77 virtual hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
78 virtual void ascii_print(ascii_output_file
*);
79 virtual void asciify(macro
*);
80 virtual int discardable();
81 virtual void spread_space(int *, hunits
*);
82 virtual void freeze_space();
83 virtual void is_escape_colon();
84 virtual breakpoint
*get_breakpoints(hunits width
, int nspaces
,
87 virtual int nbreaks();
88 virtual void split(int, node
**, node
**);
89 virtual hyphenation_type
get_hyphenation_type();
90 virtual int reread(int *);
91 virtual token_node
*get_token_node();
92 virtual int overlaps_vertically();
93 virtual int overlaps_horizontally();
95 virtual int interpret(macro
*);
97 virtual node
*merge_glyph_node(glyph_node
*);
98 virtual tfont
*get_tfont();
99 virtual color
*get_glyph_color();
100 virtual color
*get_fill_color();
101 virtual void tprint(troff_output_file
*);
102 virtual void zero_width_tprint(troff_output_file
*);
104 node
*add_italic_correction(hunits
*);
106 virtual int same(node
*) = 0;
107 virtual const char *type() = 0;
115 inline node::node(node
*n
)
124 // 0 means it doesn't, 1 means it does, 2 means it's transparent
126 int node_list_ends_sentence(node
*);
137 class line_start_node
: public node
{
140 node
*copy() { return new line_start_node
; }
144 void asciify(macro
*);
147 class space_node
: public node
{
150 enum { BLOCK
= 1024 };
151 static space_node
*free_list
;
152 void operator delete(void *);
157 char was_escape_colon
;
158 color
*col
; /* for grotty */
159 space_node(hunits
, int, int, color
*, node
* = 0);
161 space_node(hunits
, color
*, node
* = 0);
164 void *operator new(size_t);
170 int merge_space(hunits
, hunits
, hunits
);
172 void is_escape_colon();
173 void spread_space(int *, hunits
*);
174 void tprint(troff_output_file
*);
175 breakpoint
*get_breakpoints(hunits width
, int nspaces
, breakpoint
*rest
= 0,
178 void split(int, node
**, node
**);
179 void ascii_print(ascii_output_file
*);
181 void asciify(macro
*);
184 hyphenation_type
get_hyphenation_type();
189 hunits sentence_width
;
191 width_list(hunits
, hunits
);
192 width_list(width_list
*);
195 class word_space_node
: public space_node
{
197 width_list
*orig_width
;
198 unsigned char unformat
;
199 word_space_node(hunits
, int, color
*, width_list
*, int, node
* = 0);
201 word_space_node(hunits
, color
*, width_list
*, node
* = 0);
205 int set_unformat_flag();
206 void tprint(troff_output_file
*);
208 void asciify(macro
*);
210 int merge_space(hunits
, hunits
, hunits
);
214 class unbreakable_space_node
: public word_space_node
{
215 unbreakable_space_node(hunits
, int, color
*, node
* = 0);
217 unbreakable_space_node(hunits
, color
*, node
* = 0);
220 void tprint(troff_output_file
*);
222 void asciify(macro
*);
225 breakpoint
*get_breakpoints(hunits width
, int nspaces
, breakpoint
*rest
= 0,
228 void split(int, node
**, node
**);
229 int merge_space(hunits
, hunits
, hunits
);
230 node
*add_self(node
*, hyphen_list
**);
231 hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
232 hyphenation_type
get_hyphenation_type();
235 class diverted_space_node
: public node
{
238 diverted_space_node(vunits d
, node
*p
= 0);
246 class diverted_copy_file_node
: public node
{
250 diverted_copy_file_node(symbol s
, node
*p
= 0);
258 class extra_size_node
: public node
{
261 extra_size_node(vunits i
) : n(i
) {}
262 void set_vertical_size(vertical_size
*);
269 class vertical_size_node
: public node
{
272 vertical_size_node(vunits i
) : n(i
) {}
273 void set_vertical_size(vertical_size
*);
274 void asciify(macro
*);
276 int set_unformat_flag();
282 class hmotion_node
: public node
{
285 unsigned char was_tab
;
286 unsigned char unformat
;
287 color
*col
; /* for grotty */
289 hmotion_node(hunits i
, color
*c
, node
*next
= 0)
290 : node(next
), n(i
), was_tab(0), unformat(0), col(c
) {}
291 hmotion_node(hunits i
, int flag1
, int flag2
, color
*c
, node
*next
= 0)
292 : node(next
), n(i
), was_tab(flag1
), unformat(flag2
), col(c
) {}
295 int set_unformat_flag();
296 void asciify(macro
*);
297 void tprint(troff_output_file
*);
299 void ascii_print(ascii_output_file
*);
303 node
*add_self(node
*, hyphen_list
**);
304 hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
305 hyphenation_type
get_hyphenation_type();
308 class space_char_hmotion_node
: public hmotion_node
{
310 space_char_hmotion_node(hunits
, color
*, node
* = 0);
312 void ascii_print(ascii_output_file
*);
313 void asciify(macro
*);
314 void tprint(troff_output_file
*);
318 node
*add_self(node
*, hyphen_list
**);
319 hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
320 hyphenation_type
get_hyphenation_type();
323 class vmotion_node
: public node
{
325 color
*col
; /* for grotty */
327 vmotion_node(vunits i
, color
*c
) : n(i
), col(c
) {}
328 void tprint(troff_output_file
*);
330 vunits
vertical_width();
336 class hline_node
: public node
{
340 hline_node(hunits i
, node
*c
, node
*next
= 0) : node(next
), x(i
), n(c
) {}
344 void tprint(troff_output_file
*);
350 class vline_node
: public node
{
354 vline_node(vunits i
, node
*c
, node
*next
= 0) : node(next
), x(i
), n(c
) {}
357 void tprint(troff_output_file
*);
359 vunits
vertical_width();
360 void vertical_extent(vunits
*, vunits
*);
367 class dummy_node
: public node
{
369 dummy_node(node
*nd
= 0) : node(nd
) {}
374 hyphenation_type
get_hyphenation_type();
377 class transparent_dummy_node
: public node
{
379 transparent_dummy_node(node
*nd
= 0) : node(nd
) {}
385 hyphenation_type
get_hyphenation_type();
388 class zero_width_node
: public node
{
391 zero_width_node(node
*gn
);
394 void tprint(troff_output_file
*);
399 int character_type();
400 void vertical_extent(vunits
*min
, vunits
*max
);
403 class left_italic_corrected_node
: public node
{
407 left_italic_corrected_node(node
* = 0);
408 ~left_italic_corrected_node();
409 void tprint(troff_output_file
*);
410 void ascii_print(ascii_output_file
*);
411 void asciify(macro
*);
417 node
*last_char_node();
418 void vertical_extent(vunits
*, vunits
*);
420 int overlaps_horizontally();
421 int overlaps_vertically();
422 hyphenation_type
get_hyphenation_type();
424 int character_type();
426 hunits
italic_correction();
427 hunits
subscript_correction();
428 hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
429 node
*add_self(node
*, hyphen_list
**);
430 node
*merge_glyph_node(glyph_node
*);
433 class overstrike_node
: public node
{
440 void tprint(troff_output_file
*);
441 void overstrike(node
*); // add another node to be overstruck
446 node
*add_self(node
*, hyphen_list
**);
447 hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
448 hyphenation_type
get_hyphenation_type();
451 class bracket_node
: public node
{
458 void tprint(troff_output_file
*);
459 void bracket(node
*); // add another node to be overstruck
466 class special_node
: public node
{
472 void tprint_start(troff_output_file
*);
473 void tprint_char(troff_output_file
*, unsigned char);
474 void tprint_end(troff_output_file
*);
476 special_node(const macro
&, int = 0);
477 special_node(const macro
&, tfont
*, color
*, color
*, int = 0);
479 void tprint(troff_output_file
*);
487 class suppress_node
: public node
{
489 int emit_limits
; // must we issue the extent of the area written out?
494 suppress_node(int, int);
495 suppress_node(symbol f
, char p
, int id
);
496 suppress_node(int, int, symbol f
, char p
, int id
);
498 void tprint(troff_output_file
*);
504 void put(troff_output_file
*out
, const char *s
);
513 class draw_node
: public node
{
521 draw_node(char, hvpair
*, int, font_size
, color
*, color
*);
524 vunits
vertical_width();
526 void tprint(troff_output_file
*);
533 node
*make_node(charinfo
*ci
, environment
*);
534 int character_exists(charinfo
*, environment
*);
536 int same_node_list(node
*n1
, node
*n2
);
537 node
*reverse_node_list(node
*n
);
538 void delete_node_list(node
*);
539 node
*copy_node_list(node
*);
541 int get_bold_fontno(int f
);
543 inline hyphen_list::hyphen_list(unsigned char code
, hyphen_list
*p
)
544 : hyphen(0), breakable(0), hyphenation_code(code
), next(p
)
548 extern void read_desc();
549 extern int mount_font(int n
, symbol
, symbol
= NULL_SYMBOL
);
550 extern void mount_style(int n
, symbol
);
551 extern int is_good_fontno(int n
);
552 extern int symbol_fontno(symbol
);
553 extern int next_available_font_position();
554 extern void init_size_table(int *);
555 extern int get_underline_fontno();
558 char make_g_plus_plus_shut_up
;
561 virtual ~output_file();
562 virtual void trailer(vunits page_length
);
563 virtual void flush() = 0;
564 virtual void transparent_char(unsigned char) = 0;
565 virtual void print_line(hunits x
, vunits y
, node
*n
,
566 vunits before
, vunits after
, hunits width
) = 0;
567 virtual void begin_page(int pageno
, vunits page_length
) = 0;
568 virtual void copy_file(hunits x
, vunits y
, const char *filename
) = 0;
569 virtual int is_printing() = 0;
570 virtual void put_filename(const char *filename
);
574 virtual void vjustify(vunits
, symbol
);
578 #ifndef POPEN_MISSING
579 extern char *pipe_command
;
582 extern output_file
*the_output
;
583 extern void init_output();
584 int in_output_page_list(int n
);
593 int make_definite(int);
594 static void invalidate_fontno(int);
597 font_family
*lookup_family(symbol
);
598 symbol
get_font_name(int, environment
*);
599 extern search_path include_search_path
;