diff options
author | Joerg Sonnenberger <joerg@netbsd.org> | 2010-05-15 16:18:23 +0000 |
---|---|---|
committer | Joerg Sonnenberger <joerg@netbsd.org> | 2010-05-15 16:18:23 +0000 |
commit | 435e0fb79416aa764cb4f1b197ecbe24887f3de4 (patch) | |
tree | db54c83ce33284706e8ee9dbf8c04c6ede4465ab | |
parent | b9297c29623c1e4db9a654cff80d1ac016fdbaee (diff) | |
download | mandoc-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.c | 2 | ||||
-rw-r--r-- | main.h | 2 | ||||
-rw-r--r-- | man_term.c | 8 | ||||
-rw-r--r-- | mdoc_term.c | 2 | ||||
-rw-r--r-- | term.c | 12 | ||||
-rw-r--r-- | term.h | 1 |
6 files changed, 18 insertions, 9 deletions
@@ -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; @@ -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 *); @@ -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) { @@ -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); } @@ -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. */ |