2 /* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2003, 2004
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. */
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
;
59 node(node
*, statem
*, int);
60 node
*add_char(charinfo
*, environment
*, hunits
*, int *, node
** = 0);
63 virtual node
*copy() = 0;
64 virtual int set_unformat_flag();
65 virtual int force_tprint() = 0;
66 virtual int is_tag() = 0;
67 virtual hunits
width();
68 virtual hunits
subscript_correction();
69 virtual hunits
italic_correction();
70 virtual hunits
left_italic_correction();
71 virtual hunits
skew();
72 virtual int nspaces();
73 virtual int merge_space(hunits
, hunits
, hunits
);
74 virtual vunits
vertical_width();
75 virtual node
*last_char_node();
76 virtual void vertical_extent(vunits
*, vunits
*);
77 virtual int character_type();
78 virtual void set_vertical_size(vertical_size
*);
79 virtual int ends_sentence();
80 virtual node
*merge_self(node
*);
81 virtual node
*add_discretionary_hyphen();
82 virtual node
*add_self(node
*, hyphen_list
**);
83 virtual hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
84 virtual void ascii_print(ascii_output_file
*);
85 virtual void asciify(macro
*);
86 virtual int discardable();
87 virtual void spread_space(int *, hunits
*);
88 virtual void freeze_space();
89 virtual void is_escape_colon();
90 virtual breakpoint
*get_breakpoints(hunits
, int, breakpoint
* = 0, int = 0);
91 virtual int nbreaks();
92 virtual void split(int, node
**, node
**);
93 virtual hyphenation_type
get_hyphenation_type();
94 virtual int reread(int *);
95 virtual token_node
*get_token_node();
96 virtual int overlaps_vertically();
97 virtual int overlaps_horizontally();
99 virtual int interpret(macro
*);
101 virtual node
*merge_glyph_node(glyph_node
*);
102 virtual tfont
*get_tfont();
103 virtual color
*get_glyph_color();
104 virtual color
*get_fill_color();
105 virtual void tprint(troff_output_file
*);
106 virtual void zero_width_tprint(troff_output_file
*);
108 node
*add_italic_correction(hunits
*);
110 virtual int same(node
*) = 0;
111 virtual const char *type() = 0;
112 virtual void debug_node();
113 virtual void debug_node_list();
117 : next(0), last(0), state(0), push_state(0), div_nest_level(0), is_special(0)
121 inline node::node(node
*n
)
122 : next(n
), last(0), state(0), push_state(0), div_nest_level(0), is_special(0)
126 inline node::node(node
*n
, statem
*s
, int divlevel
)
127 : next(n
), last(0), push_state(0), div_nest_level(divlevel
), is_special(0)
130 state
= new statem(s
);
139 // 0 means it doesn't, 1 means it does, 2 means it's transparent
141 int node_list_ends_sentence(node
*);
152 class line_start_node
: public node
{
155 node
*copy() { return new line_start_node
; }
160 void asciify(macro
*);
163 class space_node
: public node
{
166 enum { BLOCK
= 1024 };
167 static space_node
*free_list
;
168 void operator delete(void *);
173 char was_escape_colon
;
174 color
*col
; /* for grotty */
175 space_node(hunits
, int, int, color
*, statem
*, int, node
* = 0);
177 space_node(hunits
, color
*, statem
*, int, node
* = 0);
178 space_node(hunits
, color
*, node
* = 0);
181 void *operator new(size_t);
187 int merge_space(hunits
, hunits
, hunits
);
189 void is_escape_colon();
190 void spread_space(int *, hunits
*);
191 void tprint(troff_output_file
*);
192 breakpoint
*get_breakpoints(hunits
, int, breakpoint
* = 0, int = 0);
194 void split(int, node
**, node
**);
195 void ascii_print(ascii_output_file
*);
197 void asciify(macro
*);
201 hyphenation_type
get_hyphenation_type();
206 hunits sentence_width
;
208 width_list(hunits
, hunits
);
209 width_list(width_list
*);
212 class word_space_node
: public space_node
{
214 width_list
*orig_width
;
215 unsigned char unformat
;
216 word_space_node(hunits
, int, color
*, width_list
*, int, statem
*, int,
219 word_space_node(hunits
, color
*, width_list
*, node
* = 0);
223 int set_unformat_flag();
224 void tprint(troff_output_file
*);
226 void asciify(macro
*);
228 int merge_space(hunits
, hunits
, hunits
);
233 class unbreakable_space_node
: public word_space_node
{
234 unbreakable_space_node(hunits
, int, color
*, statem
*, int, node
* = 0);
236 unbreakable_space_node(hunits
, color
*, node
* = 0);
239 void tprint(troff_output_file
*);
241 void asciify(macro
*);
245 breakpoint
*get_breakpoints(hunits
, int, breakpoint
* = 0, int = 0);
247 void split(int, node
**, node
**);
248 int merge_space(hunits
, hunits
, hunits
);
249 node
*add_self(node
*, hyphen_list
**);
250 hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
251 hyphenation_type
get_hyphenation_type();
254 class diverted_space_node
: public node
{
257 diverted_space_node(vunits
, node
* = 0);
258 diverted_space_node(vunits
, statem
*, int, node
* = 0);
267 class diverted_copy_file_node
: public node
{
271 diverted_copy_file_node(symbol
, node
* = 0);
272 diverted_copy_file_node(symbol
, statem
*, int, node
* = 0);
281 class extra_size_node
: public node
{
284 extra_size_node(vunits
);
285 extra_size_node(vunits
, statem
*, int);
286 void set_vertical_size(vertical_size
*);
294 class vertical_size_node
: public node
{
297 vertical_size_node(vunits
, statem
*, int);
298 vertical_size_node(vunits
);
299 void set_vertical_size(vertical_size
*);
300 void asciify(macro
*);
302 int set_unformat_flag();
309 class hmotion_node
: public node
{
312 unsigned char was_tab
;
313 unsigned char unformat
;
314 color
*col
; /* for grotty */
316 hmotion_node(hunits i
, color
*c
, node
*nxt
= 0)
317 : node(nxt
), n(i
), was_tab(0), unformat(0), col(c
) {}
318 hmotion_node(hunits i
, color
*c
, statem
*s
, int divlevel
, node
*nxt
= 0)
319 : node(nxt
, s
, divlevel
), n(i
), was_tab(0), unformat(0), col(c
) {}
320 hmotion_node(hunits i
, int flag1
, int flag2
, color
*c
, statem
*s
,
321 int divlevel
, node
*nxt
= 0)
322 : node(nxt
, s
, divlevel
), n(i
), was_tab(flag1
), unformat(flag2
),
324 hmotion_node(hunits i
, int flag1
, int flag2
, color
*c
, node
*nxt
= 0)
325 : node(nxt
), n(i
), was_tab(flag1
), unformat(flag2
), col(c
) {}
328 int set_unformat_flag();
329 void asciify(macro
*);
330 void tprint(troff_output_file
*);
332 void ascii_print(ascii_output_file
*);
337 node
*add_self(node
*, hyphen_list
**);
338 hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
339 hyphenation_type
get_hyphenation_type();
342 class space_char_hmotion_node
: public hmotion_node
{
344 space_char_hmotion_node(hunits
, color
*, node
* = 0);
345 space_char_hmotion_node(hunits
, color
*, statem
*, int, node
* = 0);
347 void ascii_print(ascii_output_file
*);
348 void asciify(macro
*);
349 void tprint(troff_output_file
*);
354 node
*add_self(node
*, hyphen_list
**);
355 hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
356 hyphenation_type
get_hyphenation_type();
359 class vmotion_node
: public node
{
361 color
*col
; /* for grotty */
363 vmotion_node(vunits
, color
*);
364 vmotion_node(vunits
, color
*, statem
*, int);
365 void tprint(troff_output_file
*);
367 vunits
vertical_width();
374 class hline_node
: public node
{
378 hline_node(hunits
, node
*, node
* = 0);
379 hline_node(hunits
, node
*, statem
*, int, node
* = 0);
383 void tprint(troff_output_file
*);
390 class vline_node
: public node
{
394 vline_node(vunits
, node
*, node
* = 0);
395 vline_node(vunits
, node
*, statem
*, int, node
* = 0);
398 void tprint(troff_output_file
*);
400 vunits
vertical_width();
401 void vertical_extent(vunits
*, vunits
*);
408 class dummy_node
: public node
{
410 dummy_node(node
*nd
= 0) : node(nd
) {}
416 hyphenation_type
get_hyphenation_type();
419 class transparent_dummy_node
: public node
{
421 transparent_dummy_node(node
*nd
= 0) : node(nd
) {}
428 hyphenation_type
get_hyphenation_type();
431 class zero_width_node
: public node
{
434 zero_width_node(node
*);
435 zero_width_node(node
*, statem
*, int);
438 void tprint(troff_output_file
*);
444 int character_type();
445 void vertical_extent(vunits
*, vunits
*);
448 class left_italic_corrected_node
: public node
{
452 left_italic_corrected_node(node
* = 0);
453 left_italic_corrected_node(statem
*, int, node
* = 0);
454 ~left_italic_corrected_node();
455 void tprint(troff_output_file
*);
456 void ascii_print(ascii_output_file
*);
457 void asciify(macro
*);
464 node
*last_char_node();
465 void vertical_extent(vunits
*, vunits
*);
467 int overlaps_horizontally();
468 int overlaps_vertically();
469 hyphenation_type
get_hyphenation_type();
471 int character_type();
473 hunits
italic_correction();
474 hunits
subscript_correction();
475 hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
476 node
*add_self(node
*, hyphen_list
**);
477 node
*merge_glyph_node(glyph_node
*);
480 class overstrike_node
: public node
{
485 overstrike_node(statem
*, int);
488 void tprint(troff_output_file
*);
489 void overstrike(node
*); // add another node to be overstruck
495 node
*add_self(node
*, hyphen_list
**);
496 hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
497 hyphenation_type
get_hyphenation_type();
500 class bracket_node
: public node
{
505 bracket_node(statem
*, int);
508 void tprint(troff_output_file
*);
509 void bracket(node
*); // add another node to be overstruck
517 class special_node
: public node
{
523 void tprint_start(troff_output_file
*);
524 void tprint_char(troff_output_file
*, unsigned char);
525 void tprint_end(troff_output_file
*);
527 special_node(const macro
&, int = 0);
528 special_node(const macro
&, tfont
*, color
*, color
*, statem
*, int,
531 void tprint(troff_output_file
*);
540 class suppress_node
: public node
{
542 int emit_limits
; // must we issue the extent of the area written out?
547 suppress_node(int, int);
548 suppress_node(symbol
, char, int);
549 suppress_node(int, int, symbol
, char, int, statem
*, int);
550 suppress_node(int, int, symbol
, char, int);
552 void tprint(troff_output_file
*);
559 void put(troff_output_file
*, const char *);
562 class tag_node
: public node
{
567 tag_node(string
, int);
568 tag_node(string
, statem
*, int, int);
570 void tprint(troff_output_file
*);
584 class draw_node
: public node
{
592 draw_node(char, hvpair
*, int, font_size
, color
*, color
*);
593 draw_node(char, hvpair
*, int, font_size
, color
*, color
*, statem
*, int);
596 vunits
vertical_width();
598 void tprint(troff_output_file
*);
606 node
*make_node(charinfo
*, environment
*);
607 int character_exists(charinfo
*, environment
*);
609 int same_node_list(node
*, node
*);
610 node
*reverse_node_list(node
*);
611 void delete_node_list(node
*);
612 node
*copy_node_list(node
*);
614 int get_bold_fontno(int);
616 inline hyphen_list::hyphen_list(unsigned char code
, hyphen_list
*p
)
617 : hyphen(0), breakable(0), hyphenation_code(code
), next(p
)
621 extern void read_desc();
622 extern int mount_font(int, symbol
, symbol
= NULL_SYMBOL
);
623 extern int check_font(symbol
, symbol
);
624 extern int check_style(symbol
);
625 extern void mount_style(int, symbol
);
626 extern int is_good_fontno(int);
627 extern int symbol_fontno(symbol
);
628 extern int next_available_font_position();
629 extern void init_size_table(int *);
630 extern int get_underline_fontno();
633 char make_g_plus_plus_shut_up
;
636 virtual ~output_file();
637 virtual void trailer(vunits
);
638 virtual void flush() = 0;
639 virtual void transparent_char(unsigned char) = 0;
640 virtual void print_line(hunits x
, vunits y
, node
*n
,
641 vunits before
, vunits after
, hunits width
) = 0;
642 virtual void begin_page(int pageno
, vunits page_length
) = 0;
643 virtual void copy_file(hunits x
, vunits y
, const char *filename
) = 0;
644 virtual int is_printing() = 0;
645 virtual void put_filename(const char *);
649 virtual void vjustify(vunits
, symbol
);
654 #ifndef POPEN_MISSING
655 extern char *pipe_command
;
658 extern output_file
*the_output
;
659 extern void init_output();
660 int in_output_page_list(int);
669 int make_definite(int);
670 static void invalidate_fontno(int);
673 font_family
*lookup_family(symbol
);
674 symbol
get_font_name(int, environment
*);
675 symbol
get_style_name(int);
676 extern search_path include_search_path
;