From 72ffb5f81a5259c8b01aa48d71c3542bc8eed8d7 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sun, 7 May 2017 17:31:45 +0000 Subject: 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@. --- term.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'term.c') diff --git a/term.c b/term.c index 1217d473..f2553d89 100644 --- a/term.c +++ b/term.c @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.259 2017/01/08 18:16:58 schwarze Exp $ */ +/* $Id: term.c,v 1.260 2017/05/07 17:31:45 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2017 Ingo Schwarze @@ -141,8 +141,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++; @@ -192,17 +192,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. -- cgit v1.2.3