version 1.318, 2015/04/18 16:06:41 |
version 1.322, 2015/07/25 14:18:04 |
|
|
#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 249 static const struct termact termacts[MDOC_MAX] = { |
|
Line 251 static const struct termact termacts[MDOC_MAX] = { |
|
{ termp_ll_pre, NULL }, /* ll */ |
{ termp_ll_pre, NULL }, /* ll */ |
}; |
}; |
|
|
|
static int fn_prio; |
|
|
void |
void |
terminal_mdoc(void *arg, const struct roff_man *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 roff_man *mdoc) |
|
Line 280 terminal_mdoc(void *arg, const struct roff_man *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); |
} |
} |
|
|
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 1362 termp_sh_pre(DECL_ARGS) |
|
Line 1365 termp_sh_pre(DECL_ARGS) |
|
* when the previous section was empty. |
* when the previous section was empty. |
*/ |
*/ |
if (n->prev == NULL || |
if (n->prev == NULL || |
MDOC_Sh != n->prev->tok || |
n->prev->tok != MDOC_Sh || |
(n->prev->body != NULL && |
(n->prev->body != NULL && |
n->prev->body->child != NULL)) |
n->prev->body->child != NULL)) |
term_vspace(p); |
term_vspace(p); |
Line 1372 termp_sh_pre(DECL_ARGS) |
|
Line 1375 termp_sh_pre(DECL_ARGS) |
|
break; |
break; |
case ROFFT_BODY: |
case ROFFT_BODY: |
p->offset = term_len(p, p->defindent); |
p->offset = term_len(p, p->defindent); |
if (SEC_AUTHORS == n->sec) |
switch (n->sec) { |
|
case SEC_DESCRIPTION: |
|
fn_prio = 0; |
|
break; |
|
case SEC_AUTHORS: |
p->flags &= ~(TERMP_SPLIT|TERMP_NOSPLIT); |
p->flags &= ~(TERMP_SPLIT|TERMP_NOSPLIT); |
|
break; |
|
default: |
|
break; |
|
} |
break; |
break; |
default: |
default: |
break; |
break; |
Line 1469 termp_fn_pre(DECL_ARGS) |
|
Line 1480 termp_fn_pre(DECL_ARGS) |
|
term_word(p, n->string); |
term_word(p, n->string); |
term_fontpop(p); |
term_fontpop(p); |
|
|
|
if (n->sec == SEC_DESCRIPTION) { |
|
if ( ! tag_get(n->string, 0, ++fn_prio)) |
|
tag_put(n->string, 0, fn_prio, p->line); |
|
} |
|
|
if (pretty) { |
if (pretty) { |
term_flushln(p); |
term_flushln(p); |
p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG); |
p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG); |
Line 1821 termp_sp_pre(DECL_ARGS) |
|
Line 1837 termp_sp_pre(DECL_ARGS) |
|
break; |
break; |
default: |
default: |
len = 1; |
len = 1; |
|
fn_prio = 0; |
break; |
break; |
} |
} |
|
|
Line 2252 termp_under_pre(DECL_ARGS) |
|
Line 2269 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, 1)) |
|
tag_put(n->child->string, 0, 1, p->line); |
return(1); |
return(1); |
} |
} |