aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--man_term.c8
-rw-r--r--mdoc_term.c27
-rw-r--r--term.c49
-rw-r--r--term.h13
4 files changed, 46 insertions, 51 deletions
diff --git a/man_term.c b/man_term.c
index 34448561..5a659503 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.144 2014/03/30 21:28:01 schwarze Exp $ */
+/* $Id: man_term.c,v 1.145 2014/04/08 07:13:11 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -278,7 +278,7 @@ pre_literal(DECL_ARGS)
p->offset = p->rmargin;
p->rmargin = p->maxrmargin;
p->trailspace = 0;
- p->flags &= ~TERMP_NOBREAK;
+ p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
p->flags |= TERMP_NOSPACE;
}
@@ -547,7 +547,7 @@ pre_HP(DECL_ARGS)
}
if ( ! (MANT_LITERAL & mt->fl)) {
- p->flags |= TERMP_NOBREAK;
+ p->flags |= TERMP_NOBREAK | TERMP_BRIND;
p->trailspace = 2;
}
@@ -582,7 +582,7 @@ post_HP(DECL_ARGS)
switch (n->type) {
case (MAN_BODY):
term_newln(p);
- p->flags &= ~TERMP_NOBREAK;
+ p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
p->trailspace = 0;
p->offset = mt->offset;
p->rmargin = p->maxrmargin;
diff --git a/mdoc_term.c b/mdoc_term.c
index 85314f6f..d209c009 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.262 2014/04/08 04:40:47 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.263 2014/04/08 07:13:12 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -819,14 +819,14 @@ termp_it_pre(DECL_ARGS)
MDOC_Bd == n->next->child->tok))
break;
- p->flags |= TERMP_NOBREAK | TERMP_HANG;
+ p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG;
p->trailspace = 1;
break;
case (LIST_tag):
if (MDOC_HEAD != n->type)
break;
- p->flags |= TERMP_NOBREAK;
+ p->flags |= TERMP_NOBREAK | TERMP_BRIND;
p->trailspace = 2;
if (NULL == n->next || NULL == n->next->child)
@@ -848,7 +848,7 @@ termp_it_pre(DECL_ARGS)
case (LIST_diag):
if (MDOC_HEAD != n->type)
break;
- p->flags |= TERMP_NOBREAK;
+ p->flags |= TERMP_NOBREAK | TERMP_BRIND;
p->trailspace = 1;
break;
default:
@@ -1002,9 +1002,8 @@ termp_it_post(DECL_ARGS)
* has munged them in the meanwhile.
*/
- p->flags &= ~TERMP_DANGLE;
- p->flags &= ~TERMP_NOBREAK;
- p->flags &= ~TERMP_HANG;
+ p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND |
+ TERMP_DANGLE | TERMP_HANG);
p->trailspace = 0;
}
@@ -1041,7 +1040,7 @@ termp_nm_pre(DECL_ARGS)
synopsis_pre(p, n->parent);
if (MDOC_HEAD == n->type && n->next->child) {
- p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
+ p->flags |= TERMP_NOSPACE | TERMP_NOBREAK | TERMP_BRIND;
p->trailspace = 1;
p->rmargin = p->offset + term_len(p, 1);
if (NULL == n->child) {
@@ -1072,7 +1071,7 @@ termp_nm_post(DECL_ARGS)
p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
} else if (MDOC_HEAD == n->type && n->next->child) {
term_flushln(p);
- p->flags &= ~(TERMP_NOBREAK | TERMP_HANG);
+ p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG);
p->trailspace = 0;
} else if (MDOC_BODY == n->type && n->child)
term_flushln(p);
@@ -1561,7 +1560,7 @@ termp_fn_pre(DECL_ARGS)
if (pretty) {
rmargin = p->rmargin;
p->rmargin = p->offset + term_len(p, 4);
- p->flags |= TERMP_NOBREAK | TERMP_HANG;
+ p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG;
}
assert(MDOC_TEXT == n->type);
@@ -1571,7 +1570,7 @@ termp_fn_pre(DECL_ARGS)
if (pretty) {
term_flushln(p);
- p->flags &= ~(TERMP_NOBREAK | TERMP_HANG);
+ p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG);
p->offset = p->rmargin;
p->rmargin = rmargin;
}
@@ -2063,14 +2062,16 @@ termp_fo_pre(DECL_ARGS)
if (pretty) {
rmargin = p->rmargin;
p->rmargin = p->offset + term_len(p, 4);
- p->flags |= TERMP_NOBREAK | TERMP_HANG;
+ p->flags |= TERMP_NOBREAK | TERMP_BRIND |
+ TERMP_HANG;
}
p->flags |= TERMP_NOSPACE;
term_word(p, "(");
p->flags |= TERMP_NOSPACE;
if (pretty) {
term_flushln(p);
- p->flags &= ~(TERMP_NOBREAK | TERMP_HANG);
+ p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND |
+ TERMP_HANG);
p->offset = p->rmargin;
p->rmargin = rmargin;
}
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
diff --git a/term.h b/term.h
index 54e7520b..0a27f757 100644
--- a/term.h
+++ b/term.h
@@ -1,4 +1,4 @@
-/* $Id: term.h,v 1.99 2014/03/30 21:28:01 schwarze Exp $ */
+/* $Id: term.h,v 1.100 2014/04/08 07:13:12 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -77,11 +77,12 @@ struct termp {
#define TERMP_PREKEEP (1 << 6) /* ...starting with the next one. */
#define TERMP_SKIPCHAR (1 << 7) /* Skip the next character. */
#define TERMP_NOBREAK (1 << 8) /* See term_flushln(). */
-#define TERMP_DANGLE (1 << 9) /* See term_flushln(). */
-#define TERMP_HANG (1 << 10) /* See term_flushln(). */
-#define TERMP_NOSPLIT (1 << 11) /* See termp_an_pre/post(). */
-#define TERMP_SPLIT (1 << 12) /* See termp_an_pre/post(). */
-#define TERMP_ANPREC (1 << 13) /* See termp_an_pre(). */
+#define TERMP_BRIND (1 << 9) /* See term_flushln(). */
+#define TERMP_DANGLE (1 << 10) /* See term_flushln(). */
+#define TERMP_HANG (1 << 11) /* See term_flushln(). */
+#define TERMP_NOSPLIT (1 << 12) /* See termp_an_pre/post(). */
+#define TERMP_SPLIT (1 << 13) /* See termp_an_pre/post(). */
+#define TERMP_ANPREC (1 << 14) /* See termp_an_pre(). */
int *buf; /* Output buffer. */
enum termenc enc; /* Type of encoding. */
struct mchars *symtab; /* Encoded-symbol table. */