summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--man_term.c2
-rw-r--r--mdoc_term.c2
-rw-r--r--roff.74
-rw-r--r--term.c30
-rw-r--r--term.h4
-rw-r--r--term_ascii.c18
-rw-r--r--term_ps.c11
7 files changed, 56 insertions, 15 deletions
diff --git a/man_term.c b/man_term.c
index 0b18d4a5..a8e8971f 100644
--- a/man_term.c
+++ b/man_term.c
@@ -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);
}
diff --git a/roff.7 b/roff.7
index 7a60cf30..d9e0b999 100644
--- a/roff.7
+++ b/roff.7
@@ -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
diff --git a/term.c b/term.c
index 39dbf2e1..a8f2d3f0 100644
--- a/term.c
+++ b/term.c
@@ -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)
{
diff --git a/term.h b/term.h
index f676afe8..802d2076 100644
--- a/term.h
+++ b/term.h
@@ -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 */
diff --git a/term_ps.c b/term_ps.c
index 845028a9..6e46502a 100644
--- a/term_ps.c
+++ b/term_ps.c
@@ -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;
}