summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2017-06-14 23:23:52 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2017-06-14 23:23:52 +0000
commitd85e2a30153fda2c6076da0ced09ab2e6f928d48 (patch)
tree6ddfbdf3b8eac4860c5d633c2a5ddc1d837c5cb3
parent73f02f010c9859d465642793bb2c4dd4a9434c74 (diff)
implement so-called absolute horizontal motion: \h'|...',
used for example by zoem(1)
-rw-r--r--regress/usr.bin/mandoc/roff/esc/h.in2
-rw-r--r--regress/usr.bin/mandoc/roff/esc/h.out_ascii1
-rw-r--r--regress/usr.bin/mandoc/roff/esc/h.out_lint2
-rw-r--r--share/man/man7/roff.79
-rw-r--r--usr.bin/mandoc/term.c9
5 files changed, 17 insertions, 6 deletions
diff --git a/regress/usr.bin/mandoc/roff/esc/h.in b/regress/usr.bin/mandoc/roff/esc/h.in
index 56e4275cd3c..8fa23e7b12f 100644
--- a/regress/usr.bin/mandoc/roff/esc/h.in
+++ b/regress/usr.bin/mandoc/roff/esc/h.in
@@ -9,6 +9,8 @@ simple: >\h'0'<
.br
rounding: >\h'0.16i'<
.br
+absolute: >\h'|12n'<
+.br
escape only: >\h'\w'\&'M'<
.br
escape at the end: >\h'0+\w'\&''<
diff --git a/regress/usr.bin/mandoc/roff/esc/h.out_ascii b/regress/usr.bin/mandoc/roff/esc/h.out_ascii
index ae378a45e9c..ddfac195362 100644
--- a/regress/usr.bin/mandoc/roff/esc/h.out_ascii
+++ b/regress/usr.bin/mandoc/roff/esc/h.out_ascii
@@ -6,6 +6,7 @@ NNAAMMEE
DDEESSCCRRIIPPTTIIOONN
simple: ><
rounding: > <
+ absolute: > <
escape only: ><
escape at the end: ><
escape at the beginning: ><
diff --git a/regress/usr.bin/mandoc/roff/esc/h.out_lint b/regress/usr.bin/mandoc/roff/esc/h.out_lint
index b7facfb1ebb..23ff9ce8bf9 100644
--- a/regress/usr.bin/mandoc/roff/esc/h.out_lint
+++ b/regress/usr.bin/mandoc/roff/esc/h.out_lint
@@ -1,2 +1,2 @@
-mandoc: h.in:20:21: WARNING: invalid escape sequence: \h-
+mandoc: h.in:22:21: WARNING: invalid escape sequence: \h-
mandoc: h.in:1:5: STYLE: Mdocdate missing: Dd May
diff --git a/share/man/man7/roff.7 b/share/man/man7/roff.7
index 9409bb19419..3e01893d483 100644
--- a/share/man/man7/roff.7
+++ b/share/man/man7/roff.7
@@ -1,4 +1,4 @@
-.\" $OpenBSD: roff.7,v 1.72 2017/06/14 22:50:37 schwarze Exp $
+.\" $OpenBSD: roff.7,v 1.73 2017/06/14 23:23:51 schwarze Exp $
.\"
.\" Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2010,2011,2013-2015,2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -1954,8 +1954,11 @@ and
.Ss \eH\(aq Ns Oo +|- Oc Ns Ar number Ns \(aq
Set the height of the current font; ignored by
.Xr mandoc 1 .
-.Ss \eh\(aq Ns Ar width Ns \(aq
-Horizontal motion relative to the current position.
+.Ss \eh\(aq Ns Oo Cm \&| Oc Ns Ar width Ns \(aq
+Horizontal motion.
+If the vertical bar is given, the motion is relative to the current
+indentation.
+Otherwise, it is relative to the current position.
The default scaling unit is
.Cm m .
.Ss \ek[ Ns Ar name ]
diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c
index 0f59fdc5439..0970f6835b0 100644
--- a/usr.bin/mandoc/term.c
+++ b/usr.bin/mandoc/term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: term.c,v 1.132 2017/06/14 18:23:26 schwarze Exp $ */
+/* $OpenBSD: term.c,v 1.133 2017/06/14 23:23:51 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -524,9 +524,14 @@ term_word(struct termp *p, const char *word)
p->flags |= (TERMP_NOSPACE | TERMP_NONEWLINE);
continue;
case ESCAPE_HORIZ:
+ if (*seq == '|') {
+ seq++;
+ uc = -p->col;
+ } else
+ uc = 0;
if (a2roffsu(seq, &su, SCALE_EM) == NULL)
continue;
- uc = term_hen(p, &su);
+ uc += term_hen(p, &su);
if (uc > 0)
while (uc-- > 0)
bufferc(p, ASCII_NBRSP);