summaryrefslogtreecommitdiffstats
path: root/man_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2011-09-19 22:36:16 +0000
committerIngo Schwarze <schwarze@openbsd.org>2011-09-19 22:36:16 +0000
commitbbc1c34dd91da0a6589b4a76b4c861db09eeab42 (patch)
tree966b48c25d489fc44a0d9043441dd82db45f5cad /man_term.c
parent8c76f32c930d4fac4fe4b05aacc9b57b7e190516 (diff)
downloadmandoc-bbc1c34dd91da0a6589b4a76b4c861db09eeab42.tar.gz
Remove the terminal frontend flag TERMP_NOLPAD.
In columnated contexts (.Bl -column, .Bl -tag, .IP, .TP, .HP etc.), do not pad after writing a column. Instead, always pad before writing content. In itself, this change avoids: - writing trailing whitespace in some situations - with .fi/.nf in .HP, breaking lines that were already padded It allows several bugfixes included in this patch: - Do not count backspace as a character with positive width. - Set up proper indentation when encountering .fi/.nf in .HP. - Adjust the .HP indentation width to what groff does. - Never unlimit the right margin unless in the final column. ok kristaps@
Diffstat (limited to 'man_term.c')
-rw-r--r--man_term.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/man_term.c b/man_term.c
index 398271f9..cdf0aed8 100644
--- a/man_term.c
+++ b/man_term.c
@@ -245,6 +245,18 @@ pre_literal(DECL_ARGS)
else
mt->fl &= ~MANT_LITERAL;
+ /*
+ * Unlike .IP and .TP, .HP does not have a HEAD.
+ * So in case a second call to term_flushln() is needed,
+ * indentation has to be set up explicitly.
+ */
+ if (MAN_HP == n->parent->tok && p->rmargin < p->maxrmargin) {
+ p->offset = p->rmargin + 1;
+ p->rmargin = p->maxrmargin;
+ p->flags &= ~(TERMP_NOBREAK | TERMP_TWOSPACE);
+ p->flags |= TERMP_NOSPACE;
+ }
+
return(0);
}
@@ -431,7 +443,7 @@ pre_sp(DECL_ARGS)
static int
pre_HP(DECL_ARGS)
{
- size_t len;
+ size_t len, one;
int ival;
const struct man_node *nn;
@@ -456,8 +468,11 @@ pre_HP(DECL_ARGS)
if ((ival = a2width(p, nn->string)) >= 0)
len = (size_t)ival;
- if (0 == len)
- len = term_len(p, 1);
+ one = term_len(p, 1);
+ if (len > one)
+ len -= one;
+ else
+ len = one;
p->offset = mt->offset;
p->rmargin = mt->offset + len;
@@ -520,7 +535,6 @@ pre_IP(DECL_ARGS)
switch (n->type) {
case (MAN_BODY):
- p->flags |= TERMP_NOLPAD;
p->flags |= TERMP_NOSPACE;
break;
case (MAN_HEAD):
@@ -591,7 +605,6 @@ post_IP(DECL_ARGS)
break;
case (MAN_BODY):
term_newln(p);
- p->flags &= ~TERMP_NOLPAD;
break;
default:
break;
@@ -612,7 +625,6 @@ pre_TP(DECL_ARGS)
p->flags |= TERMP_NOBREAK;
break;
case (MAN_BODY):
- p->flags |= TERMP_NOLPAD;
p->flags |= TERMP_NOSPACE;
break;
case (MAN_BLOCK):
@@ -681,7 +693,6 @@ post_TP(DECL_ARGS)
break;
case (MAN_BODY):
term_newln(p);
- p->flags &= ~TERMP_NOLPAD;
break;
default:
break;
@@ -882,7 +893,7 @@ print_man_node(DECL_ARGS)
* -man doesn't have nested macros, we don't need to be
* more specific than this.
*/
- if (MANT_LITERAL & mt->fl &&
+ if (MANT_LITERAL & mt->fl && ! (TERMP_NOBREAK & p->flags) &&
(NULL == n->next ||
n->next->line > n->line)) {
rm = p->rmargin;
@@ -890,7 +901,6 @@ print_man_node(DECL_ARGS)
p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
p->flags |= TERMP_NOSPACE;
term_flushln(p);
- p->flags &= ~TERMP_NOLPAD;
p->rmargin = rm;
p->maxrmargin = rmax;
}
@@ -972,7 +982,7 @@ print_man_foot(struct termp *p, const void *arg)
term_word(p, "");
term_flushln(p);
- p->flags |= TERMP_NOLPAD | TERMP_NOSPACE;
+ p->flags |= TERMP_NOSPACE;
p->offset = p->rmargin;
p->rmargin = p->maxrmargin;
p->flags &= ~TERMP_NOBREAK;
@@ -1019,7 +1029,7 @@ print_man_head(struct termp *p, const void *arg)
term_word(p, title);
term_flushln(p);
- p->flags |= TERMP_NOLPAD | TERMP_NOSPACE;
+ p->flags |= TERMP_NOSPACE;
p->offset = p->rmargin;
p->rmargin = p->offset + buflen + titlen < p->maxrmargin ?
p->maxrmargin - titlen : p->maxrmargin;
@@ -1029,7 +1039,7 @@ print_man_head(struct termp *p, const void *arg)
p->flags &= ~TERMP_NOBREAK;
if (p->rmargin + titlen <= p->maxrmargin) {
- p->flags |= TERMP_NOLPAD | TERMP_NOSPACE;
+ p->flags |= TERMP_NOSPACE;
p->offset = p->rmargin;
p->rmargin = p->maxrmargin;
term_word(p, title);