aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/man_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2012-07-29 12:35:42 +0000
committerIngo Schwarze <schwarze@openbsd.org>2012-07-29 12:35:42 +0000
commit068480942200dc38803cc7423614aae3d1fd6978 (patch)
treea3578d1da0fe2c930326dcb865625075d30deb67 /man_term.c
parent57839926b7f5afc693c79a347c6ffd83a56bb780 (diff)
downloadmandoc-068480942200dc38803cc7423614aae3d1fd6978.tar.gz
mandoc-068480942200dc38803cc7423614aae3d1fd6978.tar.zst
mandoc-068480942200dc38803cc7423614aae3d1fd6978.zip
Implement .PD for -Tascii.
Reminded about the missing feature by millert@. This reduces mandoc/groff differences in OpenBSD base by 25%. ok millert@
Diffstat (limited to 'man_term.c')
-rw-r--r--man_term.c48
1 files changed, 35 insertions, 13 deletions
diff --git a/man_term.c b/man_term.c
index c8d558e0..b9ea22ab 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.133 2012/07/16 21:59:40 schwarze Exp $ */
+/* $Id: man_term.c,v 1.134 2012/07/29 12:35:42 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012 Ingo Schwarze <schwarze@openbsd.org>
@@ -35,8 +35,6 @@
#define MAXMARGINS 64 /* maximum number of indented scopes */
-/* FIXME: have PD set the default vspace width. */
-
struct mtermp {
int fl;
#define MANT_LITERAL (1 << 0)
@@ -44,6 +42,7 @@ struct mtermp {
int lmargincur; /* index of current margin */
int lmarginsz; /* actual number of nested margins */
size_t offset; /* default offset to visible page */
+ int pardist; /* vert. space before par., unit: [v] */
};
#define DECL_ARGS struct termp *p, \
@@ -66,13 +65,14 @@ static void print_man_node(DECL_ARGS);
static void print_man_head(struct termp *, const void *);
static void print_man_foot(struct termp *, const void *);
static void print_bvspace(struct termp *,
- const struct man_node *);
+ const struct man_node *, int);
static int pre_B(DECL_ARGS);
static int pre_HP(DECL_ARGS);
static int pre_I(DECL_ARGS);
static int pre_IP(DECL_ARGS);
static int pre_OP(DECL_ARGS);
+static int pre_PD(DECL_ARGS);
static int pre_PP(DECL_ARGS);
static int pre_RS(DECL_ARGS);
static int pre_SH(DECL_ARGS);
@@ -122,7 +122,7 @@ static const struct termact termacts[MAN_MAX] = {
{ pre_RS, post_RS, 0 }, /* RS */
{ pre_ign, NULL, 0 }, /* DT */
{ pre_ign, NULL, 0 }, /* UC */
- { pre_ign, NULL, 0 }, /* PD */
+ { pre_PD, NULL, MAN_NOTEXT }, /* PD */
{ pre_ign, NULL, 0 }, /* AT */
{ pre_in, NULL, MAN_NOTEXT }, /* in */
{ pre_ft, NULL, MAN_NOTEXT }, /* ft */
@@ -163,6 +163,7 @@ terminal_man(void *arg, const struct man *man)
mt.lmargin[mt.lmargincur] = term_len(p, p->defindent);
mt.offset = term_len(p, p->defindent);
+ mt.pardist = 1;
if (n->child)
print_man_nodelist(p, &mt, n->child, m);
@@ -203,8 +204,9 @@ a2width(const struct termp *p, const char *cp)
* first, print it.
*/
static void
-print_bvspace(struct termp *p, const struct man_node *n)
+print_bvspace(struct termp *p, const struct man_node *n, int pardist)
{
+ int i;
term_newln(p);
@@ -216,7 +218,8 @@ print_bvspace(struct termp *p, const struct man_node *n)
if (NULL == n->prev)
return;
- term_vspace(p);
+ for (i = 0; i < pardist; i++)
+ term_vspace(p);
}
/* ARGSUSED */
@@ -267,6 +270,21 @@ pre_literal(DECL_ARGS)
/* ARGSUSED */
static int
+pre_PD(DECL_ARGS)
+{
+
+ n = n->child;
+ if (0 == n) {
+ mt->pardist = 1;
+ return(0);
+ }
+ assert(MAN_TEXT == n->type);
+ mt->pardist = atoi(n->string);
+ return(0);
+}
+
+/* ARGSUSED */
+static int
pre_alternate(DECL_ARGS)
{
enum termfont font[2];
@@ -503,7 +521,7 @@ pre_HP(DECL_ARGS)
switch (n->type) {
case (MAN_BLOCK):
- print_bvspace(p, n);
+ print_bvspace(p, n, mt->pardist);
return(1);
case (MAN_BODY):
break;
@@ -566,7 +584,7 @@ pre_PP(DECL_ARGS)
switch (n->type) {
case (MAN_BLOCK):
mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
- print_bvspace(p, n);
+ print_bvspace(p, n, mt->pardist);
break;
default:
p->offset = mt->offset;
@@ -593,7 +611,7 @@ pre_IP(DECL_ARGS)
p->flags |= TERMP_NOBREAK;
break;
case (MAN_BLOCK):
- print_bvspace(p, n);
+ print_bvspace(p, n, mt->pardist);
/* FALLTHROUGH */
default:
return(1);
@@ -680,7 +698,7 @@ pre_TP(DECL_ARGS)
p->flags |= TERMP_NOSPACE;
break;
case (MAN_BLOCK):
- print_bvspace(p, n);
+ print_bvspace(p, n, mt->pardist);
/* FALLTHROUGH */
default:
return(1);
@@ -755,6 +773,7 @@ post_TP(DECL_ARGS)
static int
pre_SS(DECL_ARGS)
{
+ int i;
switch (n->type) {
case (MAN_BLOCK):
@@ -767,7 +786,8 @@ pre_SS(DECL_ARGS)
break;
if (NULL == n->prev)
break;
- term_vspace(p);
+ for (i = 0; i < mt->pardist; i++)
+ term_vspace(p);
break;
case (MAN_HEAD):
term_fontrepl(p, TERMFONT_BOLD);
@@ -806,6 +826,7 @@ post_SS(DECL_ARGS)
static int
pre_SH(DECL_ARGS)
{
+ int i;
switch (n->type) {
case (MAN_BLOCK):
@@ -819,7 +840,8 @@ pre_SH(DECL_ARGS)
/* If the first macro, no vspae. */
if (NULL == n->prev)
break;
- term_vspace(p);
+ for (i = 0; i < mt->pardist; i++)
+ term_vspace(p);
break;
case (MAN_HEAD):
term_fontrepl(p, TERMFONT_BOLD);