From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (schwarze@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id pADDFF7E001468 for ; Sun, 13 Nov 2011 08:15:15 -0500 (EST) Received: (from schwarze@localhost) by krisdoz.my.domain (8.14.3/8.14.3/Submit) id pADDFFuY005452; Sun, 13 Nov 2011 08:15:15 -0500 (EST) Date: Sun, 13 Nov 2011 08:15:15 -0500 (EST) Message-Id: <201111131315.pADDFFuY005452@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: Make the default left text margin configurable from the command X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- 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 Modified Files: -------------- mdocml: man_term.c mandoc.1 mdoc_term.c term.h term_ascii.c Revision Data ------------- Index: term.h =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term.h,v retrieving revision 1.88 retrieving revision 1.89 diff -Lterm.h -Lterm.h -u -p -r1.88 -r1.89 --- term.h +++ term.h @@ -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. */ Index: mandoc.1 =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.1,v retrieving revision 1.97 retrieving revision 1.98 diff -Lmandoc.1 -Lmandoc.1 -u -p -r1.97 -r1.98 --- mandoc.1 +++ mandoc.1 @@ -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 , Index: man_term.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_term.c,v retrieving revision 1.121 retrieving revision 1.122 diff -Lman_term.c -Lman_term.c -u -p -r1.121 -r1.122 --- man_term.c +++ man_term.c @@ -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 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 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) Index: term_ascii.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term_ascii.c,v retrieving revision 1.18 retrieving revision 1.19 diff -Lterm_ascii.c -Lterm_ascii.c -u -p -r1.18 -r1.19 --- term_ascii.c +++ term_ascii.c @@ -68,7 +68,7 @@ static size_t locale_width(const stru 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 *outop } #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: Index: mdoc_term.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_term.c,v retrieving revision 1.237 retrieving revision 1.238 diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.237 -r1.238 --- mdoc_term.c +++ mdoc_term.c @@ -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 md 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 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; -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv