version 1.316, 2015/04/02 23:48:20 |
version 1.320, 2015/07/17 22:38:29 |
|
|
#include "mdoc.h" |
#include "mdoc.h" |
#include "out.h" |
#include "out.h" |
#include "term.h" |
#include "term.h" |
|
#include "tag.h" |
#include "main.h" |
#include "main.h" |
|
|
struct termpair { |
struct termpair { |
Line 117 static int termp_skip_pre(DECL_ARGS); |
|
Line 118 static int termp_skip_pre(DECL_ARGS); |
|
static int termp_sm_pre(DECL_ARGS); |
static int termp_sm_pre(DECL_ARGS); |
static int termp_sp_pre(DECL_ARGS); |
static int termp_sp_pre(DECL_ARGS); |
static int termp_ss_pre(DECL_ARGS); |
static int termp_ss_pre(DECL_ARGS); |
|
static int termp_tag_pre(DECL_ARGS); |
static int termp_under_pre(DECL_ARGS); |
static int termp_under_pre(DECL_ARGS); |
static int termp_ud_pre(DECL_ARGS); |
static int termp_ud_pre(DECL_ARGS); |
static int termp_vt_pre(DECL_ARGS); |
static int termp_vt_pre(DECL_ARGS); |
Line 145 static const struct termact termacts[MDOC_MAX] = { |
|
Line 147 static const struct termact termacts[MDOC_MAX] = { |
|
{ termp_bold_pre, NULL }, /* Cm */ |
{ termp_bold_pre, NULL }, /* Cm */ |
{ NULL, NULL }, /* Dv */ |
{ NULL, NULL }, /* Dv */ |
{ NULL, NULL }, /* Er */ |
{ NULL, NULL }, /* Er */ |
{ NULL, NULL }, /* Ev */ |
{ termp_tag_pre, NULL }, /* Ev */ |
{ termp_ex_pre, NULL }, /* Ex */ |
{ termp_ex_pre, NULL }, /* Ex */ |
{ termp_fa_pre, NULL }, /* Fa */ |
{ termp_fa_pre, NULL }, /* Fa */ |
{ termp_fd_pre, termp_fd_post }, /* Fd */ |
{ termp_fd_pre, termp_fd_post }, /* Fd */ |
Line 251 static const struct termact termacts[MDOC_MAX] = { |
|
Line 253 static const struct termact termacts[MDOC_MAX] = { |
|
|
|
|
|
void |
void |
terminal_mdoc(void *arg, const struct mdoc *mdoc) |
terminal_mdoc(void *arg, const struct roff_man *mdoc) |
{ |
{ |
const struct roff_meta *meta; |
|
struct roff_node *n; |
struct roff_node *n; |
struct termp *p; |
struct termp *p; |
|
|
p = (struct termp *)arg; |
p = (struct termp *)arg; |
|
|
p->overstep = 0; |
p->overstep = 0; |
p->rmargin = p->maxrmargin = p->defrmargin; |
p->rmargin = p->maxrmargin = p->defrmargin; |
p->tabwidth = term_len(p, 5); |
p->tabwidth = term_len(p, 5); |
|
|
n = mdoc_node(mdoc)->child; |
n = mdoc->first->child; |
meta = mdoc_meta(mdoc); |
|
|
|
if (p->synopsisonly) { |
if (p->synopsisonly) { |
while (n != NULL) { |
while (n != NULL) { |
if (n->tok == MDOC_Sh && n->sec == SEC_SYNOPSIS) { |
if (n->tok == MDOC_Sh && n->sec == SEC_SYNOPSIS) { |
if (n->child->next->child != NULL) |
if (n->child->next->child != NULL) |
print_mdoc_nodelist(p, NULL, |
print_mdoc_nodelist(p, NULL, |
meta, n->child->next->child); |
&mdoc->meta, |
|
n->child->next->child); |
term_newln(p); |
term_newln(p); |
break; |
break; |
} |
} |
Line 280 terminal_mdoc(void *arg, const struct mdoc *mdoc) |
|
Line 279 terminal_mdoc(void *arg, const struct mdoc *mdoc) |
|
} else { |
} else { |
if (p->defindent == 0) |
if (p->defindent == 0) |
p->defindent = 5; |
p->defindent = 5; |
term_begin(p, print_mdoc_head, print_mdoc_foot, meta); |
term_begin(p, print_mdoc_head, print_mdoc_foot, |
|
&mdoc->meta); |
if (n != NULL) { |
if (n != NULL) { |
if (n->tok != MDOC_Sh) |
if (n->tok != MDOC_Sh) |
term_vspace(p); |
term_vspace(p); |
print_mdoc_nodelist(p, NULL, meta, n); |
print_mdoc_nodelist(p, NULL, &mdoc->meta, n); |
} |
} |
term_end(p); |
term_end(p); |
} |
} |
Line 533 a2width(const struct termp *p, const char *v) |
|
Line 533 a2width(const struct termp *p, const char *v) |
|
SCALE_HS_INIT(&su, term_strlen(p, v)); |
SCALE_HS_INIT(&su, term_strlen(p, v)); |
su.scale /= term_strlen(p, "0"); |
su.scale /= term_strlen(p, "0"); |
} |
} |
return(term_hspan(p, &su)); |
return(term_hspan(p, &su) / 24); |
} |
} |
|
|
/* |
/* |
|
|
termp_fl_pre(DECL_ARGS) |
termp_fl_pre(DECL_ARGS) |
{ |
{ |
|
|
|
termp_tag_pre(p, pair, meta, n); |
term_fontpush(p, TERMFONT_BOLD); |
term_fontpush(p, TERMFONT_BOLD); |
term_word(p, "\\-"); |
term_word(p, "\\-"); |
|
|
|
|
termp_bold_pre(DECL_ARGS) |
termp_bold_pre(DECL_ARGS) |
{ |
{ |
|
|
|
termp_tag_pre(p, pair, meta, n); |
term_fontpush(p, TERMFONT_BOLD); |
term_fontpush(p, TERMFONT_BOLD); |
return(1); |
return(1); |
} |
} |
Line 2252 termp_under_pre(DECL_ARGS) |
|
Line 2254 termp_under_pre(DECL_ARGS) |
|
{ |
{ |
|
|
term_fontpush(p, TERMFONT_UNDER); |
term_fontpush(p, TERMFONT_UNDER); |
|
return(1); |
|
} |
|
|
|
static int |
|
termp_tag_pre(DECL_ARGS) |
|
{ |
|
|
|
if (n->child != NULL && |
|
n->child->type == ROFFT_TEXT && |
|
n->prev == NULL && |
|
(n->parent->tok == MDOC_It || |
|
(n->parent->tok == MDOC_Xo && |
|
n->parent->parent->prev == NULL && |
|
n->parent->parent->parent->tok == MDOC_It)) && |
|
! tag_get(n->child->string, 0)) |
|
tag_put(n->child->string, 0, p->line); |
return(1); |
return(1); |
} |
} |