summaryrefslogtreecommitdiffstats
path: root/roff_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-06-14 22:51:25 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-06-14 22:51:25 +0000
commit91f0f16f2181a2ac79aecf7026518b21cf15770f (patch)
treefd0b81e0b7d9aa319a83d358e1dc96ae8be2f6b6 /roff_term.c
parenta20ce5b08da3bf35aba0065fbac0a3b322fc5e1d (diff)
downloadmandoc-91f0f16f2181a2ac79aecf7026518b21cf15770f.tar.gz
Naive implementation of the roff(7) .po (page offset) request.
This clearly works when .po is called on the top level, but might not be sophisticated enough if people call .po inside indentation-changing contexts, but i haven't seen that in manual pages (yet :).
Diffstat (limited to 'roff_term.c')
-rw-r--r--roff_term.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/roff_term.c b/roff_term.c
index 59de74fc..5a838ea2 100644
--- a/roff_term.c
+++ b/roff_term.c
@@ -32,6 +32,7 @@ static void roff_term_pre_ce(ROFF_TERM_ARGS);
static void roff_term_pre_ft(ROFF_TERM_ARGS);
static void roff_term_pre_ll(ROFF_TERM_ARGS);
static void roff_term_pre_mc(ROFF_TERM_ARGS);
+static void roff_term_pre_po(ROFF_TERM_ARGS);
static void roff_term_pre_sp(ROFF_TERM_ARGS);
static void roff_term_pre_ta(ROFF_TERM_ARGS);
static void roff_term_pre_ti(ROFF_TERM_ARGS);
@@ -42,6 +43,7 @@ static const roff_term_pre_fp roff_term_pre_acts[ROFF_MAX] = {
roff_term_pre_ft, /* ft */
roff_term_pre_ll, /* ll */
roff_term_pre_mc, /* mc */
+ roff_term_pre_po, /* po */
roff_term_pre_ce, /* rj */
roff_term_pre_sp, /* sp */
roff_term_pre_ta, /* ta */
@@ -153,6 +155,28 @@ roff_term_pre_mc(ROFF_TERM_ARGS)
}
static void
+roff_term_pre_po(ROFF_TERM_ARGS)
+{
+ struct roffsu su;
+ static int po, polast;
+ int ponew;
+
+ if (n->child != NULL &&
+ a2roffsu(n->child->string, &su, SCALE_EM) != NULL) {
+ ponew = term_hen(p, &su);
+ if (*n->child->string == '+' ||
+ *n->child->string == '-')
+ ponew += po;
+ } else
+ ponew = polast;
+ polast = po;
+ po = ponew;
+
+ ponew = po - polast + (int)p->tcol->offset;
+ p->tcol->offset = ponew > 0 ? ponew : 0;
+}
+
+static void
roff_term_pre_sp(ROFF_TERM_ARGS)
{
struct roffsu su;