aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-05-07 17:31:45 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-05-07 17:31:45 +0000
commit72ffb5f81a5259c8b01aa48d71c3542bc8eed8d7 (patch)
tree31fa6b4a1d8a875e8da528874a5b9907e452f853 /mdoc_term.c
parent3bbe9ca77bfa0a811b6ac068444fadfbb440cb8e (diff)
downloadmandoc-72ffb5f81a5259c8b01aa48d71c3542bc8eed8d7.tar.gz
mandoc-72ffb5f81a5259c8b01aa48d71c3542bc8eed8d7.tar.zst
mandoc-72ffb5f81a5259c8b01aa48d71c3542bc8eed8d7.zip
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.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index ab26e280..08620365 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.355 2017/05/05 15:17:32 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.356 2017/05/07 17:31:45 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -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;