51 |
dictionary env_dictionary(10); |
dictionary env_dictionary(10); |
52 |
environment *curenv; |
environment *curenv; |
53 |
static int next_line_number = 0; |
static int next_line_number = 0; |
54 |
|
extern int suppress_push; |
55 |
|
extern statem *get_diversion_state(); |
56 |
|
|
57 |
charinfo *field_delimiter_char; |
charinfo *field_delimiter_char; |
58 |
charinfo *padding_indicator_char; |
charinfo *padding_indicator_char; |
62 |
class pending_output_line { |
class pending_output_line { |
63 |
node *nd; |
node *nd; |
64 |
int no_fill; |
int no_fill; |
65 |
|
int was_centered; |
66 |
vunits vs; |
vunits vs; |
67 |
vunits post_vs; |
vunits post_vs; |
68 |
hunits width; |
hunits width; |
72 |
public: |
public: |
73 |
pending_output_line *next; |
pending_output_line *next; |
74 |
|
|
75 |
pending_output_line(node *, int, vunits, vunits, hunits, |
pending_output_line(node *, int, vunits, vunits, hunits, int, |
76 |
pending_output_line * = 0); |
pending_output_line * = 0); |
77 |
~pending_output_line(); |
~pending_output_line(); |
78 |
int output(); |
int output(); |
79 |
|
|
80 |
#ifdef WIDOW_CONTROL |
#ifdef WIDOW_CONTROL |
81 |
friend void environment::mark_last_line(); |
friend void environment::mark_last_line(); |
82 |
friend void environment::output(node *, int, vunits, vunits, hunits); |
friend void environment::output(node *, int, vunits, vunits, hunits, int); |
83 |
#endif /* WIDOW_CONTROL */ |
#endif /* WIDOW_CONTROL */ |
84 |
}; |
}; |
85 |
|
|
86 |
pending_output_line::pending_output_line(node *n, int nf, vunits v, vunits pv, |
pending_output_line::pending_output_line(node *n, int nf, vunits v, vunits pv, |
87 |
hunits w, pending_output_line *p) |
hunits w, int ce, |
88 |
: nd(n), no_fill(nf), vs(v), post_vs(pv), width(w), |
pending_output_line *p) |
89 |
|
: nd(n), no_fill(nf), was_centered(ce), vs(v), post_vs(pv), width(w), |
90 |
#ifdef WIDOW_CONTROL |
#ifdef WIDOW_CONTROL |
91 |
last_line(0), |
last_line(0), |
92 |
#endif /* WIDOW_CONTROL */ |
#endif /* WIDOW_CONTROL */ |
112 |
} |
} |
113 |
} |
} |
114 |
#endif |
#endif |
115 |
|
curenv->construct_format_state(nd, was_centered, !no_fill); |
116 |
curdiv->output(nd, no_fill, vs, post_vs, width); |
curdiv->output(nd, no_fill, vs, post_vs, width); |
117 |
nd = 0; |
nd = 0; |
118 |
return 1; |
return 1; |
120 |
|
|
121 |
void environment::output(node *nd, int no_fill_flag, |
void environment::output(node *nd, int no_fill_flag, |
122 |
vunits vs, vunits post_vs, |
vunits vs, vunits post_vs, |
123 |
hunits width) |
hunits width, int was_centered) |
124 |
{ |
{ |
125 |
#ifdef WIDOW_CONTROL |
#ifdef WIDOW_CONTROL |
126 |
while (pending_lines) { |
while (pending_lines) { |
140 |
&& (!widow_control || no_fill_flag) |
&& (!widow_control || no_fill_flag) |
141 |
#endif /* WIDOW_CONTROL */ |
#endif /* WIDOW_CONTROL */ |
142 |
) { |
) { |
143 |
|
curenv->construct_format_state(nd, was_centered, !no_fill_flag); |
144 |
curdiv->output(nd, no_fill_flag, vs, post_vs, width); |
curdiv->output(nd, no_fill_flag, vs, post_vs, width); |
|
emitted_node = 1; |
|
145 |
} else { |
} else { |
146 |
pending_output_line **p; |
pending_output_line **p; |
147 |
for (p = &pending_lines; *p; p = &(*p)->next) |
for (p = &pending_lines; *p; p = &(*p)->next) |
148 |
; |
; |
149 |
*p = new pending_output_line(nd, no_fill_flag, vs, post_vs, width); |
*p = new pending_output_line(nd, no_fill_flag, vs, post_vs, width, |
150 |
|
was_centered); |
151 |
} |
} |
152 |
} |
} |
153 |
|
|
161 |
curdiv->output(nd, no_fill_flag, vs, post_vs, width); |
curdiv->output(nd, no_fill_flag, vs, post_vs, width); |
162 |
else |
else |
163 |
pending_lines = new pending_output_line(nd, no_fill_flag, vs, post_vs, |
pending_lines = new pending_output_line(nd, no_fill_flag, vs, post_vs, |
164 |
width, pending_lines); |
width, 0, pending_lines); |
165 |
} |
} |
166 |
|
|
167 |
void environment::output_pending_lines() |
void environment::output_pending_lines() |
272 |
void environment::add_char(charinfo *ci) |
void environment::add_char(charinfo *ci) |
273 |
{ |
{ |
274 |
int s; |
int s; |
275 |
|
node *gc_np = 0; |
276 |
if (interrupted) |
if (interrupted) |
277 |
; |
; |
278 |
// don't allow fields in dummy environments |
// don't allow fields in dummy environments |
288 |
if (tab_contents == 0) |
if (tab_contents == 0) |
289 |
tab_contents = new line_start_node; |
tab_contents = new line_start_node; |
290 |
if (ci != hyphen_indicator_char) |
if (ci != hyphen_indicator_char) |
291 |
tab_contents = tab_contents->add_char(ci, this, &tab_width, &s); |
tab_contents = tab_contents->add_char(ci, this, &tab_width, &s, &gc_np); |
292 |
else |
else |
293 |
tab_contents = tab_contents->add_discretionary_hyphen(); |
tab_contents = tab_contents->add_discretionary_hyphen(); |
294 |
} |
} |
295 |
else { |
else { |
296 |
if (line == 0) |
if (line == 0) |
297 |
start_line(); |
start_line(); |
298 |
|
#if 0 |
299 |
|
fprintf(stderr, "current line is\n"); |
300 |
|
line->debug_node_list(); |
301 |
|
#endif |
302 |
if (ci != hyphen_indicator_char) |
if (ci != hyphen_indicator_char) |
303 |
line = line->add_char(ci, this, &width_total, &space_total); |
line = line->add_char(ci, this, &width_total, &space_total, &gc_np); |
304 |
else |
else |
305 |
line = line->add_discretionary_hyphen(); |
line = line->add_discretionary_hyphen(); |
306 |
} |
} |
307 |
|
#if 0 |
308 |
|
fprintf(stderr, "now after we have added character the line is\n"); |
309 |
|
line->debug_node_list(); |
310 |
|
#endif |
311 |
|
if ((!suppress_push) && gc_np) { |
312 |
|
if (gc_np && (gc_np->state == 0)) { |
313 |
|
gc_np->state = construct_state(0); |
314 |
|
gc_np->push_state = get_diversion_state(); |
315 |
|
} |
316 |
|
else if (line && (line->state == 0)) { |
317 |
|
line->state = construct_state(0); |
318 |
|
line->push_state = get_diversion_state(); |
319 |
|
} |
320 |
|
} |
321 |
|
#if 0 |
322 |
|
fprintf(stderr, "now we have possibly added the state the line is\n"); |
323 |
|
line->debug_node_list(); |
324 |
|
#endif |
325 |
} |
} |
326 |
|
|
327 |
node *environment::make_char_node(charinfo *ci) |
node *environment::make_char_node(charinfo *ci) |
333 |
{ |
{ |
334 |
if (n == 0) |
if (n == 0) |
335 |
return; |
return; |
336 |
|
if (!suppress_push) { |
337 |
|
if (n->is_special && n->state == NULL) |
338 |
|
n->state = construct_state(0); |
339 |
|
n->push_state = get_diversion_state(); |
340 |
|
} |
341 |
|
|
342 |
if (current_tab || current_field) |
if (current_tab || current_field) |
343 |
n->freeze_space(); |
n->freeze_space(); |
344 |
if (interrupted) { |
if (interrupted) { |
362 |
space_total += n->nspaces(); |
space_total += n->nspaces(); |
363 |
n->next = line; |
n->next = line; |
364 |
line = n; |
line = n; |
365 |
|
construct_new_line_state(line); |
366 |
} |
} |
367 |
} |
} |
368 |
|
|
|
|
|
369 |
void environment::add_hyphen_indicator() |
void environment::add_hyphen_indicator() |
370 |
{ |
{ |
371 |
if (current_tab || interrupted || current_field |
if (current_tab || interrupted || current_field |
622 |
prev_requested_size(sizescale*10), |
prev_requested_size(sizescale*10), |
623 |
char_height(0), |
char_height(0), |
624 |
char_slant(0), |
char_slant(0), |
625 |
|
seen_space(0), |
626 |
|
seen_eol(0), |
627 |
|
suppress_next_eol(0), |
628 |
|
seen_break(0), |
629 |
space_size(12), |
space_size(12), |
630 |
sentence_space_size(12), |
sentence_space_size(12), |
631 |
adjust_mode(ADJUST_BOTH), |
adjust_mode(ADJUST_BOTH), |
680 |
#ifdef WIDOW_CONTROL |
#ifdef WIDOW_CONTROL |
681 |
widow_control(0), |
widow_control(0), |
682 |
#endif /* WIDOW_CONTROL */ |
#endif /* WIDOW_CONTROL */ |
|
ignore_next_eol(0), |
|
|
emitted_node(0), |
|
683 |
glyph_color(&default_color), |
glyph_color(&default_color), |
684 |
prev_glyph_color(&default_color), |
prev_glyph_color(&default_color), |
685 |
fill_color(&default_color), |
fill_color(&default_color), |
714 |
fontno(e->fontno), |
fontno(e->fontno), |
715 |
prev_family(e->prev_family), |
prev_family(e->prev_family), |
716 |
family(e->family), |
family(e->family), |
717 |
|
seen_space(e->seen_space), |
718 |
|
seen_eol(e->seen_eol), |
719 |
|
suppress_next_eol(e->suppress_next_eol), |
720 |
|
seen_break(e->seen_break), |
721 |
space_size(e->space_size), |
space_size(e->space_size), |
722 |
sentence_space_size(e->sentence_space_size), |
sentence_space_size(e->sentence_space_size), |
723 |
adjust_mode(e->adjust_mode), |
adjust_mode(e->adjust_mode), |
772 |
#ifdef WIDOW_CONTROL |
#ifdef WIDOW_CONTROL |
773 |
widow_control(e->widow_control), |
widow_control(e->widow_control), |
774 |
#endif /* WIDOW_CONTROL */ |
#endif /* WIDOW_CONTROL */ |
|
ignore_next_eol(0), |
|
|
emitted_node(0), |
|
775 |
glyph_color(e->glyph_color), |
glyph_color(e->glyph_color), |
776 |
prev_glyph_color(e->prev_glyph_color), |
prev_glyph_color(e->prev_glyph_color), |
777 |
fill_color(e->fill_color), |
fill_color(e->fill_color), |
857 |
hyphenation_space = e->hyphenation_space; |
hyphenation_space = e->hyphenation_space; |
858 |
hyphenation_margin = e->hyphenation_margin; |
hyphenation_margin = e->hyphenation_margin; |
859 |
composite = 0; |
composite = 0; |
|
ignore_next_eol = e->ignore_next_eol; |
|
|
emitted_node = e->emitted_node; |
|
860 |
glyph_color= e->glyph_color; |
glyph_color= e->glyph_color; |
861 |
prev_glyph_color = e->prev_glyph_color; |
prev_glyph_color = e->prev_glyph_color; |
862 |
fill_color = e->fill_color; |
fill_color = e->fill_color; |
1223 |
if (n <= 0) |
if (n <= 0) |
1224 |
n = 1; |
n = 1; |
1225 |
curenv->set_size(n); |
curenv->set_size(n); |
|
curenv->add_html_tag(0, ".ps", n); |
|
1226 |
} |
} |
1227 |
else |
else |
1228 |
curenv->set_size(0); |
curenv->set_size(0); |
1290 |
if (break_flag) |
if (break_flag) |
1291 |
curenv->do_break(); |
curenv->do_break(); |
1292 |
curenv->fill = 1; |
curenv->fill = 1; |
|
curenv->add_html_tag(1, ".fi"); |
|
|
curenv->add_html_tag(0, ".br"); |
|
1293 |
tok.next(); |
tok.next(); |
1294 |
} |
} |
1295 |
|
|
1300 |
if (break_flag) |
if (break_flag) |
1301 |
curenv->do_break(); |
curenv->do_break(); |
1302 |
curenv->fill = 0; |
curenv->fill = 0; |
1303 |
curenv->add_html_tag(1, ".nf"); |
curenv->suppress_next_eol = 1; |
|
curenv->add_html_tag(0, ".br"); |
|
|
curenv->add_html_tag(0, ".po", topdiv->get_page_offset().to_units()); |
|
1304 |
tok.next(); |
tok.next(); |
1305 |
} |
} |
1306 |
|
|
1317 |
curenv->do_break(); |
curenv->do_break(); |
1318 |
curenv->right_justify_lines = 0; |
curenv->right_justify_lines = 0; |
1319 |
curenv->center_lines = n; |
curenv->center_lines = n; |
1320 |
curenv->add_html_tag(1, ".ce", n); |
curdiv->modified_tag.incl(MTSM_CE); |
1321 |
tok.next(); |
tok.next(); |
1322 |
} |
} |
1323 |
|
|
1334 |
curenv->do_break(); |
curenv->do_break(); |
1335 |
curenv->center_lines = 0; |
curenv->center_lines = 0; |
1336 |
curenv->right_justify_lines = n; |
curenv->right_justify_lines = n; |
1337 |
curenv->add_html_tag(1, ".rj", n); |
curdiv->modified_tag.incl(MTSM_RJ); |
1338 |
tok.next(); |
tok.next(); |
1339 |
} |
} |
1340 |
|
|
1351 |
temp = curenv->prev_line_length; |
temp = curenv->prev_line_length; |
1352 |
curenv->prev_line_length = curenv->line_length; |
curenv->prev_line_length = curenv->line_length; |
1353 |
curenv->line_length = temp; |
curenv->line_length = temp; |
1354 |
curenv->add_html_tag(1, ".ll", temp.to_units()); |
curdiv->modified_tag.incl(MTSM_LL); |
1355 |
skip_line(); |
skip_line(); |
1356 |
} |
} |
1357 |
|
|
1438 |
curenv->have_temporary_indent = 0; |
curenv->have_temporary_indent = 0; |
1439 |
curenv->prev_indent = curenv->indent; |
curenv->prev_indent = curenv->indent; |
1440 |
curenv->indent = temp; |
curenv->indent = temp; |
1441 |
if (break_flag) |
curdiv->modified_tag.incl(MTSM_IN); |
|
curenv->add_html_tag(1, ".in", temp.to_units()); |
|
1442 |
tok.next(); |
tok.next(); |
1443 |
} |
} |
1444 |
|
|
1459 |
if (!err) { |
if (!err) { |
1460 |
curenv->temporary_indent = temp; |
curenv->temporary_indent = temp; |
1461 |
curenv->have_temporary_indent = 1; |
curenv->have_temporary_indent = 1; |
1462 |
curenv->add_html_tag(1, ".ti", temp.to_units()); |
curdiv->modified_tag.incl(MTSM_TI); |
1463 |
} |
} |
1464 |
tok.next(); |
tok.next(); |
1465 |
} |
} |
1676 |
|
|
1677 |
void environment::newline() |
void environment::newline() |
1678 |
{ |
{ |
1679 |
|
int was_centered = 0; |
1680 |
if (underline_lines > 0) { |
if (underline_lines > 0) { |
1681 |
if (--underline_lines == 0) { |
if (--underline_lines == 0) { |
1682 |
prev_fontno = fontno; |
prev_fontno = fontno; |
1715 |
if (x > H0) |
if (x > H0) |
1716 |
saved_indent += x/2; |
saved_indent += x/2; |
1717 |
to_be_output = line; |
to_be_output = line; |
1718 |
if (is_html) { |
was_centered = 1; |
|
node *n = make_html_tag("eol.ce"); |
|
|
n->next = to_be_output; |
|
|
to_be_output = n; |
|
|
} |
|
1719 |
to_be_output_width = width_total; |
to_be_output_width = width_total; |
1720 |
line = 0; |
line = 0; |
1721 |
} |
} |
1738 |
input_line_start = line == 0 ? H0 : width_total; |
input_line_start = line == 0 ? H0 : width_total; |
1739 |
if (to_be_output) { |
if (to_be_output) { |
1740 |
if (is_html && !fill) { |
if (is_html && !fill) { |
1741 |
if (curdiv == topdiv) { |
curdiv->modified_tag.incl(MTSM_EOL); |
1742 |
node *n = make_html_tag("eol"); |
if (suppress_next_eol) |
1743 |
|
suppress_next_eol = 0; |
1744 |
n->next = to_be_output; |
else |
1745 |
to_be_output = n; |
seen_eol = 1; |
|
} |
|
1746 |
} |
} |
1747 |
output_line(to_be_output, to_be_output_width); |
|
1748 |
|
output_line(to_be_output, to_be_output_width, was_centered); |
1749 |
hyphen_line_count = 0; |
hyphen_line_count = 0; |
1750 |
} |
} |
1751 |
if (input_trap_count > 0) { |
if (input_trap_count > 0) { |
1755 |
} |
} |
1756 |
} |
} |
1757 |
|
|
1758 |
void environment::output_line(node *n, hunits width) |
void environment::output_line(node *n, hunits width, int was_centered) |
1759 |
{ |
{ |
1760 |
prev_text_length = width; |
prev_text_length = width; |
1761 |
if (margin_character_flags) { |
if (margin_character_flags) { |
1814 |
width += w; |
width += w; |
1815 |
++next_line_number; |
++next_line_number; |
1816 |
} |
} |
1817 |
output(nn, !fill, vertical_spacing, total_post_vertical_spacing(), width); |
output(nn, !fill, vertical_spacing, total_post_vertical_spacing(), width, |
1818 |
|
was_centered); |
1819 |
} |
} |
1820 |
|
|
1821 |
void environment::start_line() |
void environment::start_line() |
2063 |
|
|
2064 |
void environment::possibly_break_line(int start_here, int forced) |
void environment::possibly_break_line(int start_here, int forced) |
2065 |
{ |
{ |
2066 |
|
int was_centered = center_lines > 0; |
2067 |
if (!fill || current_tab || current_field || dummy) |
if (!fill || current_tab || current_field || dummy) |
2068 |
return; |
return; |
2069 |
while (line != 0 |
while (line != 0 |
2093 |
break; |
break; |
2094 |
case ADJUST_CENTER: |
case ADJUST_CENTER: |
2095 |
saved_indent += (target_text_length - bp->width)/2; |
saved_indent += (target_text_length - bp->width)/2; |
2096 |
|
was_centered = 1; |
2097 |
break; |
break; |
2098 |
case ADJUST_RIGHT: |
case ADJUST_RIGHT: |
2099 |
saved_indent += target_text_length - bp->width; |
saved_indent += target_text_length - bp->width; |
2131 |
} |
} |
2132 |
// Do output_line() here so that line will be 0 iff the |
// Do output_line() here so that line will be 0 iff the |
2133 |
// the environment will be empty. |
// the environment will be empty. |
2134 |
output_line(pre, output_width); |
output_line(pre, output_width, was_centered); |
2135 |
while (to_be_discarded != 0) { |
while (to_be_discarded != 0) { |
2136 |
tem = to_be_discarded; |
tem = to_be_discarded; |
2137 |
to_be_discarded = to_be_discarded->next; |
to_be_discarded = to_be_discarded->next; |
2194 |
do_break(); |
do_break(); |
2195 |
} |
} |
2196 |
|
|
2197 |
/* |
node *environment::make_tag(const char *name, int i) |
|
* add_html_tag - emits a special html-tag: to help post-grohtml understand |
|
|
* the key troff commands |
|
|
*/ |
|
|
|
|
|
void environment::add_html_tag(int force, const char *nm) |
|
2198 |
{ |
{ |
|
if (!force && (curdiv != topdiv)) |
|
|
return; |
|
|
|
|
2199 |
if (is_html) { |
if (is_html) { |
2200 |
/* |
/* |
2201 |
* need to emit tag for post-grohtml |
* need to emit tag for post-grohtml |
2205 |
topdiv->begin_page(); |
topdiv->begin_page(); |
2206 |
macro *m = new macro; |
macro *m = new macro; |
2207 |
m->append_str("html-tag:"); |
m->append_str("html-tag:"); |
2208 |
for (const char *p = nm; *p; p++) |
for (const char *p = name; *p; p++) |
|
if (!invalid_input_char((unsigned char)*p)) |
|
|
m->append(*p); |
|
|
curdiv->output(new special_node(*m), 1, 0, 0, 0); |
|
|
if (strcmp(nm, ".nf") == 0) |
|
|
curenv->ignore_next_eol = 1; |
|
|
} |
|
|
} |
|
|
|
|
|
/* |
|
|
* add_html_tag - emits a special html-tag: to help post-grohtml understand |
|
|
* the key troff commands, it appends a string representation |
|
|
* of i. |
|
|
*/ |
|
|
|
|
|
void environment::add_html_tag(int force, const char *nm, int i) |
|
|
{ |
|
|
if (!force && (curdiv != topdiv)) |
|
|
return; |
|
|
|
|
|
if (is_html) { |
|
|
/* |
|
|
* need to emit tag for post-grohtml |
|
|
* but we check to see whether we can emit specials |
|
|
*/ |
|
|
if (curdiv == topdiv && topdiv->before_first_page) |
|
|
topdiv->begin_page(); |
|
|
macro *m = new macro; |
|
|
m->append_str("html-tag:"); |
|
|
for (const char *p = nm; *p; p++) |
|
2209 |
if (!invalid_input_char((unsigned char)*p)) |
if (!invalid_input_char((unsigned char)*p)) |
2210 |
m->append(*p); |
m->append(*p); |
2211 |
m->append(' '); |
m->append(' '); |
2212 |
m->append_int(i); |
m->append_int(i); |
2213 |
node *n = new special_node(*m); |
return new special_node(*m); |
|
curdiv->output(n, 1, 0, 0, 0); |
|
2214 |
} |
} |
2215 |
|
return 0; |
2216 |
} |
} |
2217 |
|
|
2218 |
/* |
void environment::dump_troff_state() |
|
* add_html_tag_tabs - emits the tab settings for post-grohtml |
|
|
*/ |
|
|
|
|
|
void environment::add_html_tag_tabs(int force) |
|
2219 |
{ |
{ |
2220 |
if (!force && (curdiv != topdiv)) |
#define SPACES " " |
2221 |
return; |
fprintf(stderr, SPACES "register `in' = %d\n", curenv->indent.to_units()); |
2222 |
|
if (curenv->have_temporary_indent) |
2223 |
|
fprintf(stderr, SPACES "register `ti' = %d\n", |
2224 |
|
curenv->temporary_indent.to_units()); |
2225 |
|
fprintf(stderr, SPACES "centered lines `ce' = %d\n", curenv->center_lines); |
2226 |
|
fprintf(stderr, SPACES "register `ll' = %d\n", |
2227 |
|
curenv->line_length.to_units()); |
2228 |
|
fprintf(stderr, SPACES "fill `fi=1/nf=0' = %d\n", curenv->fill); |
2229 |
|
fprintf(stderr, SPACES "page offset `po' = %d\n", |
2230 |
|
topdiv->get_page_offset().to_units()); |
2231 |
|
fprintf(stderr, SPACES "seen_break = %d\n", curenv->seen_break); |
2232 |
|
fprintf(stderr, SPACES "seen_space = %d\n", curenv->seen_space); |
2233 |
|
fflush(stderr); |
2234 |
|
#undef SPACES |
2235 |
|
} |
2236 |
|
|
2237 |
|
statem *environment::construct_state(int only_eol) |
2238 |
|
{ |
2239 |
if (is_html) { |
if (is_html) { |
2240 |
/* |
statem *s = new statem(); |
2241 |
* need to emit tag for post-grohtml |
if (!only_eol) { |
2242 |
* but we check to see whether we can emit specials |
s->add_tag(MTSM_IN, indent); |
2243 |
*/ |
s->add_tag(MTSM_LL, line_length); |
2244 |
if (curdiv == topdiv && topdiv->before_first_page) |
s->add_tag(MTSM_PO, topdiv->get_page_offset().to_units()); |
2245 |
topdiv->begin_page(); |
s->add_tag(MTSM_RJ, right_justify_lines); |
2246 |
macro *m = new macro; |
if (have_temporary_indent) |
2247 |
hunits d, l; |
s->add_tag(MTSM_TI, temporary_indent); |
2248 |
enum tab_type t; |
s->add_tag_ta(); |
2249 |
m->append_str("html-tag:.ta "); |
if (seen_break) |
2250 |
do { |
s->add_tag(MTSM_BR); |
2251 |
t = curenv->tabs.distance_to_next_tab(l, &d); |
if (seen_space != 0) |
2252 |
l += d; |
s->add_tag(MTSM_SP, seen_space); |
2253 |
switch (t) { |
seen_break = 0; |
2254 |
case TAB_LEFT: |
seen_space = 0; |
2255 |
m->append_str(" L "); |
} |
2256 |
m->append_int(l.to_units()); |
if (seen_eol) { |
2257 |
break; |
s->add_tag(MTSM_EOL); |
2258 |
case TAB_CENTER: |
s->add_tag(MTSM_CE, center_lines); |
2259 |
m->append_str(" C "); |
} |
2260 |
m->append_int(l.to_units()); |
seen_eol = 0; |
2261 |
break; |
return s; |
|
case TAB_RIGHT: |
|
|
m->append_str(" R "); |
|
|
m->append_int(l.to_units()); |
|
|
break; |
|
|
case TAB_NONE: |
|
|
break; |
|
|
} |
|
|
} while ((t != TAB_NONE) && (l < get_line_length())); |
|
|
curdiv->output(new special_node(*m), 1, 0, 0, 0); |
|
2262 |
} |
} |
2263 |
|
else |
2264 |
|
return NULL; |
2265 |
} |
} |
2266 |
|
|
2267 |
node *environment::make_html_tag(const char *nm, int i) |
void environment::construct_format_state(node *n, int was_centered, int fill) |
2268 |
{ |
{ |
2269 |
if (is_html) { |
if (is_html) { |
2270 |
/* |
// find first glyph node which has a state. |
2271 |
* need to emit tag for post-grohtml |
while (n != 0 && n->state == 0) |
2272 |
* but we check to see whether we can emit specials |
n = n->next; |
2273 |
*/ |
if (n == 0 || (n->state == 0)) |
2274 |
if (curdiv == topdiv && topdiv->before_first_page) |
return; |
2275 |
topdiv->begin_page(); |
if (seen_space != 0) |
2276 |
macro *m = new macro; |
n->state->add_tag(MTSM_SP, seen_space); |
2277 |
m->append_str("html-tag:"); |
if (seen_eol && topdiv == curdiv) |
2278 |
for (const char *p = nm; *p; p++) |
n->state->add_tag(MTSM_EOL); |
2279 |
if (!invalid_input_char((unsigned char)*p)) |
seen_space = 0; |
2280 |
m->append(*p); |
seen_eol = 0; |
2281 |
m->append(' '); |
if (was_centered) |
2282 |
m->append_int(i); |
n->state->add_tag(MTSM_CE, center_lines+1); |
2283 |
return new special_node(*m); |
else |
2284 |
|
n->state->add_tag_if_unknown(MTSM_CE, 0); |
2285 |
|
n->state->add_tag_if_unknown(MTSM_FI, fill); |
2286 |
|
n = n->next; |
2287 |
|
while (n != 0) { |
2288 |
|
if (n->state != 0) { |
2289 |
|
n->state->sub_tag_ce(); |
2290 |
|
n->state->add_tag_if_unknown(MTSM_FI, fill); |
2291 |
|
} |
2292 |
|
n = n->next; |
2293 |
|
} |
2294 |
} |
} |
|
return 0; |
|
2295 |
} |
} |
2296 |
|
|
2297 |
node *environment::make_html_tag(const char *nm) |
void environment::construct_new_line_state(node *n) |
2298 |
{ |
{ |
2299 |
if (is_html) { |
if (is_html) { |
2300 |
/* |
// find first glyph node which has a state. |
2301 |
* need to emit tag for post-grohtml |
while (n != 0 && n->state == 0) |
2302 |
* but we check to see whether we can emit specials |
n = n->next; |
2303 |
*/ |
if (n == 0 || n->state == 0) |
2304 |
if (curdiv == topdiv && topdiv->before_first_page) |
return; |
2305 |
topdiv->begin_page(); |
if (seen_space != 0) |
2306 |
macro *m = new macro; |
n->state->add_tag(MTSM_SP, seen_space); |
2307 |
m->append_str("html-tag:"); |
if (seen_eol && topdiv == curdiv) |
2308 |
for (const char *p = nm; *p; p++) |
n->state->add_tag(MTSM_EOL); |
2309 |
if (!invalid_input_char((unsigned char)*p)) |
seen_space = 0; |
2310 |
m->append(*p); |
seen_eol = 0; |
|
return new special_node(*m); |
|
2311 |
} |
} |
|
return 0; |
|
2312 |
} |
} |
2313 |
|
|
2314 |
|
extern int global_diverted_space; |
2315 |
|
|
2316 |
void environment::do_break(int do_spread) |
void environment::do_break(int do_spread) |
2317 |
{ |
{ |
2318 |
|
int was_centered = 0; |
2319 |
if (curdiv == topdiv && topdiv->before_first_page) { |
if (curdiv == topdiv && topdiv->before_first_page) { |
2320 |
topdiv->begin_page(); |
topdiv->begin_page(); |
2321 |
return; |
return; |
2342 |
switch (adjust_mode) { |
switch (adjust_mode) { |
2343 |
case ADJUST_CENTER: |
case ADJUST_CENTER: |
2344 |
saved_indent += (target_text_length - width_total)/2; |
saved_indent += (target_text_length - width_total)/2; |
2345 |
|
was_centered = 1; |
2346 |
break; |
break; |
2347 |
case ADJUST_RIGHT: |
case ADJUST_RIGHT: |
2348 |
saved_indent += target_text_length - width_total; |
saved_indent += target_text_length - width_total; |
2351 |
} |
} |
2352 |
node *tem = line; |
node *tem = line; |
2353 |
line = 0; |
line = 0; |
2354 |
output_line(tem, width_total); |
output_line(tem, width_total, was_centered); |
2355 |
hyphen_line_count = 0; |
hyphen_line_count = 0; |
2356 |
} |
} |
2357 |
prev_line_interrupted = 0; |
prev_line_interrupted = 0; |
2359 |
mark_last_line(); |
mark_last_line(); |
2360 |
output_pending_lines(); |
output_pending_lines(); |
2361 |
#endif /* WIDOW_CONTROL */ |
#endif /* WIDOW_CONTROL */ |
2362 |
|
if (!global_diverted_space) { |
2363 |
|
curdiv->modified_tag.incl(MTSM_BR); |
2364 |
|
seen_break = 1; |
2365 |
|
} |
2366 |
} |
} |
2367 |
|
|
2368 |
int environment::is_empty() |
int environment::is_empty() |
2374 |
{ |
{ |
2375 |
while (!tok.newline() && !tok.eof()) |
while (!tok.newline() && !tok.eof()) |
2376 |
tok.next(); |
tok.next(); |
2377 |
if (break_flag) { |
if (break_flag) |
2378 |
curenv->do_break(spread); |
curenv->do_break(spread); |
|
curenv->add_html_tag(0, ".br"); |
|
|
} |
|
2379 |
tok.next(); |
tok.next(); |
2380 |
} |
} |
2381 |
|
|
2782 |
} |
} |
2783 |
} |
} |
2784 |
curenv->tabs = tabs; |
curenv->tabs = tabs; |
2785 |
curenv->add_html_tag_tabs(1); |
curdiv->modified_tag.incl(MTSM_TA); |
2786 |
skip_line(); |
skip_line(); |
2787 |
} |
} |
2788 |
|
|
2904 |
case TAB_NONE: |
case TAB_NONE: |
2905 |
return; |
return; |
2906 |
case TAB_LEFT: |
case TAB_LEFT: |
2907 |
|
add_node(make_tag("tab L", absolute.to_units())); |
2908 |
add_node(make_tab_node(d)); |
add_node(make_tab_node(d)); |
|
add_node(make_html_tag("tab L", absolute.to_units())); |
|
2909 |
return; |
return; |
2910 |
case TAB_RIGHT: |
case TAB_RIGHT: |
2911 |
add_node(make_html_tag("tab R", absolute.to_units())); |
add_node(make_tag("tab R", absolute.to_units())); |
2912 |
break; |
break; |
2913 |
case TAB_CENTER: |
case TAB_CENTER: |
2914 |
add_node(make_html_tag("tab C", absolute.to_units())); |
add_node(make_tag("tab C", absolute.to_units())); |
2915 |
break; |
break; |
2916 |
default: |
default: |
2917 |
assert(0); |
assert(0); |