summaryrefslogtreecommitdiffstats
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
commit36ea49d05167f8ba695622ec59362f449d8882bf (patch)
treedde2ce5c54dc714cd80e97945a0bfaa78d7a29eb /man_term.c
parentd40f01e01b9fd995ed3ff236f92882a453ac2d00 (diff)
downloadmandoc-36ea49d05167f8ba695622ec59362f449d8882bf.tar.gz
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.c46
1 files changed, 34 insertions, 12 deletions
diff --git a/man_term.c b/man_term.c
index e7535cad..3d7016a5 100644
--- a/man_term.c
+++ b/man_term.c
@@ -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);