2 * Copyright (c) 2014 - 2015 Steffen (Daode) Nurpmeso <sdaoden@users.sf.net>.
4 * Copyright (C) 1989 - 1992, 2000 - 2004, 2006
5 * Free Software Foundation, Inc.
6 * Written by James Clark (jjc@jclark.com)
8 * This 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 * This 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.
26 #include "troff-config.h"
32 unsigned char breakable
;
33 unsigned char hyphenation_code
;
36 hyphen_list(unsigned char code
, hyphen_list
*p
= 0);
39 void hyphenate(hyphen_list
*, unsigned);
41 enum hyphenation_type
{ HYPHEN_MIDDLE
, HYPHEN_BOUNDARY
, HYPHEN_INHIBIT
};
43 class ascii_output_file
;
51 class troff_output_file
;
56 class diverted_space_node
;
71 node(node
*, statem
*, int);
72 node
*add_char(charinfo
*, environment
*, hunits
*, int *, node
** = 0);
75 virtual node
*copy() = 0;
76 virtual int set_unformat_flag();
77 virtual int force_tprint() = 0;
78 virtual int is_tag() = 0;
79 virtual hunits
width();
80 virtual hunits
subscript_correction();
81 virtual hunits
italic_correction();
82 virtual hunits
left_italic_correction();
83 virtual hunits
skew();
84 virtual int nspaces();
85 virtual int merge_space(hunits
, hunits
, hunits
);
86 virtual vunits
vertical_width();
87 virtual node
*last_char_node();
88 virtual void vertical_extent(vunits
*, vunits
*);
89 virtual int character_type();
90 virtual void set_vertical_size(vertical_size
*);
91 virtual int ends_sentence();
92 virtual node
*merge_self(node
*);
93 virtual node
*add_discretionary_hyphen();
94 virtual node
*add_self(node
*, hyphen_list
**);
95 virtual hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
96 virtual void ascii_print(ascii_output_file
*);
97 virtual void asciify(macro
*);
98 virtual int discardable();
99 virtual void spread_space(int *, hunits
*);
100 virtual void freeze_space();
101 virtual void is_escape_colon();
102 virtual breakpoint
*get_breakpoints(hunits
, int, breakpoint
* = 0, int = 0);
103 virtual int nbreaks();
104 virtual void split(int, node
**, node
**);
105 virtual hyphenation_type
get_hyphenation_type();
106 virtual int reread(int *);
107 virtual token_node
*get_token_node();
108 virtual int overlaps_vertically();
109 virtual int overlaps_horizontally();
110 virtual units
size();
111 virtual int interpret(macro
*);
113 virtual node
*merge_glyph_node(glyph_node
*);
114 virtual tfont
*get_tfont();
115 virtual color
*get_glyph_color();
116 virtual color
*get_fill_color();
117 virtual void tprint(troff_output_file
*);
118 virtual void zero_width_tprint(troff_output_file
*);
120 node
*add_italic_correction(hunits
*);
122 virtual int same(node
*) = 0;
123 virtual const char *type() = 0;
124 virtual void debug_node();
125 virtual void debug_node_list();
129 : next(0), last(0), state(0), push_state(0), div_nest_level(0), is_special(0)
133 inline node::node(node
*n
)
134 : next(n
), last(0), state(0), push_state(0), div_nest_level(0), is_special(0)
138 inline node::node(node
*n
, statem
*s
, int divlevel
)
139 : next(n
), last(0), push_state(0), div_nest_level(divlevel
), is_special(0)
142 state
= new statem(s
);
151 // 0 means it doesn't, 1 means it does, 2 means it's transparent
153 int node_list_ends_sentence(node
*);
164 class line_start_node
169 node
*copy() { return new line_start_node
; }
174 void asciify(macro
*);
181 enum { BLOCK
= 1024 };
182 static space_node
*free_list
;
183 void operator delete(void *);
189 char was_escape_colon
;
190 color
*col
; /* for grotty */
192 space_node(hunits
, int, int, color
*, statem
*, int, node
* = 0);
195 space_node(hunits
, color
*, statem
*, int, node
* = 0);
196 space_node(hunits
, color
*, node
* = 0);
199 void *operator new(size_t);
205 int merge_space(hunits
, hunits
, hunits
);
207 void is_escape_colon();
208 void spread_space(int *, hunits
*);
209 void tprint(troff_output_file
*);
210 breakpoint
*get_breakpoints(hunits
, int, breakpoint
* = 0, int = 0);
212 void split(int, node
**, node
**);
213 void ascii_print(ascii_output_file
*);
215 void asciify(macro
*);
219 hyphenation_type
get_hyphenation_type();
226 hunits sentence_width
;
229 width_list(hunits
, hunits
);
230 width_list(width_list
*);
233 class word_space_node
237 width_list
*orig_width
;
238 unsigned char unformat
;
240 word_space_node(hunits
, int, color
*, width_list
*, int, statem
*, int,
244 word_space_node(hunits
, color
*, width_list
*, node
* = 0);
248 int set_unformat_flag();
249 void tprint(troff_output_file
*);
251 void asciify(macro
*);
253 int merge_space(hunits
, hunits
, hunits
);
258 class unbreakable_space_node
259 : public word_space_node
261 unbreakable_space_node(hunits
, int, color
*, statem
*, int, node
* = 0);
264 unbreakable_space_node(hunits
, color
*, node
* = 0);
267 void tprint(troff_output_file
*);
269 void asciify(macro
*);
273 breakpoint
*get_breakpoints(hunits
, int, breakpoint
* = 0, int = 0);
275 void split(int, node
**, node
**);
276 int merge_space(hunits
, hunits
, hunits
);
277 node
*add_self(node
*, hyphen_list
**);
278 hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
279 hyphenation_type
get_hyphenation_type();
282 class diverted_space_node
288 diverted_space_node(vunits
, node
* = 0);
289 diverted_space_node(vunits
, statem
*, int, node
* = 0);
298 class diverted_copy_file_node
306 diverted_copy_file_node(symbol
, node
* = 0);
307 diverted_copy_file_node(symbol
, statem
*, int, node
* = 0);
316 class extra_size_node
322 extra_size_node(vunits
);
323 extra_size_node(vunits
, statem
*, int);
324 void set_vertical_size(vertical_size
*);
332 class vertical_size_node
338 vertical_size_node(vunits
, statem
*, int);
339 vertical_size_node(vunits
);
340 void set_vertical_size(vertical_size
*);
341 void asciify(macro
*);
343 int set_unformat_flag();
355 unsigned char was_tab
;
356 unsigned char unformat
;
357 color
*col
; /* for grotty */
360 hmotion_node(hunits i
, color
*c
, node
*nxt
= 0)
361 : node(nxt
), n(i
), was_tab(0), unformat(0), col(c
) {}
362 hmotion_node(hunits i
, color
*c
, statem
*s
, int divlevel
, node
*nxt
= 0)
363 : node(nxt
, s
, divlevel
), n(i
), was_tab(0), unformat(0), col(c
) {}
364 hmotion_node(hunits i
, int flag1
, int flag2
, color
*c
, statem
*s
,
365 int divlevel
, node
*nxt
= 0)
366 : node(nxt
, s
, divlevel
), n(i
), was_tab(flag1
), unformat(flag2
),
368 hmotion_node(hunits i
, int flag1
, int flag2
, color
*c
, node
*nxt
= 0)
369 : node(nxt
), n(i
), was_tab(flag1
), unformat(flag2
), col(c
) {}
372 int set_unformat_flag();
373 void asciify(macro
*);
374 void tprint(troff_output_file
*);
376 void ascii_print(ascii_output_file
*);
381 node
*add_self(node
*, hyphen_list
**);
382 hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
383 hyphenation_type
get_hyphenation_type();
386 class space_char_hmotion_node
387 : public hmotion_node
390 space_char_hmotion_node(hunits
, color
*, node
* = 0);
391 space_char_hmotion_node(hunits
, color
*, statem
*, int, node
* = 0);
393 void ascii_print(ascii_output_file
*);
394 void asciify(macro
*);
395 void tprint(troff_output_file
*);
400 node
*add_self(node
*, hyphen_list
**);
401 hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
402 hyphenation_type
get_hyphenation_type();
409 color
*col
; /* for grotty */
412 vmotion_node(vunits
, color
*);
413 vmotion_node(vunits
, color
*, statem
*, int);
414 void tprint(troff_output_file
*);
416 vunits
vertical_width();
430 hline_node(hunits
, node
*, node
* = 0);
431 hline_node(hunits
, node
*, statem
*, int, node
* = 0);
435 void tprint(troff_output_file
*);
449 vline_node(vunits
, node
*, node
* = 0);
450 vline_node(vunits
, node
*, statem
*, int, node
* = 0);
453 void tprint(troff_output_file
*);
455 vunits
vertical_width();
456 void vertical_extent(vunits
*, vunits
*);
467 dummy_node(node
*nd
= 0) : node(nd
) {}
473 hyphenation_type
get_hyphenation_type();
476 class transparent_dummy_node
480 transparent_dummy_node(node
*nd
= 0) : node(nd
) {}
487 hyphenation_type
get_hyphenation_type();
490 class zero_width_node
496 zero_width_node(node
*);
497 zero_width_node(node
*, statem
*, int);
500 void tprint(troff_output_file
*);
506 int character_type();
507 void vertical_extent(vunits
*, vunits
*);
510 class left_italic_corrected_node
517 left_italic_corrected_node(node
* = 0);
518 left_italic_corrected_node(statem
*, int, node
* = 0);
519 ~left_italic_corrected_node();
520 void tprint(troff_output_file
*);
521 void ascii_print(ascii_output_file
*);
522 void asciify(macro
*);
529 node
*last_char_node();
530 void vertical_extent(vunits
*, vunits
*);
532 int overlaps_horizontally();
533 int overlaps_vertically();
534 hyphenation_type
get_hyphenation_type();
536 int character_type();
538 hunits
italic_correction();
539 hunits
subscript_correction();
540 hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
541 node
*add_self(node
*, hyphen_list
**);
542 node
*merge_glyph_node(glyph_node
*);
545 class overstrike_node
553 overstrike_node(statem
*, int);
556 void tprint(troff_output_file
*);
557 void overstrike(node
*); // add another node to be overstruck
563 node
*add_self(node
*, hyphen_list
**);
564 hyphen_list
*get_hyphen_list(hyphen_list
*, int *);
565 hyphenation_type
get_hyphenation_type();
576 bracket_node(statem
*, int);
579 void tprint(troff_output_file
*);
580 void bracket(node
*); // add another node to be overstruck
597 void tprint_start(troff_output_file
*);
598 void tprint_char(troff_output_file
*, unsigned char);
599 void tprint_end(troff_output_file
*);
602 special_node(const macro
&, int = 0);
603 special_node(const macro
&, tfont
*, color
*, color
*, statem
*, int,
606 void tprint(troff_output_file
*);
619 int emit_limits
; // must we issue the extent of the area written out?
624 void put(troff_output_file
*, const char *);
627 suppress_node(int, int);
628 suppress_node(symbol
, char, int);
629 suppress_node(int, int, symbol
, char, int, statem
*, int);
630 suppress_node(int, int, symbol
, char, int);
632 void tprint(troff_output_file
*);
648 tag_node(string
, int);
649 tag_node(string
, statem
*, int, int);
651 void tprint(troff_output_file
*);
679 draw_node(char, hvpair
*, int, font_size
, color
*, color
*);
680 draw_node(char, hvpair
*, int, font_size
, color
*, color
*, statem
*, int);
683 vunits
vertical_width();
685 void tprint(troff_output_file
*);
693 node
*make_node(charinfo
*, environment
*);
694 int character_exists(charinfo
*, environment
*);
696 int same_node_list(node
*, node
*);
697 node
*reverse_node_list(node
*);
698 void delete_node_list(node
*);
699 node
*copy_node_list(node
*);
701 int get_bold_fontno(int);
703 inline hyphen_list::hyphen_list(unsigned char code
, hyphen_list
*p
)
704 : hyphen(0), breakable(0), hyphenation_code(code
), next(p
)
708 extern void read_desc();
709 extern int mount_font(int, symbol
, symbol
= NULL_SYMBOL
);
710 extern int check_font(symbol
, symbol
);
711 extern int check_style(symbol
);
712 extern void mount_style(int, symbol
);
713 extern int is_good_fontno(int);
714 extern int symbol_fontno(symbol
);
715 extern int next_available_font_position();
716 extern void init_size_table(int *);
717 extern int get_underline_fontno();
721 char make_g_plus_plus_shut_up
;
725 virtual ~output_file();
726 virtual void trailer(vunits
);
727 virtual void flush() = 0;
728 virtual void transparent_char(unsigned char) = 0;
729 virtual void print_line(hunits x
, vunits y
, node
*n
,
730 vunits before
, vunits after
, hunits width
) = 0;
731 virtual void begin_page(int pageno
, vunits page_length
) = 0;
732 virtual void copy_file(hunits x
, vunits y
, const char *filename
) = 0;
733 virtual int is_printing() = 0;
734 virtual void put_filename(const char *, int);
738 virtual void vjustify(vunits
, symbol
);
743 #ifndef POPEN_MISSING
744 extern char *pipe_command
;
747 extern output_file
*the_output
;
748 extern void init_output();
749 int in_output_page_list(int);
761 int make_definite(int);
762 static void invalidate_fontno(int);
765 font_family
*lookup_family(symbol
);
766 symbol
get_font_name(int, environment
*);
767 symbol
get_style_name(int);
768 extern search_path include_search_path
;