diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2017-06-01 19:05:37 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2017-06-01 19:05:37 +0000 |
commit | 41ca712e6e6b6ad1b09c0abcbe87b01ea039b2be (patch) | |
tree | ec9d7acf6d3d88ba8497512fa6e9deea45745d4b /term.c | |
parent | 5325cd99ac197268bd26af0ee01d0539cb78cb61 (diff) | |
download | mandoc-41ca712e6e6b6ad1b09c0abcbe87b01ea039b2be.tar.gz mandoc-41ca712e6e6b6ad1b09c0abcbe87b01ea039b2be.tar.zst mandoc-41ca712e6e6b6ad1b09c0abcbe87b01ea039b2be.zip |
Minimal implementation of the \h (horizontal motion) escape sequence.
Good enough to cope with the average DocBook insanity.
Diffstat (limited to 'term.c')
-rw-r--r-- | term.c | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.260 2017/05/07 17:31:45 schwarze Exp $ */ +/* $Id: term.c,v 1.261 2017/06/01 19:05:37 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org> @@ -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; @@ -488,6 +489,27 @@ term_word(struct termp *p, const char *word) 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; continue; |