summaryrefslogtreecommitdiffstats
path: root/man_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2013-12-22 23:34:13 +0000
committerIngo Schwarze <schwarze@openbsd.org>2013-12-22 23:34:13 +0000
commit3b2ca955f8a2aa20d55aed7f0b8fb63533fddb64 (patch)
treee82445f6f67dcbe0c89395f44bf802693714be39 /man_term.c
parentcac6ca6afd5184c9e640382fcad986fa5922cec9 (diff)
downloadmandoc-3b2ca955f8a2aa20d55aed7f0b8fb63533fddb64.tar.gz
Polishing the worms in my favourite can, term_flushln().
The TERMP_TWOSPACE flag i introduced in August 2009 was idiosyncratic and served only a very narrow purpose. Replace it by a more intuitive and more general termp attribute "trailspace", to be used together with TERMP_NOBREAK, to request a minimum amount of whitespace at the end of the current column. Adapt all code to the new interface. No functional change intended; code reviews to confirm that are welcome *eg*.
Diffstat (limited to 'man_term.c')
-rw-r--r--man_term.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/man_term.c b/man_term.c
index 3c76f4cb..22668f02 100644
--- a/man_term.c
+++ b/man_term.c
@@ -265,7 +265,8 @@ pre_literal(DECL_ARGS)
if (MAN_HP == n->parent->tok && p->rmargin < p->maxrmargin) {
p->offset = p->rmargin;
p->rmargin = p->maxrmargin;
- p->flags &= ~(TERMP_NOBREAK | TERMP_TWOSPACE);
+ p->trailspace = 0;
+ p->flags &= ~TERMP_NOBREAK;
p->flags |= TERMP_NOSPACE;
}
@@ -535,7 +536,7 @@ pre_HP(DECL_ARGS)
if ( ! (MANT_LITERAL & mt->fl)) {
p->flags |= TERMP_NOBREAK;
- p->flags |= TERMP_TWOSPACE;
+ p->trailspace = 2;
}
len = mt->lmargin[mt->lmargincur];
@@ -570,7 +571,7 @@ post_HP(DECL_ARGS)
case (MAN_BODY):
term_newln(p);
p->flags &= ~TERMP_NOBREAK;
- p->flags &= ~TERMP_TWOSPACE;
+ p->trailspace = 0;
p->offset = mt->offset;
p->rmargin = p->maxrmargin;
break;
@@ -613,6 +614,7 @@ pre_IP(DECL_ARGS)
break;
case (MAN_HEAD):
p->flags |= TERMP_NOBREAK;
+ p->trailspace = 1;
break;
case (MAN_BLOCK):
print_bvspace(p, n, mt->pardist);
@@ -675,6 +677,7 @@ post_IP(DECL_ARGS)
case (MAN_HEAD):
term_flushln(p);
p->flags &= ~TERMP_NOBREAK;
+ p->trailspace = 0;
p->rmargin = p->maxrmargin;
break;
case (MAN_BODY):
@@ -698,6 +701,7 @@ pre_TP(DECL_ARGS)
switch (n->type) {
case (MAN_HEAD):
p->flags |= TERMP_NOBREAK;
+ p->trailspace = 1;
break;
case (MAN_BODY):
p->flags |= TERMP_NOSPACE;
@@ -745,8 +749,8 @@ pre_TP(DECL_ARGS)
case (MAN_BODY):
p->offset = mt->offset + len;
p->rmargin = p->maxrmargin;
+ p->trailspace = 0;
p->flags &= ~TERMP_NOBREAK;
- p->flags &= ~TERMP_TWOSPACE;
break;
default:
break;
@@ -1101,6 +1105,7 @@ print_man_foot(struct termp *p, const void *arg)
/* Bottom left corner: manual source. */
p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
+ p->trailspace = 1;
p->offset = 0;
p->rmargin = (p->maxrmargin - datelen + term_len(p, 1)) / 2;
@@ -1123,6 +1128,7 @@ print_man_foot(struct termp *p, const void *arg)
p->flags &= ~TERMP_NOBREAK;
p->flags |= TERMP_NOSPACE;
+ p->trailspace = 0;
p->offset = p->rmargin;
p->rmargin = p->maxrmargin;
@@ -1154,6 +1160,7 @@ print_man_head(struct termp *p, const void *arg)
titlen = term_strlen(p, title);
p->flags |= TERMP_NOBREAK | TERMP_NOSPACE;
+ p->trailspace = 1;
p->offset = 0;
p->rmargin = 2 * (titlen+1) + buflen < p->maxrmargin ?
(p->maxrmargin -
@@ -1176,6 +1183,7 @@ print_man_head(struct termp *p, const void *arg)
/* Top right corner: title and section, again. */
p->flags &= ~TERMP_NOBREAK;
+ p->trailspace = 0;
if (p->rmargin + titlen <= p->maxrmargin) {
p->flags |= TERMP_NOSPACE;
p->offset = p->rmargin;