diff options
-rw-r--r-- | man_term.c | 2 | ||||
-rw-r--r-- | mdoc_term.c | 2 | ||||
-rw-r--r-- | roff.7 | 4 | ||||
-rw-r--r-- | term.c | 30 | ||||
-rw-r--r-- | term.h | 4 | ||||
-rw-r--r-- | term_ascii.c | 18 | ||||
-rw-r--r-- | term_ps.c | 11 |
7 files changed, 56 insertions, 15 deletions
@@ -242,7 +242,7 @@ static int pre_ll(DECL_ARGS) { - (*p->setwidth)(p, n->nchild ? a2width(p, n->child->string) : 0); + term_setwidth(p, n->nchild ? n->child->string : NULL); return(0); } diff --git a/mdoc_term.c b/mdoc_term.c index 8da9366b..e6d85e8e 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -622,7 +622,7 @@ static int termp_ll_pre(DECL_ARGS) { - (*p->setwidth)(p, n->nchild ? a2width(p, n->child->string) : 0); + term_setwidth(p, n->nchild ? n->child->string : NULL); return(0); } @@ -878,12 +878,14 @@ request are discarded. Change the output line length. Its syntax is as follows: .Pp -.D1 Pf . Cm \&ll Op Ar width +.D1 Pf . Cm \&ll Op Oo +|- Oc Ns Ar width .Pp If the .Ar width argument is omitted, the line length is reset to its previous value. The default setting for terminal output is 78n. +If a sign is given, the line length is added to or subtracted from; +otherwise, it is set to the provided value. Using this request in new manuals is discouraged for several reasons, among others because it overrides the .Xr mandoc 1 @@ -623,6 +623,36 @@ encode(struct termp *p, const char *word, size_t sz) } } +void +term_setwidth(struct termp *p, const char *wstr) +{ + struct roffsu su; + size_t width; + int iop; + + if (NULL != wstr) { + switch (*wstr) { + case ('+'): + iop = 1; + wstr++; + break; + case ('-'): + iop = -1; + wstr++; + break; + default: + iop = 0; + break; + } + if ( ! a2roffsu(wstr, &su, SCALE_MAX)) { + wstr = NULL; + iop = 0; + } + } + width = (NULL != wstr) ? term_hspan(p, &su) : 0; + (*p->setwidth)(p, iop, width); +} + size_t term_len(const struct termp *p, size_t sz) { @@ -95,7 +95,7 @@ struct termp { void (*end)(struct termp *); void (*endline)(struct termp *); void (*advance)(struct termp *, size_t); - void (*setwidth)(struct termp *, size_t); + void (*setwidth)(struct termp *, int, size_t); size_t (*width)(const struct termp *, int); double (*hspan)(const struct termp *, const struct roffsu *); @@ -114,7 +114,7 @@ void term_begin(struct termp *, term_margin, term_margin, const void *); void term_end(struct termp *); -void term_setwidth(struct termp *, size_t); +void term_setwidth(struct termp *, const char *); size_t term_hspan(const struct termp *, const struct roffsu *); size_t term_vspan(const struct termp *, diff --git a/term_ascii.c b/term_ascii.c index a9242348..edf203a2 100644 --- a/term_ascii.c +++ b/term_ascii.c @@ -58,7 +58,7 @@ static void ascii_begin(struct termp *); static void ascii_end(struct termp *); static void ascii_endline(struct termp *); static void ascii_letter(struct termp *, int); -static void ascii_setwidth(struct termp *, size_t); +static void ascii_setwidth(struct termp *, int, size_t); #ifdef USE_WCHAR static void locale_advance(struct termp *, size_t); @@ -161,14 +161,18 @@ locale_alloc(char *outopts) } static void -ascii_setwidth(struct termp *p, size_t width) +ascii_setwidth(struct termp *p, int iop, size_t width) { - size_t lastwidth; - lastwidth = p->defrmargin; - p->rmargin = p->maxrmargin = p->defrmargin = - width ? width : p->lastrmargin; - p->lastrmargin = lastwidth; + p->rmargin = p->defrmargin; + if (0 < iop) + p->defrmargin += width; + else if (0 > iop) + p->defrmargin -= width; + else + p->defrmargin = width ? width : p->lastrmargin; + p->lastrmargin = p->rmargin; + p->rmargin = p->maxrmargin = p->defrmargin; } /* ARGSUSED */ @@ -106,7 +106,7 @@ __attribute__((__format__ (__printf__, 2, 3))) static void ps_printf(struct termp *, const char *, ...); static void ps_putchar(struct termp *, char); static void ps_setfont(struct termp *, enum termfont); -static void ps_setwidth(struct termp *, size_t); +static void ps_setwidth(struct termp *, int, size_t); static struct termp *pspdf_alloc(char *); static void pdf_obj(struct termp *, size_t); @@ -536,12 +536,17 @@ pspdf_alloc(char *outopts) static void -ps_setwidth(struct termp *p, size_t width) +ps_setwidth(struct termp *p, int iop, size_t width) { size_t lastwidth; lastwidth = p->ps->width; - p->ps->width = width ? width : p->ps->lastwidth; + if (0 < iop) + p->ps->width += width; + else if (0 > iop) + p->ps->width -= width; + else + p->ps->width = width ? width : p->ps->lastwidth; p->ps->lastwidth = lastwidth; } |