version 1.197, 2017/05/05 15:17:32 |
version 1.203, 2017/06/07 17:38:26 |
Line 68 static void print_bvspace(struct termp *, |
|
Line 68 static void print_bvspace(struct termp *, |
|
const struct roff_node *, int); |
const struct roff_node *, int); |
|
|
static int pre_B(DECL_ARGS); |
static int pre_B(DECL_ARGS); |
|
static int pre_DT(DECL_ARGS); |
static int pre_HP(DECL_ARGS); |
static int pre_HP(DECL_ARGS); |
static int pre_I(DECL_ARGS); |
static int pre_I(DECL_ARGS); |
static int pre_IP(DECL_ARGS); |
static int pre_IP(DECL_ARGS); |
Line 117 static const struct termact __termacts[MAN_MAX - MAN_T |
|
Line 118 static const struct termact __termacts[MAN_MAX - MAN_T |
|
{ pre_literal, NULL, 0 }, /* fi */ |
{ pre_literal, NULL, 0 }, /* fi */ |
{ NULL, NULL, 0 }, /* RE */ |
{ NULL, NULL, 0 }, /* RE */ |
{ pre_RS, post_RS, 0 }, /* RS */ |
{ pre_RS, post_RS, 0 }, /* RS */ |
{ pre_ign, NULL, 0 }, /* DT */ |
{ pre_DT, NULL, 0 }, /* DT */ |
{ pre_ign, NULL, MAN_NOTEXT }, /* UC */ |
{ pre_ign, NULL, MAN_NOTEXT }, /* UC */ |
{ pre_PD, NULL, MAN_NOTEXT }, /* PD */ |
{ pre_PD, NULL, MAN_NOTEXT }, /* PD */ |
{ pre_ign, NULL, 0 }, /* AT */ |
{ pre_ign, NULL, 0 }, /* AT */ |
Line 140 terminal_man(void *arg, const struct roff_man *man) |
|
Line 141 terminal_man(void *arg, const struct roff_man *man) |
|
size_t save_defindent; |
size_t save_defindent; |
|
|
p = (struct termp *)arg; |
p = (struct termp *)arg; |
p->overstep = 0; |
p->tcol->rmargin = p->maxrmargin = p->defrmargin; |
p->rmargin = p->maxrmargin = p->defrmargin; |
term_tab_set(p, NULL); |
p->tabwidth = term_len(p, 5); |
term_tab_set(p, "T"); |
|
term_tab_set(p, ".5i"); |
|
|
memset(&mt, 0, sizeof(struct mtermp)); |
memset(&mt, 0, sizeof(struct mtermp)); |
mt.lmargin[mt.lmargincur] = term_len(p, p->defindent); |
mt.lmargin[mt.lmargincur] = term_len(p, p->defindent); |
Line 226 pre_literal(DECL_ARGS) |
|
Line 228 pre_literal(DECL_ARGS) |
|
|
|
term_newln(p); |
term_newln(p); |
|
|
if (MAN_nf == n->tok || MAN_EX == n->tok) |
if (n->tok == MAN_nf || n->tok == MAN_EX) |
mt->fl |= MANT_LITERAL; |
mt->fl |= MANT_LITERAL; |
else |
else |
mt->fl &= ~MANT_LITERAL; |
mt->fl &= ~MANT_LITERAL; |
Line 236 pre_literal(DECL_ARGS) |
|
Line 238 pre_literal(DECL_ARGS) |
|
* So in case a second call to term_flushln() is needed, |
* So in case a second call to term_flushln() is needed, |
* indentation has to be set up explicitly. |
* indentation has to be set up explicitly. |
*/ |
*/ |
if (MAN_HP == n->parent->tok && p->rmargin < p->maxrmargin) { |
if (n->parent->tok == MAN_HP && p->tcol->rmargin < p->maxrmargin) { |
p->offset = p->rmargin; |
p->tcol->offset = p->tcol->rmargin; |
p->rmargin = p->maxrmargin; |
p->tcol->rmargin = p->maxrmargin; |
p->trailspace = 0; |
p->trailspace = 0; |
p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND); |
p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND); |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
Line 357 pre_in(DECL_ARGS) |
|
Line 359 pre_in(DECL_ARGS) |
|
|
|
term_newln(p); |
term_newln(p); |
|
|
if (NULL == n->child) { |
if (n->child == NULL) { |
p->offset = mt->offset; |
p->tcol->offset = mt->offset; |
return 0; |
return 0; |
} |
} |
|
|
Line 378 pre_in(DECL_ARGS) |
|
Line 380 pre_in(DECL_ARGS) |
|
v = (term_hspan(p, &su) + 11) / 24; |
v = (term_hspan(p, &su) + 11) / 24; |
|
|
if (less < 0) |
if (less < 0) |
p->offset -= p->offset > v ? v : p->offset; |
p->tcol->offset -= p->tcol->offset > v ? v : p->tcol->offset; |
else if (less > 0) |
else if (less > 0) |
p->offset += v; |
p->tcol->offset += v; |
else |
else |
p->offset = v; |
p->tcol->offset = v; |
if (p->offset > SHRT_MAX) |
if (p->tcol->offset > SHRT_MAX) |
p->offset = term_len(p, p->defindent); |
p->tcol->offset = term_len(p, p->defindent); |
|
|
return 0; |
return 0; |
} |
} |
|
|
static int |
static int |
|
pre_DT(DECL_ARGS) |
|
{ |
|
term_tab_set(p, NULL); |
|
term_tab_set(p, "T"); |
|
term_tab_set(p, ".5i"); |
|
return 0; |
|
} |
|
|
|
static int |
pre_HP(DECL_ARGS) |
pre_HP(DECL_ARGS) |
{ |
{ |
struct roffsu su; |
struct roffsu su; |
Line 424 pre_HP(DECL_ARGS) |
|
Line 435 pre_HP(DECL_ARGS) |
|
} else |
} else |
len = mt->lmargin[mt->lmargincur]; |
len = mt->lmargin[mt->lmargincur]; |
|
|
p->offset = mt->offset; |
p->tcol->offset = mt->offset; |
p->rmargin = mt->offset + len; |
p->tcol->rmargin = mt->offset + len; |
return 1; |
return 1; |
} |
} |
|
|
Line 449 post_HP(DECL_ARGS) |
|
Line 460 post_HP(DECL_ARGS) |
|
|
|
p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND); |
p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND); |
p->trailspace = 0; |
p->trailspace = 0; |
p->offset = mt->offset; |
p->tcol->offset = mt->offset; |
p->rmargin = p->maxrmargin; |
p->tcol->rmargin = p->maxrmargin; |
break; |
break; |
default: |
default: |
break; |
break; |
Line 467 pre_PP(DECL_ARGS) |
|
Line 478 pre_PP(DECL_ARGS) |
|
print_bvspace(p, n, mt->pardist); |
print_bvspace(p, n, mt->pardist); |
break; |
break; |
default: |
default: |
p->offset = mt->offset; |
p->tcol->offset = mt->offset; |
break; |
break; |
} |
} |
|
|
Line 511 pre_IP(DECL_ARGS) |
|
Line 522 pre_IP(DECL_ARGS) |
|
|
|
switch (n->type) { |
switch (n->type) { |
case ROFFT_HEAD: |
case ROFFT_HEAD: |
p->offset = mt->offset; |
p->tcol->offset = mt->offset; |
p->rmargin = mt->offset + len; |
p->tcol->rmargin = mt->offset + len; |
|
|
savelit = MANT_LITERAL & mt->fl; |
savelit = MANT_LITERAL & mt->fl; |
mt->fl &= ~MANT_LITERAL; |
mt->fl &= ~MANT_LITERAL; |
Line 525 pre_IP(DECL_ARGS) |
|
Line 536 pre_IP(DECL_ARGS) |
|
|
|
return 0; |
return 0; |
case ROFFT_BODY: |
case ROFFT_BODY: |
p->offset = mt->offset + len; |
p->tcol->offset = mt->offset + len; |
p->rmargin = p->maxrmargin; |
p->tcol->rmargin = p->maxrmargin; |
break; |
break; |
default: |
default: |
break; |
break; |
Line 544 post_IP(DECL_ARGS) |
|
Line 555 post_IP(DECL_ARGS) |
|
term_flushln(p); |
term_flushln(p); |
p->flags &= ~TERMP_NOBREAK; |
p->flags &= ~TERMP_NOBREAK; |
p->trailspace = 0; |
p->trailspace = 0; |
p->rmargin = p->maxrmargin; |
p->tcol->rmargin = p->maxrmargin; |
break; |
break; |
case ROFFT_BODY: |
case ROFFT_BODY: |
term_newln(p); |
term_newln(p); |
p->offset = mt->offset; |
p->tcol->offset = mt->offset; |
break; |
break; |
default: |
default: |
break; |
break; |
Line 593 pre_TP(DECL_ARGS) |
|
Line 604 pre_TP(DECL_ARGS) |
|
|
|
switch (n->type) { |
switch (n->type) { |
case ROFFT_HEAD: |
case ROFFT_HEAD: |
p->offset = mt->offset; |
p->tcol->offset = mt->offset; |
p->rmargin = mt->offset + len; |
p->tcol->rmargin = mt->offset + len; |
|
|
savelit = MANT_LITERAL & mt->fl; |
savelit = MANT_LITERAL & mt->fl; |
mt->fl &= ~MANT_LITERAL; |
mt->fl &= ~MANT_LITERAL; |
Line 613 pre_TP(DECL_ARGS) |
|
Line 624 pre_TP(DECL_ARGS) |
|
mt->fl |= MANT_LITERAL; |
mt->fl |= MANT_LITERAL; |
return 0; |
return 0; |
case ROFFT_BODY: |
case ROFFT_BODY: |
p->offset = mt->offset + len; |
p->tcol->offset = mt->offset + len; |
p->rmargin = p->maxrmargin; |
p->tcol->rmargin = p->maxrmargin; |
p->trailspace = 0; |
p->trailspace = 0; |
p->flags &= ~(TERMP_NOBREAK | TERMP_BRTRSP); |
p->flags &= ~(TERMP_NOBREAK | TERMP_BRTRSP); |
break; |
break; |
Line 635 post_TP(DECL_ARGS) |
|
Line 646 post_TP(DECL_ARGS) |
|
break; |
break; |
case ROFFT_BODY: |
case ROFFT_BODY: |
term_newln(p); |
term_newln(p); |
p->offset = mt->offset; |
p->tcol->offset = mt->offset; |
break; |
break; |
default: |
default: |
break; |
break; |
Line 670 pre_SS(DECL_ARGS) |
|
Line 681 pre_SS(DECL_ARGS) |
|
break; |
break; |
case ROFFT_HEAD: |
case ROFFT_HEAD: |
term_fontrepl(p, TERMFONT_BOLD); |
term_fontrepl(p, TERMFONT_BOLD); |
p->offset = term_len(p, 3); |
p->tcol->offset = term_len(p, 3); |
p->rmargin = mt->offset; |
p->tcol->rmargin = mt->offset; |
p->trailspace = mt->offset; |
p->trailspace = mt->offset; |
p->flags |= TERMP_NOBREAK | TERMP_BRIND; |
p->flags |= TERMP_NOBREAK | TERMP_BRIND; |
break; |
break; |
case ROFFT_BODY: |
case ROFFT_BODY: |
p->offset = mt->offset; |
p->tcol->offset = mt->offset; |
p->rmargin = p->maxrmargin; |
p->tcol->rmargin = p->maxrmargin; |
p->trailspace = 0; |
p->trailspace = 0; |
p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND); |
p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND); |
break; |
break; |
Line 732 pre_SH(DECL_ARGS) |
|
Line 743 pre_SH(DECL_ARGS) |
|
break; |
break; |
case ROFFT_HEAD: |
case ROFFT_HEAD: |
term_fontrepl(p, TERMFONT_BOLD); |
term_fontrepl(p, TERMFONT_BOLD); |
p->offset = 0; |
p->tcol->offset = 0; |
p->rmargin = mt->offset; |
p->tcol->rmargin = mt->offset; |
p->trailspace = mt->offset; |
p->trailspace = mt->offset; |
p->flags |= TERMP_NOBREAK | TERMP_BRIND; |
p->flags |= TERMP_NOBREAK | TERMP_BRIND; |
break; |
break; |
case ROFFT_BODY: |
case ROFFT_BODY: |
p->offset = mt->offset; |
p->tcol->offset = mt->offset; |
p->rmargin = p->maxrmargin; |
p->tcol->rmargin = p->maxrmargin; |
p->trailspace = 0; |
p->trailspace = 0; |
p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND); |
p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND); |
break; |
break; |
Line 793 pre_RS(DECL_ARGS) |
|
Line 804 pre_RS(DECL_ARGS) |
|
n->aux = term_len(p, p->defindent); |
n->aux = term_len(p, p->defindent); |
|
|
mt->offset += n->aux; |
mt->offset += n->aux; |
p->offset = mt->offset; |
p->tcol->offset = mt->offset; |
p->rmargin = p->maxrmargin; |
p->tcol->rmargin = p->maxrmargin; |
|
|
if (++mt->lmarginsz < MAXMARGINS) |
if (++mt->lmarginsz < MAXMARGINS) |
mt->lmargincur = mt->lmarginsz; |
mt->lmargincur = mt->lmarginsz; |
Line 818 post_RS(DECL_ARGS) |
|
Line 829 post_RS(DECL_ARGS) |
|
} |
} |
|
|
mt->offset -= n->parent->head->aux; |
mt->offset -= n->parent->head->aux; |
p->offset = mt->offset; |
p->tcol->offset = mt->offset; |
|
|
if (--mt->lmarginsz < MAXMARGINS) |
if (--mt->lmarginsz < MAXMARGINS) |
mt->lmargincur = mt->lmarginsz; |
mt->lmargincur = mt->lmarginsz; |
Line 851 post_UR(DECL_ARGS) |
|
Line 862 post_UR(DECL_ARGS) |
|
static void |
static void |
print_man_node(DECL_ARGS) |
print_man_node(DECL_ARGS) |
{ |
{ |
size_t rm, rmax; |
|
int c; |
int c; |
|
|
switch (n->type) { |
switch (n->type) { |
Line 861 print_man_node(DECL_ARGS) |
|
Line 871 print_man_node(DECL_ARGS) |
|
* If we have a space as the first character, break |
* If we have a space as the first character, break |
* before printing the line's data. |
* before printing the line's data. |
*/ |
*/ |
if ('\0' == *n->string) { |
if (*n->string == '\0') { |
term_vspace(p); |
term_vspace(p); |
return; |
return; |
} else if (' ' == *n->string && NODE_LINE & n->flags) |
} else if (*n->string == ' ' && n->flags & NODE_LINE && |
|
(p->flags & TERMP_NONEWLINE) == 0) |
term_newln(p); |
term_newln(p); |
|
|
term_word(p, n->string); |
term_word(p, n->string); |
|
|
if (mt->fl & MANT_LITERAL && |
if (mt->fl & MANT_LITERAL && |
! (p->flags & (TERMP_NOBREAK | TERMP_NONEWLINE)) && |
! (p->flags & (TERMP_NOBREAK | TERMP_NONEWLINE)) && |
(n->next == NULL || n->next->flags & NODE_LINE)) { |
(n->next == NULL || n->next->flags & NODE_LINE)) { |
rm = p->rmargin; |
p->flags |= TERMP_BRNEVER | TERMP_NOSPACE; |
rmax = p->maxrmargin; |
|
p->rmargin = p->maxrmargin = TERM_MAXMARGIN; |
|
p->flags |= TERMP_NOSPACE; |
|
if (n->string != NULL && *n->string != '\0') |
if (n->string != NULL && *n->string != '\0') |
term_flushln(p); |
term_flushln(p); |
else |
else |
term_newln(p); |
term_newln(p); |
if (rm < rmax && n->parent->tok == MAN_HP) { |
p->flags &= ~TERMP_BRNEVER; |
p->offset = rm; |
if (p->tcol->rmargin < p->maxrmargin && |
p->rmargin = rmax; |
n->parent->tok == MAN_HP) { |
} else |
p->tcol->offset = p->tcol->rmargin; |
p->rmargin = rm; |
p->tcol->rmargin = p->maxrmargin; |
p->maxrmargin = rmax; |
} |
} |
} |
if (NODE_EOS & n->flags) |
if (NODE_EOS & n->flags) |
p->flags |= TERMP_SENTENCE; |
p->flags |= TERMP_SENTENCE; |
Line 987 print_man_foot(struct termp *p, const struct roff_meta |
|
Line 995 print_man_foot(struct termp *p, const struct roff_meta |
|
|
|
p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; |
p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; |
p->trailspace = 1; |
p->trailspace = 1; |
p->offset = 0; |
p->tcol->offset = 0; |
p->rmargin = p->maxrmargin > datelen ? |
p->tcol->rmargin = p->maxrmargin > datelen ? |
(p->maxrmargin + term_len(p, 1) - datelen) / 2 : 0; |
(p->maxrmargin + term_len(p, 1) - datelen) / 2 : 0; |
|
|
if (meta->os) |
if (meta->os) |
Line 997 print_man_foot(struct termp *p, const struct roff_meta |
|
Line 1005 print_man_foot(struct termp *p, const struct roff_meta |
|
|
|
/* At the bottom in the middle: manual date. */ |
/* At the bottom in the middle: manual date. */ |
|
|
p->offset = p->rmargin; |
p->tcol->offset = p->tcol->rmargin; |
titlen = term_strlen(p, title); |
titlen = term_strlen(p, title); |
p->rmargin = p->maxrmargin > titlen ? p->maxrmargin - titlen : 0; |
p->tcol->rmargin = p->maxrmargin > titlen ? |
|
p->maxrmargin - titlen : 0; |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
|
|
term_word(p, meta->date); |
term_word(p, meta->date); |
Line 1010 print_man_foot(struct termp *p, const struct roff_meta |
|
Line 1019 print_man_foot(struct termp *p, const struct roff_meta |
|
p->flags &= ~TERMP_NOBREAK; |
p->flags &= ~TERMP_NOBREAK; |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
p->trailspace = 0; |
p->trailspace = 0; |
p->offset = p->rmargin; |
p->tcol->offset = p->tcol->rmargin; |
p->rmargin = p->maxrmargin; |
p->tcol->rmargin = p->maxrmargin; |
|
|
term_word(p, title); |
term_word(p, title); |
term_flushln(p); |
term_flushln(p); |
Line 1038 print_man_head(struct termp *p, const struct roff_meta |
|
Line 1047 print_man_head(struct termp *p, const struct roff_meta |
|
|
|
p->flags |= TERMP_NOBREAK | TERMP_NOSPACE; |
p->flags |= TERMP_NOBREAK | TERMP_NOSPACE; |
p->trailspace = 1; |
p->trailspace = 1; |
p->offset = 0; |
p->tcol->offset = 0; |
p->rmargin = 2 * (titlen+1) + vollen < p->maxrmargin ? |
p->tcol->rmargin = 2 * (titlen+1) + vollen < p->maxrmargin ? |
(p->maxrmargin - vollen + term_len(p, 1)) / 2 : |
(p->maxrmargin - vollen + term_len(p, 1)) / 2 : |
vollen < p->maxrmargin ? p->maxrmargin - vollen : 0; |
vollen < p->maxrmargin ? p->maxrmargin - vollen : 0; |
|
|
Line 1049 print_man_head(struct termp *p, const struct roff_meta |
|
Line 1058 print_man_head(struct termp *p, const struct roff_meta |
|
/* At the top in the middle: manual volume. */ |
/* At the top in the middle: manual volume. */ |
|
|
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
p->offset = p->rmargin; |
p->tcol->offset = p->tcol->rmargin; |
p->rmargin = p->offset + vollen + titlen < p->maxrmargin ? |
p->tcol->rmargin = p->tcol->offset + vollen + titlen < |
p->maxrmargin - titlen : p->maxrmargin; |
p->maxrmargin ? p->maxrmargin - titlen : p->maxrmargin; |
|
|
term_word(p, volume); |
term_word(p, volume); |
term_flushln(p); |
term_flushln(p); |
Line 1060 print_man_head(struct termp *p, const struct roff_meta |
|
Line 1069 print_man_head(struct termp *p, const struct roff_meta |
|
|
|
p->flags &= ~TERMP_NOBREAK; |
p->flags &= ~TERMP_NOBREAK; |
p->trailspace = 0; |
p->trailspace = 0; |
if (p->rmargin + titlen <= p->maxrmargin) { |
if (p->tcol->rmargin + titlen <= p->maxrmargin) { |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
p->offset = p->rmargin; |
p->tcol->offset = p->tcol->rmargin; |
p->rmargin = p->maxrmargin; |
p->tcol->rmargin = p->maxrmargin; |
term_word(p, title); |
term_word(p, title); |
term_flushln(p); |
term_flushln(p); |
} |
} |
|
|
p->flags &= ~TERMP_NOSPACE; |
p->flags &= ~TERMP_NOSPACE; |
p->offset = 0; |
p->tcol->offset = 0; |
p->rmargin = p->maxrmargin; |
p->tcol->rmargin = p->maxrmargin; |
|
|
/* |
/* |
* Groff prints three blank lines before the content. |
* Groff prints three blank lines before the content. |