diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2017-05-07 17:31:45 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2017-05-07 17:31:45 +0000 |
commit | df7add94ac0e6037b421b622febfdbe3236dad5c (patch) | |
tree | d3549eb68d21b93b68a624099f590ddb686ecfd9 /mdoc_term.c | |
parent | 412e48b8cba6db0a6b8eae7f848cfa460e0a315d (diff) | |
download | mandoc-df7add94ac0e6037b421b622febfdbe3236dad5c.tar.gz |
Basic implementation of the roff(7) .ta (define tab stops) request.
This is the first feature made possible by the parser reorganization.
Improves the formatting of the SYNOPSIS in many Xenocara GL manuals.
Also important for ports, as reported by many, including naddy@.
Diffstat (limited to 'mdoc_term.c')
-rw-r--r-- | mdoc_term.c | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/mdoc_term.c b/mdoc_term.c index 0becd3b5..0307cca6 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -261,7 +261,9 @@ terminal_mdoc(void *arg, const struct roff_man *mdoc) p = (struct termp *)arg; p->overstep = 0; p->rmargin = p->maxrmargin = p->defrmargin; - p->tabwidth = term_len(p, 5); + term_tab_set(p, NULL); + term_tab_set(p, "T"); + term_tab_set(p, ".5i"); n = mdoc->first->child; if (p->synopsisonly) { @@ -1128,8 +1130,14 @@ static void termp_bl_post(DECL_ARGS) { - if (n->type == ROFFT_BLOCK) - term_newln(p); + if (n->type != ROFFT_BLOCK) + return; + term_newln(p); + if (n->tok != MDOC_Bl || n->norm->Bl.type != LIST_column) + return; + term_tab_set(p, NULL); + term_tab_set(p, "T"); + term_tab_set(p, ".5i"); } static int @@ -1272,6 +1280,9 @@ termp_sh_pre(DECL_ARGS) break; case ROFFT_BODY: p->offset = term_len(p, p->defindent); + term_tab_set(p, NULL); + term_tab_set(p, "T"); + term_tab_set(p, ".5i"); switch (n->sec) { case SEC_DESCRIPTION: fn_prio = 0; @@ -1322,6 +1333,9 @@ termp_d1_pre(DECL_ARGS) return 1; term_newln(p); p->offset += term_len(p, p->defindent + 1); + term_tab_set(p, NULL); + term_tab_set(p, "T"); + term_tab_set(p, ".5i"); return 1; } @@ -1427,7 +1441,7 @@ termp_fa_pre(DECL_ARGS) static int termp_bd_pre(DECL_ARGS) { - size_t tabwidth, lm, len, rm, rmax; + size_t lm, len, rm, rmax; struct roff_node *nn; int offset; @@ -1467,9 +1481,11 @@ termp_bd_pre(DECL_ARGS) DISP_centered != n->norm->Bd.type) return 1; - tabwidth = p->tabwidth; - if (DISP_literal == n->norm->Bd.type) - p->tabwidth = term_len(p, 8); + if (n->norm->Bd.type == DISP_literal) { + term_tab_set(p, NULL); + term_tab_set(p, "T"); + term_tab_set(p, "8n"); + } lm = p->offset; rm = p->rmargin; @@ -1493,9 +1509,9 @@ termp_bd_pre(DECL_ARGS) * notion of selective eoln whitespace is pretty dumb * anyway, so don't sweat it. */ + if (nn->tok < ROFF_MAX) + continue; switch (nn->tok) { - case ROFF_br: - case ROFF_sp: case MDOC_Sm: case MDOC_Bl: case MDOC_D1: @@ -1513,7 +1529,6 @@ termp_bd_pre(DECL_ARGS) p->flags |= TERMP_NOSPACE; } - p->tabwidth = tabwidth; p->rmargin = rm; p->maxrmargin = rmax; return 0; @@ -1584,6 +1599,9 @@ termp_ss_pre(DECL_ARGS) break; case ROFFT_BODY: p->offset = term_len(p, p->defindent); + term_tab_set(p, NULL); + term_tab_set(p, "T"); + term_tab_set(p, ".5i"); break; default: break; |