summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2017-05-07 17:30:59 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2017-05-07 17:30:59 +0000
commit61e08b3ae1ef9c667611ead25bb473f9759fbb2b (patch)
tree69ea0dcafa67d4e8672f9209c6d7b889e0bdadac /usr.bin/mandoc/term.c
parent03e014232b141d938451aca6862f5d43f0594524 (diff)
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 'usr.bin/mandoc/term.c')
-rw-r--r--usr.bin/mandoc/term.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c
index aa36e557bd0..2a4a44f41fa 100644
--- a/usr.bin/mandoc/term.c
+++ b/usr.bin/mandoc/term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: term.c,v 1.119 2017/01/08 18:08:44 schwarze Exp $ */
+/* $OpenBSD: term.c,v 1.120 2017/05/07 17:30:58 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -139,8 +139,8 @@ term_flushln(struct termp *p)
* subsequent tabs into a single huge set of spaces.
*/
ntab = 0;
- while (i < p->col && '\t' == p->buf[i]) {
- vend = (vis / p->tabwidth + 1) * p->tabwidth;
+ while (i < p->col && p->buf[i] == '\t') {
+ vend = term_tab_next(vis);
vbl += vend - vis;
vis = vend;
ntab++;
@@ -190,17 +190,20 @@ term_flushln(struct termp *p)
vend -= vis;
(*p->endline)(p);
p->viscol = 0;
- if (TERMP_BRIND & p->flags) {
- vbl = p->rmargin;
- vend += p->rmargin;
- vend -= p->offset;
- } else
- vbl = p->offset;
- /* use pending tabs on the new line */
+ /* Use pending tabs on the new line. */
+
+ vbl = 0;
+ while (ntab--)
+ vbl = term_tab_next(vbl);
- if (0 < ntab)
- vbl += ntab * p->tabwidth;
+ /* Re-establish indentation. */
+
+ if (p->flags & TERMP_BRIND) {
+ vbl += p->rmargin;
+ vend += p->rmargin - p->offset;
+ } else
+ vbl += p->offset;
/*
* Remove the p->overstep width.