summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Sonnenberger <joerg@netbsd.org>2010-05-15 16:18:23 +0000
committerJoerg Sonnenberger <joerg@netbsd.org>2010-05-15 16:18:23 +0000
commit435e0fb79416aa764cb4f1b197ecbe24887f3de4 (patch)
treedb54c83ce33284706e8ee9dbf8c04c6ede4465ab
parentb9297c29623c1e4db9a654cff80d1ac016fdbaee (diff)
downloadmandoc-435e0fb79416aa764cb4f1b197ecbe24887f3de4.tar.gz
Make the output width an option for ascii_alloc and use that to compute
the default margin. Hard-code 80 chars/line for now.
-rw-r--r--main.c2
-rw-r--r--main.h2
-rw-r--r--man_term.c8
-rw-r--r--mdoc_term.c2
-rw-r--r--term.c12
-rw-r--r--term.h1
6 files changed, 18 insertions, 9 deletions
diff --git a/main.c b/main.c
index d8b95c7a..fa071f48 100644
--- a/main.c
+++ b/main.c
@@ -484,7 +484,7 @@ fdesc(struct curparse *curp)
case (OUTT_LINT):
break;
default:
- curp->outdata = ascii_alloc();
+ curp->outdata = ascii_alloc(80);
curp->outman = terminal_man;
curp->outmdoc = terminal_mdoc;
curp->outfree = terminal_free;
diff --git a/main.h b/main.h
index 63bc2b67..20ed51ec 100644
--- a/main.h
+++ b/main.h
@@ -38,7 +38,7 @@ void html_free(void *);
void tree_mdoc(void *, const struct mdoc *);
void tree_man(void *, const struct man *);
-void *ascii_alloc(void);
+void *ascii_alloc(size_t);
void terminal_mdoc(void *, const struct mdoc *);
void terminal_man(void *, const struct man *);
void terminal_free(void *);
diff --git a/man_term.c b/man_term.c
index f2410527..bde7680a 100644
--- a/man_term.c
+++ b/man_term.c
@@ -163,7 +163,7 @@ terminal_man(void *arg, const struct man *man)
p = (struct termp *)arg;
p->overstep = 0;
- p->maxrmargin = 65;
+ p->maxrmargin = p->defrmargin;
if (NULL == p->symtab)
switch (p->enc) {
@@ -803,6 +803,7 @@ post_RS(DECL_ARGS)
static void
print_man_node(DECL_ARGS)
{
+ size_t rm, rmax;
int c;
c = 1;
@@ -819,10 +820,13 @@ print_man_node(DECL_ARGS)
/* FIXME: this means that macro lines are munged! */
if (MANT_LITERAL & mt->fl) {
+ rm = p->rmargin;
+ rmax = p->maxrmargin;
p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
p->flags |= TERMP_NOSPACE;
term_flushln(p);
- p->rmargin = p->maxrmargin = 65;
+ p->rmargin = rm;
+ p->maxrmargin = rmax;
}
break;
default:
diff --git a/mdoc_term.c b/mdoc_term.c
index 7413a541..5cbcef77 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -273,7 +273,7 @@ terminal_mdoc(void *arg, const struct mdoc *mdoc)
p = (struct termp *)arg;
p->overstep = 0;
- p->maxrmargin = 78;
+ p->maxrmargin = p->defrmargin;
if (NULL == p->symtab)
switch (p->enc) {
diff --git a/term.c b/term.c
index bdd3d38c..8d612bbf 100644
--- a/term.c
+++ b/term.c
@@ -34,7 +34,7 @@
#include "mdoc.h"
#include "main.h"
-static struct termp *term_alloc(enum termenc);
+static struct termp *term_alloc(enum termenc, size_t);
static void term_free(struct termp *);
static void spec(struct termp *, const char *, size_t);
static void res(struct termp *, const char *, size_t);
@@ -45,10 +45,10 @@ static void encode(struct termp *, const char *, size_t);
void *
-ascii_alloc(void)
+ascii_alloc(size_t width)
{
- return(term_alloc(TERMENC_ASCII));
+ return(term_alloc(TERMENC_ASCII, width));
}
@@ -74,7 +74,7 @@ term_free(struct termp *p)
static struct termp *
-term_alloc(enum termenc enc)
+term_alloc(enum termenc enc, size_t width)
{
struct termp *p;
@@ -84,6 +84,10 @@ term_alloc(enum termenc enc)
exit(EXIT_FAILURE);
}
p->enc = enc;
+ /* Enforce some lower boundary. */
+ if (width < 60)
+ width = 60;
+ p->defrmargin = width - 2;
return(p);
}
diff --git a/term.h b/term.h
index 62da4174..b0df752f 100644
--- a/term.h
+++ b/term.h
@@ -32,6 +32,7 @@ enum termfont {
#define TERM_MAXMARGIN 100000 /* FIXME */
struct termp {
+ size_t defrmargin; /* Right margin of the device.. */
size_t rmargin; /* Current right margin. */
size_t maxrmargin; /* Max right margin. */
size_t maxcols; /* Max size of buf. */