aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-04-08 07:13:11 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-04-08 07:13:11 +0000
commit54ecda87da2932c7457339c66a54bb18190a7306 (patch)
tree89b42b6079612358db9d0c25510517be13ec6fa5 /term.c
parentafd2d83121837880082344a1125e3e44aa078d3e (diff)
downloadmandoc-54ecda87da2932c7457339c66a54bb18190a7306.tar.gz
mandoc-54ecda87da2932c7457339c66a54bb18190a7306.tar.zst
mandoc-54ecda87da2932c7457339c66a54bb18190a7306.zip
Add a new term_flushln() flag TERMP_BRIND (if break, then indent)
to control indentation of continuation lines in TERMP_NOBREAK mode. In the past, this was always on; continue using it for .Bl, .Nm, .Fn, .Fo, and .HP, but no longer for .IP and .TP. I looked at this because sthen@ reported the issue in a manual of a Perl module from ports, but it affects base, too: This patch reduces groff-mandoc differences in base by more than 15%.
Diffstat (limited to 'term.c')
-rw-r--r--term.c49
1 files changed, 21 insertions, 28 deletions
diff --git a/term.c b/term.c
index 1cd4f9d5..263f4760 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.220 2014/04/05 21:18:19 schwarze Exp $ */
+/* $Id: term.c,v 1.221 2014/04/08 07:13:12 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -72,34 +72,27 @@ term_end(struct termp *p)
}
/*
- * Flush a line of text. A "line" is loosely defined as being something
- * that should be followed by a newline, regardless of whether it's
- * broken apart by newlines getting there. A line can also be a
- * fragment of a columnar list (`Bl -tag' or `Bl -column'), which does
- * not have a trailing newline.
- *
+ * Flush a chunk of text. By default, break the output line each time
+ * the right margin is reached, and continue output on the next line
+ * at the same offset as the chunk itself. By default, also break the
+ * output line at the end of the chunk.
* The following flags may be specified:
*
- * - TERMP_NOBREAK: this is the most important and is used when making
- * columns. In short: don't print a newline and instead expect the
- * next call to do the padding up to the start of the next column.
- * p->trailspace may be set to 0, 1, or 2, depending on how many
- * space characters are required at the end of the column.
- *
- * - TERMP_DANGLE: don't newline when TERMP_NOBREAK is specified and
- * the line is overrun, and don't pad-right if it's underrun.
- *
- * - TERMP_HANG: like TERMP_DANGLE, but doesn't newline when
- * overrunning, instead save the position and continue at that point
- * when the next invocation.
- *
- * In-line line breaking:
- *
- * If TERMP_NOBREAK is specified and the line overruns the right
- * margin, it will break and pad-right to the right margin after
- * writing. If maxrmargin is violated, it will break and continue
- * writing from the right-margin, which will lead to the above scenario
- * upon exit. Otherwise, the line will break at the right margin.
+ * - TERMP_NOBREAK: Do not break the output line at the right margin,
+ * but only at the max right margin. Also, do not break the output
+ * line at the end of the chunk, such that the next call can pad to
+ * the next column. However, if less than p->trailspace blanks,
+ * which can be 0, 1, or 2, remain to the right margin, the line
+ * will be broken.
+ * - TERMP_BRIND: If the chunk does not fit and the output line has
+ * to be broken, start the next line at the right margin instead
+ * of at the offset. Used together with TERMP_NOBREAK for the tags
+ * in various kinds of tagged lists.
+ * - TERMP_DANGLE: Do not break the output line at the right margin,
+ * append the next chunk after it even if this one is too long.
+ * To be used together with TERMP_NOBREAK.
+ * - TERMP_HANG: Like TERMP_DANGLE, and also suppress padding before
+ * the next chunk if this column is not full.
*/
void
term_flushln(struct termp *p)
@@ -201,7 +194,7 @@ term_flushln(struct termp *p)
vend -= vis;
(*p->endline)(p);
p->viscol = 0;
- if (TERMP_NOBREAK & p->flags) {
+ if (TERMP_BRIND & p->flags) {
vbl = p->rmargin;
vend += p->rmargin - p->offset;
} else