aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2011-11-13 13:15:14 +0000
committerIngo Schwarze <schwarze@openbsd.org>2011-11-13 13:15:14 +0000
commitab6453fdca1be7946e737b3374ec480a539fc41e (patch)
treeca8912be6d0f13fd94b62678e66ccb0ac2d33ea4
parent26a93b19ed081622643e47785d2ba7810a015efc (diff)
downloadmandoc-ab6453fdca1be7946e737b3374ec480a539fc41e.tar.gz
mandoc-ab6453fdca1be7946e737b3374ec480a539fc41e.tar.zst
mandoc-ab6453fdca1be7946e737b3374ec480a539fc41e.zip
Make the default left text margin configurable from the command line,
just like the default right margin already is. This may be useful for people with expensive screen real estate. Besides, it helps automated man(7) to mdoc(7) output comparisons to validate -Tman output. ok kristaps@ on an earlier version
-rw-r--r--man_term.c27
-rw-r--r--mandoc.113
-rw-r--r--mdoc_term.c18
-rw-r--r--term.h3
-rw-r--r--term_ascii.c12
5 files changed, 44 insertions, 29 deletions
diff --git a/man_term.c b/man_term.c
index a4ebb1b4..63662337 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.121 2011/09/21 09:57:13 schwarze Exp $ */
+/* $Id: man_term.c,v 1.122 2011/11/13 13:15:14 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -33,8 +33,6 @@
#include "term.h"
#include "main.h"
-#define INDENT 7 /* fixed-width char full-indent */
-#define HALFINDENT 3 /* fixed-width char half-indent */
#define MAXMARGINS 64 /* maximum number of indented scopes */
/* FIXME: have PD set the default vspace width. */
@@ -141,6 +139,9 @@ terminal_man(void *arg, const struct man *man)
p = (struct termp *)arg;
+ if (0 == p->defindent)
+ p->defindent = 7;
+
p->overstep = 0;
p->maxrmargin = p->defrmargin;
p->tabwidth = term_len(p, 5);
@@ -156,8 +157,8 @@ terminal_man(void *arg, const struct man *man)
memset(&mt, 0, sizeof(struct mtermp));
- mt.lmargin[mt.lmargincur] = term_len(p, INDENT);
- mt.offset = term_len(p, INDENT);
+ mt.lmargin[mt.lmargincur] = term_len(p, p->defindent);
+ mt.offset = term_len(p, p->defindent);
if (n->child)
print_man_nodelist(p, &mt, n->child, m);
@@ -511,7 +512,7 @@ pre_PP(DECL_ARGS)
switch (n->type) {
case (MAN_BLOCK):
- mt->lmargin[mt->lmargincur] = term_len(p, INDENT);
+ mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
print_bvspace(p, n);
break;
default:
@@ -706,8 +707,8 @@ pre_SS(DECL_ARGS)
switch (n->type) {
case (MAN_BLOCK):
mt->fl &= ~MANT_LITERAL;
- mt->lmargin[mt->lmargincur] = term_len(p, INDENT);
- mt->offset = term_len(p, INDENT);
+ mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
+ mt->offset = term_len(p, p->defindent);
/* If following a prior empty `SS', no vspace. */
if (n->prev && MAN_SS == n->prev->tok)
if (NULL == n->prev->body->child)
@@ -718,7 +719,7 @@ pre_SS(DECL_ARGS)
break;
case (MAN_HEAD):
term_fontrepl(p, TERMFONT_BOLD);
- p->offset = term_len(p, HALFINDENT);
+ p->offset = term_len(p, p->defindent/2);
break;
case (MAN_BODY):
p->offset = mt->offset;
@@ -757,8 +758,8 @@ pre_SH(DECL_ARGS)
switch (n->type) {
case (MAN_BLOCK):
mt->fl &= ~MANT_LITERAL;
- mt->lmargin[mt->lmargincur] = term_len(p, INDENT);
- mt->offset = term_len(p, INDENT);
+ mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
+ mt->offset = term_len(p, p->defindent);
/* If following a prior empty `SH', no vspace. */
if (n->prev && MAN_SH == n->prev->tok)
if (NULL == n->prev->body->child)
@@ -817,7 +818,7 @@ pre_RS(DECL_ARGS)
break;
}
- sz = term_len(p, INDENT);
+ sz = term_len(p, p->defindent);
if (NULL != (n = n->parent->head->child))
if ((ival = a2width(p, n->string)) >= 0)
@@ -851,7 +852,7 @@ post_RS(DECL_ARGS)
break;
}
- sz = term_len(p, INDENT);
+ sz = term_len(p, p->defindent);
if (NULL != (n = n->parent->head->child))
if ((ival = a2width(p, n->string)) >= 0)
diff --git a/mandoc.1 b/mandoc.1
index 0dd7c29e..0a5048e7 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -1,4 +1,4 @@
-.\" $Id: mandoc.1,v 1.97 2011/10/09 21:37:06 schwarze Exp $
+.\" $Id: mandoc.1,v 1.98 2011/11/13 13:15:14 schwarze Exp $
.\"
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: October 9 2011 $
+.Dd $Mdocdate: November 13 2011 $
.Dt MANDOC 1
.Os
.Sh NAME
@@ -234,6 +234,15 @@ The following
.Fl O
arguments are accepted:
.Bl -tag -width Ds
+.It Cm indent Ns = Ns Ar indent
+The left margin for normal text is set to
+.Ar indent
+blank characters instead of the default of five for
+.Xr mdoc 7
+and seven for
+.Xr man 7 .
+Increasing this is not recommended; it may result in degraded formatting,
+for example overful lines or ugly line breaks.
.It Cm width Ns = Ns Ar width
The output width is set to
.Ar width ,
diff --git a/mdoc_term.c b/mdoc_term.c
index 9b01d651..53335664 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.237 2011/11/03 20:36:59 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.238 2011/11/13 13:15:14 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -34,9 +34,6 @@
#include "mdoc.h"
#include "main.h"
-#define INDENT 5
-#define HALFINDENT 3
-
struct termpair {
struct termpair *ppair;
int count;
@@ -259,6 +256,9 @@ terminal_mdoc(void *arg, const struct mdoc *mdoc)
p = (struct termp *)arg;
+ if (0 == p->defindent)
+ p->defindent = 5;
+
p->overstep = 0;
p->maxrmargin = p->defrmargin;
p->tabwidth = term_len(p, 5);
@@ -562,9 +562,9 @@ a2offs(const struct termp *p, const char *v)
else if (0 == strcmp(v, "left"))
return(0);
else if (0 == strcmp(v, "indent"))
- return(term_len(p, INDENT + 1));
+ return(term_len(p, p->defindent + 1));
else if (0 == strcmp(v, "indent-two"))
- return(term_len(p, (INDENT + 1) * 2));
+ return(term_len(p, (p->defindent + 1) * 2));
else if ( ! a2roffsu(v, &su, SCALE_MAX))
SCALE_HS_INIT(&su, term_strlen(p, v));
@@ -1424,7 +1424,7 @@ termp_sh_pre(DECL_ARGS)
term_fontpush(p, TERMFONT_BOLD);
break;
case (MDOC_BODY):
- p->offset = term_len(p, INDENT);
+ p->offset = term_len(p, p->defindent);
break;
default:
break;
@@ -1492,7 +1492,7 @@ termp_d1_pre(DECL_ARGS)
if (MDOC_BLOCK != n->type)
return(1);
term_newln(p);
- p->offset += term_len(p, (INDENT + 1));
+ p->offset += term_len(p, p->defindent + 1);
return(1);
}
@@ -1797,7 +1797,7 @@ termp_ss_pre(DECL_ARGS)
break;
case (MDOC_HEAD):
term_fontpush(p, TERMFONT_BOLD);
- p->offset = term_len(p, HALFINDENT);
+ p->offset = term_len(p, (p->defindent+1)/2);
break;
default:
break;
diff --git a/term.h b/term.h
index 685d0962..0758f772 100644
--- a/term.h
+++ b/term.h
@@ -1,4 +1,4 @@
-/* $Id: term.h,v 1.88 2011/09/19 22:36:16 schwarze Exp $ */
+/* $Id: term.h,v 1.89 2011/11/13 13:15:14 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -52,6 +52,7 @@ struct termp_tbl {
struct termp {
enum termtype type;
struct rofftbl tbl; /* table configuration */
+ size_t defindent; /* Default indent for text. */
size_t defrmargin; /* Right margin of the device. */
size_t rmargin; /* Current right margin. */
size_t maxrmargin; /* Max right margin. */
diff --git a/term_ascii.c b/term_ascii.c
index 8283aede..a1d3bc1c 100644
--- a/term_ascii.c
+++ b/term_ascii.c
@@ -1,4 +1,4 @@
-/* $Id: term_ascii.c,v 1.18 2011/09/18 14:14:15 schwarze Exp $ */
+/* $Id: term_ascii.c,v 1.19 2011/11/13 13:15:14 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -68,7 +68,7 @@ static size_t locale_width(const struct termp *, int);
static struct termp *
ascii_init(enum termenc enc, char *outopts)
{
- const char *toks[2];
+ const char *toks[3];
char *v;
struct termp *p;
@@ -104,12 +104,16 @@ ascii_init(enum termenc enc, char *outopts)
}
#endif
- toks[0] = "width";
- toks[1] = NULL;
+ toks[0] = "indent";
+ toks[1] = "width";
+ toks[2] = NULL;
while (outopts && *outopts)
switch (getsubopt(&outopts, UNCONST(toks), &v)) {
case (0):
+ p->defindent = (size_t)atoi(v);
+ break;
+ case (1):
p->defrmargin = (size_t)atoi(v);
break;
default: