aboutsummaryrefslogtreecommitdiffstatshomepage
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
commit4f3f2467baac85e3e184ff13cf9d87c8cad0e577 (patch)
tree5b6ae096c3fd5249306aeb28e32e346cd6957ca7 /term.c
parente02845a612e170851ce8a57d88d5ddf83b80b3d6 (diff)
downloadmandoc-4f3f2467baac85e3e184ff13cf9d87c8cad0e577.tar.gz
mandoc-4f3f2467baac85e3e184ff13cf9d87c8cad0e577.tar.zst
mandoc-4f3f2467baac85e3e184ff13cf9d87c8cad0e577.zip
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.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/term.c b/term.c
index 542ce27f..b4beb633 100644
--- 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');
}