* mdocml: Minimal implementation of the \h (horizontal motion) escape
@ 2017-06-01 19:05 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2017-06-01 19:05 UTC (permalink / raw)
To: source
Log Message:
-----------
Minimal implementation of the \h (horizontal motion) escape sequence.
Good enough to cope with the average DocBook insanity.
Modified Files:
--------------
mdocml:
mandoc.c
mandoc.h
mdoc_term.c
roff.7
term.c
mdocml/regress/roff/esc:
h.in
Revision Data
-------------
Index: mandoc.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandoc.c,v
retrieving revision 1.98
retrieving revision 1.99
diff -Lmandoc.c -Lmandoc.c -u -p -r1.98 -r1.99
--- mandoc.c
+++ mandoc.c
@@ -175,7 +175,7 @@ mandoc_escape(const char **end, const ch
++*end;
return ESCAPE_ERROR;
}
- gly = ESCAPE_IGNORE;
+ gly = (*start)[-1] == 'h' ? ESCAPE_HORIZ : ESCAPE_IGNORE;
term = **start;
*start = ++*end;
break;
Index: term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/term.c,v
retrieving revision 1.260
retrieving revision 1.261
diff -Lterm.c -Lterm.c -u -p -r1.260 -r1.261
--- term.c
+++ term.c
@@ -400,6 +400,7 @@ term_fontpop(struct termp *p)
void
term_word(struct termp *p, const char *word)
{
+ struct roffsu su;
const char nbrsp[2] = { ASCII_NBRSP, 0 };
const char *seq, *cp;
int sz, uc;
@@ -487,6 +488,27 @@ term_word(struct termp *p, const char *w
p->flags &= ~TERMP_BACKAFTER;
else if (*word == '\0')
p->flags |= (TERMP_NOSPACE | TERMP_NONEWLINE);
+ continue;
+ case ESCAPE_HORIZ:
+ if (a2roffsu(seq, &su, SCALE_EM) == 0)
+ continue;
+ uc = term_hspan(p, &su) / 24;
+ if (uc > 0)
+ while (uc-- > 0)
+ bufferc(p, ASCII_NBRSP);
+ else if (p->col > (size_t)(-uc))
+ p->col += uc;
+ else {
+ uc += p->col;
+ p->col = 0;
+ if (p->offset > (size_t)(-uc)) {
+ p->ti += uc;
+ p->offset += uc;
+ } else {
+ p->ti -= p->offset;
+ p->offset = 0;
+ }
+ }
continue;
case ESCAPE_SKIPCHAR:
p->flags |= TERMP_BACKAFTER;
Index: roff.7
===================================================================
RCS file: /home/cvs/mdocml/mdocml/roff.7,v
retrieving revision 1.80
retrieving revision 1.81
diff -Lroff.7 -Lroff.7 -u -p -r1.80 -r1.81
--- roff.7
+++ roff.7
@@ -1925,9 +1925,10 @@ 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 number Ns \(aq
-Horizontal motion; ignored by
-.Xr mandoc 1 .
+.Ss \eh\(aq Ns Ar width Ns \(aq
+Horizontal motion relative to the current position.
+The default scaling unit is
+.Cm m .
.Ss \ek[ Ns Ar name ]
Mark horizontal input place in register; ignored by
.Xr mandoc 1 .
Index: mandoc.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandoc.h,v
retrieving revision 1.219
retrieving revision 1.220
diff -Lmandoc.h -Lmandoc.h -u -p -r1.219 -r1.220
--- mandoc.h
+++ mandoc.h
@@ -411,6 +411,7 @@ enum mandoc_esc {
ESCAPE_NUMBERED, /* a numbered glyph */
ESCAPE_UNICODE, /* a unicode codepoint */
ESCAPE_NOSPACE, /* suppress space if the last on a line */
+ ESCAPE_HORIZ, /* horizontal movement */
ESCAPE_SKIPCHAR, /* skip the next character */
ESCAPE_OVERSTRIKE /* overstrike all chars in the argument */
};
Index: mdoc_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_term.c,v
retrieving revision 1.358
retrieving revision 1.359
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.358 -r1.359
--- mdoc_term.c
+++ mdoc_term.c
@@ -407,7 +407,8 @@ print_mdoc_node(DECL_ARGS)
if (NODE_EOS & n->flags)
p->flags |= TERMP_SENTENCE;
- p->offset = offset;
+ if (n->type != ROFFT_TEXT)
+ p->offset = offset;
p->rmargin = rmargin;
}
Index: h.in
===================================================================
RCS file: /home/cvs/mdocml/mdocml/regress/roff/esc/h.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/roff/esc/h.in -Lregress/roff/esc/h.in -u -p -r1.1 -r1.2
--- regress/roff/esc/h.in
+++ regress/roff/esc/h.in
@@ -7,11 +7,11 @@
.Sh DESCRIPTION
simple: >\h'0'<
.br
-escape only: >\h'\w'\&''<
+escape only: >\h'\w'\&'M'<
.br
escape at the end: >\h'0+\w'\&''<
.br
-escape at the beginning: >\h'\w'\&'+0'<
+escape at the beginning: >\h'\w'\&'M+0'<
.br
escape in the middle: >\h'0+\w'\&'+0'<
.br
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-06-01 19:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-01 19:05 mdocml: Minimal implementation of the \h (horizontal motion) escape schwarze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).