aboutsummaryrefslogtreecommitdiffstatshomepage
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
commiteee1390dda1a4f11d87431577c7c95163d5f60a5 (patch)
treebfd4c404a511c3347f250bce4bf8275bccd2b834 /man_term.c
parent80a2117d1c762a36f59899a3fa11da69900d340b (diff)
downloadmandoc-eee1390dda1a4f11d87431577c7c95163d5f60a5.tar.gz
mandoc-eee1390dda1a4f11d87431577c7c95163d5f60a5.tar.zst
mandoc-eee1390dda1a4f11d87431577c7c95163d5f60a5.zip
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.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/man_term.c b/man_term.c
index c7150153..219e0a2b 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.116 2011/09/18 21:08:34 schwarze Exp $ */
+/* $Id: man_term.c,v 1.117 2011/09/19 22:36:16 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -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);