version 1.358, 2017/05/30 16:31:29 |
version 1.361, 2017/06/04 22:44:15 |
Line 259 terminal_mdoc(void *arg, const struct roff_man *mdoc) |
|
Line 259 terminal_mdoc(void *arg, const struct roff_man *mdoc) |
|
size_t save_defindent; |
size_t save_defindent; |
|
|
p = (struct termp *)arg; |
p = (struct termp *)arg; |
p->overstep = 0; |
|
p->rmargin = p->maxrmargin = p->defrmargin; |
p->rmargin = p->maxrmargin = p->defrmargin; |
term_tab_set(p, NULL); |
term_tab_set(p, NULL); |
term_tab_set(p, "T"); |
term_tab_set(p, "T"); |
Line 407 print_mdoc_node(DECL_ARGS) |
|
Line 406 print_mdoc_node(DECL_ARGS) |
|
if (NODE_EOS & n->flags) |
if (NODE_EOS & n->flags) |
p->flags |= TERMP_SENTENCE; |
p->flags |= TERMP_SENTENCE; |
|
|
p->offset = offset; |
if (n->type != ROFFT_TEXT) |
|
p->offset = offset; |
p->rmargin = rmargin; |
p->rmargin = rmargin; |
} |
} |
|
|
Line 764 termp_it_pre(DECL_ARGS) |
|
Line 764 termp_it_pre(DECL_ARGS) |
|
case LIST_bullet: |
case LIST_bullet: |
case LIST_dash: |
case LIST_dash: |
case LIST_hyphen: |
case LIST_hyphen: |
/* |
if (n->type == ROFFT_HEAD) { |
* Weird special case. |
p->flags |= TERMP_NOBREAK | TERMP_HANG; |
* Some very narrow lists actually hang. |
p->trailspace = 1; |
*/ |
} else if (width <= (int)term_len(p, 2)) |
if (width <= (int)term_len(p, 2)) |
p->flags |= TERMP_NOPAD; |
p->flags |= TERMP_HANG; |
|
if (n->type != ROFFT_HEAD) |
|
break; |
|
p->flags |= TERMP_NOBREAK; |
|
p->trailspace = 1; |
|
break; |
break; |
case LIST_hang: |
case LIST_hang: |
if (n->type != ROFFT_HEAD) |
if (n->type != ROFFT_HEAD) |
break; |
break; |
|
|
/* |
|
* This is ugly. If `-hang' is specified and the body |
|
* is a `Bl' or `Bd', then we want basically to nullify |
|
* the "overstep" effect in term_flushln() and treat |
|
* this as a `-ohang' list instead. |
|
*/ |
|
if (NULL != n->next && |
|
NULL != n->next->child && |
|
(MDOC_Bl == n->next->child->tok || |
|
MDOC_Bd == n->next->child->tok)) |
|
break; |
|
|
|
p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG; |
p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG; |
p->trailspace = 1; |
p->trailspace = 1; |
break; |
break; |
Line 802 termp_it_pre(DECL_ARGS) |
|
Line 784 termp_it_pre(DECL_ARGS) |
|
p->trailspace = 2; |
p->trailspace = 2; |
|
|
if (NULL == n->next || NULL == n->next->child) |
if (NULL == n->next || NULL == n->next->child) |
p->flags |= TERMP_DANGLE; |
p->flags |= TERMP_HANG; |
break; |
break; |
case LIST_column: |
case LIST_column: |
if (n->type == ROFFT_HEAD) |
if (n->type == ROFFT_HEAD) |
Line 836 termp_it_pre(DECL_ARGS) |
|
Line 818 termp_it_pre(DECL_ARGS) |
|
p->offset += offset; |
p->offset += offset; |
|
|
switch (type) { |
switch (type) { |
case LIST_hang: |
|
/* |
|
* Same stipulation as above, regarding `-hang'. We |
|
* don't want to recalculate rmargin and offsets when |
|
* using `Bd' or `Bl' within `-hang' overstep lists. |
|
*/ |
|
if (n->type == ROFFT_HEAD && |
|
NULL != n->next && |
|
NULL != n->next->child && |
|
(MDOC_Bl == n->next->child->tok || |
|
MDOC_Bd == n->next->child->tok)) |
|
break; |
|
/* FALLTHROUGH */ |
|
case LIST_bullet: |
case LIST_bullet: |
case LIST_dash: |
case LIST_dash: |
case LIST_enum: |
case LIST_enum: |
case LIST_hyphen: |
case LIST_hyphen: |
|
case LIST_hang: |
case LIST_tag: |
case LIST_tag: |
if (n->type == ROFFT_HEAD) |
if (n->type == ROFFT_HEAD) |
p->rmargin = p->offset + width; |
p->rmargin = p->offset + width; |
Line 919 termp_it_pre(DECL_ARGS) |
|
Line 889 termp_it_pre(DECL_ARGS) |
|
case LIST_column: |
case LIST_column: |
if (n->type == ROFFT_HEAD) |
if (n->type == ROFFT_HEAD) |
return 0; |
return 0; |
|
p->minbl = 0; |
break; |
break; |
default: |
default: |
break; |
break; |
Line 959 termp_it_post(DECL_ARGS) |
|
Line 930 termp_it_post(DECL_ARGS) |
|
* has munged them in the meanwhile. |
* has munged them in the meanwhile. |
*/ |
*/ |
|
|
p->flags &= ~(TERMP_NOBREAK | TERMP_BRTRSP | TERMP_BRIND | |
p->flags &= ~(TERMP_NOBREAK | TERMP_BRTRSP | TERMP_BRIND | TERMP_HANG); |
TERMP_DANGLE | TERMP_HANG); |
|
p->trailspace = 0; |
p->trailspace = 0; |
} |
} |
|
|
Line 1380 termp_fn_pre(DECL_ARGS) |
|
Line 1350 termp_fn_pre(DECL_ARGS) |
|
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); |
|
p->flags |= TERMP_NOPAD; |
p->offset = p->rmargin; |
p->offset = p->rmargin; |
p->rmargin = rmargin; |
p->rmargin = rmargin; |
} |
} |
Line 1442 termp_fa_pre(DECL_ARGS) |
|
Line 1413 termp_fa_pre(DECL_ARGS) |
|
static int |
static int |
termp_bd_pre(DECL_ARGS) |
termp_bd_pre(DECL_ARGS) |
{ |
{ |
size_t lm, len, rm, rmax; |
size_t lm, len; |
struct roff_node *nn; |
struct roff_node *nn; |
int offset; |
int offset; |
|
|
Line 1489 termp_bd_pre(DECL_ARGS) |
|
Line 1460 termp_bd_pre(DECL_ARGS) |
|
} |
} |
|
|
lm = p->offset; |
lm = p->offset; |
rm = p->rmargin; |
p->flags |= TERMP_BRNEVER; |
rmax = p->maxrmargin; |
|
p->rmargin = p->maxrmargin = TERM_MAXMARGIN; |
|
|
|
for (nn = n->child; nn; nn = nn->next) { |
for (nn = n->child; nn; nn = nn->next) { |
if (DISP_centered == n->norm->Bd.type) { |
if (DISP_centered == n->norm->Bd.type) { |
if (nn->type == ROFFT_TEXT) { |
if (nn->type == ROFFT_TEXT) { |
len = term_strlen(p, nn->string); |
len = term_strlen(p, nn->string); |
p->offset = len >= rm ? 0 : |
p->offset = len >= p->rmargin ? 0 : |
lm + len >= rm ? rm - len : |
lm + len >= p->rmargin ? p->rmargin - len : |
(lm + rm - len) / 2; |
(lm + p->rmargin - len) / 2; |
} else |
} else |
p->offset = lm; |
p->offset = lm; |
} |
} |
Line 1529 termp_bd_pre(DECL_ARGS) |
|
Line 1497 termp_bd_pre(DECL_ARGS) |
|
term_flushln(p); |
term_flushln(p); |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
} |
} |
|
p->flags &= ~TERMP_BRNEVER; |
p->rmargin = rm; |
|
p->maxrmargin = rmax; |
|
return 0; |
return 0; |
} |
} |
|
|
static void |
static void |
termp_bd_post(DECL_ARGS) |
termp_bd_post(DECL_ARGS) |
{ |
{ |
size_t rm, rmax; |
|
|
|
if (n->type != ROFFT_BODY) |
if (n->type != ROFFT_BODY) |
return; |
return; |
|
|
rm = p->rmargin; |
|
rmax = p->maxrmargin; |
|
|
|
if (DISP_literal == n->norm->Bd.type || |
if (DISP_literal == n->norm->Bd.type || |
DISP_unfilled == n->norm->Bd.type) |
DISP_unfilled == n->norm->Bd.type) |
p->rmargin = p->maxrmargin = TERM_MAXMARGIN; |
p->flags |= TERMP_BRNEVER; |
|
|
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
term_newln(p); |
term_newln(p); |
|
p->flags &= ~TERMP_BRNEVER; |
p->rmargin = rm; |
|
p->maxrmargin = rmax; |
|
} |
} |
|
|
static int |
static int |
Line 1858 termp_fo_pre(DECL_ARGS) |
|
Line 1815 termp_fo_pre(DECL_ARGS) |
|
term_flushln(p); |
term_flushln(p); |
p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | |
p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | |
TERMP_HANG); |
TERMP_HANG); |
|
p->flags |= TERMP_NOPAD; |
p->offset = p->rmargin; |
p->offset = p->rmargin; |
p->rmargin = rmargin; |
p->rmargin = rmargin; |
} |
} |