summaryrefslogtreecommitdiffstats
path: root/term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2010-05-24 21:51:20 +0000
committerIngo Schwarze <schwarze@openbsd.org>2010-05-24 21:51:20 +0000
commite4081855b3ccc752fd8d5c743e87ad84478c748c (patch)
tree3547f69f52972cb996e650c41652f7fd47b5cf5a /term.c
parentd0f1de7c988060895fa78550174754f334d3b8ff (diff)
downloadmandoc-e4081855b3ccc752fd8d5c743e87ad84478c748c.tar.gz
sync to OpenBSD:
save the visual cursor position in term_flushln() and use that to avoid multiple blank lines in nested lists while still putting subsequent empty list tags each on their own line; "go ahead" kristaps@
Diffstat (limited to 'term.c')
-rw-r--r--term.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/term.c b/term.c
index 471056c4..a41162c4 100644
--- a/term.c
+++ b/term.c
@@ -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');
}