aboutsummaryrefslogtreecommitdiffstatshomepage
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
commit7763823a09119fdfe1ca1e3baef83ca1b5a39713 (patch)
tree5640a8fd9667aa8c0f607065cb19adf7754ab748 /man_term.c
parentc7089c4c53f1f303b3db0a33aa5dbb9c79ded016 (diff)
downloadmandoc-7763823a09119fdfe1ca1e3baef83ca1b5a39713.tar.gz
mandoc-7763823a09119fdfe1ca1e3baef83ca1b5a39713.tar.zst
mandoc-7763823a09119fdfe1ca1e3baef83ca1b5a39713.zip
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.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/man_term.c b/man_term.c
index 1f9a6048..4bd62443 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.138 2013/11/11 00:37:55 schwarze Exp $ */
+/* $Id: man_term.c,v 1.139 2013/12/22 23:34:13 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
@@ -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;