diff options
-rw-r--r-- | man_term.c | 4 | ||||
-rw-r--r-- | mdoc_term.c | 4 | ||||
-rw-r--r-- | roff.7 | 6 | ||||
-rw-r--r-- | term.c | 32 | ||||
-rw-r--r-- | term.h | 6 | ||||
-rw-r--r-- | term_ascii.c | 20 | ||||
-rw-r--r-- | term_ps.c | 13 |
7 files changed, 63 insertions, 22 deletions
@@ -1,4 +1,4 @@ -/* $Id: man_term.c,v 1.143 2014/03/30 19:47:48 schwarze Exp $ */ +/* $Id: man_term.c,v 1.144 2014/03/30 21:28:01 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> @@ -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 5e1a10e8..aa29274f 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.260 2014/03/30 19:47:48 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.261 2014/03/30 21:28:01 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -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); } @@ -1,4 +1,4 @@ -.\" $Id: roff.7,v 1.50 2014/03/30 19:47:48 schwarze Exp $ +.\" $Id: roff.7,v 1.51 2014/03/30 21:28:01 schwarze Exp $ .\" .\" Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> .\" Copyright (c) 2010, 2011, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -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 @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.218 2014/03/23 11:25:26 schwarze Exp $ */ +/* $Id: term.c,v 1.219 2014/03/30 21:28:01 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> @@ -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) { @@ -1,4 +1,4 @@ -/* $Id: term.h,v 1.98 2014/03/30 19:47:48 schwarze Exp $ */ +/* $Id: term.h,v 1.99 2014/03/30 21:28:01 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -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 09f052c3..f40b0c2b 100644 --- a/term_ascii.c +++ b/term_ascii.c @@ -1,4 +1,4 @@ -/* $Id: term_ascii.c,v 1.23 2014/03/30 19:47:48 schwarze Exp $ */ +/* $Id: term_ascii.c,v 1.24 2014/03/30 21:28:01 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -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 */ @@ -1,4 +1,4 @@ -/* $Id: term_ps.c,v 1.57 2014/03/30 19:47:48 schwarze Exp $ */ +/* $Id: term_ps.c,v 1.58 2014/03/30 21:28:01 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -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; } |