]> git.cameronkatri.com Git - mandoc.git/blobdiff - term.c
recognize ".if n" as true;
[mandoc.git] / term.c
diff --git a/term.c b/term.c
index 542ce27ff2cffa42c9c620388c39c60bbadfded4..b4beb633bcdd1fef151b07cf3f03834884b80a22 100644 (file)
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/*     $Id: term.c,v 1.138 2010/05/24 21:34:16 schwarze Exp $ */
+/*     $Id: term.c,v 1.139 2010/05/24 21:51:20 schwarze Exp $ */
 /*
  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
  *
@@ -207,10 +207,12 @@ term_flushln(struct termp *p)
                        vend -= vis;
                        putchar('\n');
                        if (TERMP_NOBREAK & p->flags) {
+                               p->viscol = p->rmargin;
                                for (j = 0; j < (int)p->rmargin; j++)
                                        putchar(' ');
                                vend += p->rmargin - p->offset;
                        } else {
+                               p->viscol = 0;
                                vbl = p->offset;
                        }
 
@@ -251,9 +253,11 @@ term_flushln(struct termp *p)
                        if (vbl) {
                                for (j = 0; j < (int)vbl; j++)
                                        putchar(' ');
+                               p->viscol += vbl;
                                vbl = 0;
                        }
                        putchar(p->buf[i]);
+                       p->viscol += 1;
                }
                vend += vbl;
                vis = vend;
@@ -263,6 +267,7 @@ term_flushln(struct termp *p)
        p->overstep = 0;
 
        if ( ! (TERMP_NOBREAK & p->flags)) {
+               p->viscol = 0;
                putchar('\n');
                return;
        }
@@ -294,11 +299,13 @@ term_flushln(struct termp *p)
 
        /* Right-pad. */
        if (maxvis > vis + /* LINTED */
-                       ((TERMP_TWOSPACE & p->flags) ? 1 : 0))  
+                       ((TERMP_TWOSPACE & p->flags) ? 1 : 0)) {
+               p->viscol += maxvis - vis;
                for ( ; vis < maxvis; vis++)
                        putchar(' ');
-       else {  /* ...or newline break. */
+       } else {        /* ...or newline break. */
                putchar('\n');
+               p->viscol = p->rmargin;
                for (i = 0; i < (int)p->rmargin; i++)
                        putchar(' ');
        }
@@ -315,7 +322,7 @@ term_newln(struct termp *p)
 {
 
        p->flags |= TERMP_NOSPACE;
-       if (0 == p->col) {
+       if (0 == p->col && 0 == p->viscol) {
                p->flags &= ~TERMP_NOLPAD;
                return;
        }
@@ -335,6 +342,7 @@ term_vspace(struct termp *p)
 {
 
        term_newln(p);
+       p->viscol = 0;
        putchar('\n');
 }