From 41ca712e6e6b6ad1b09c0abcbe87b01ea039b2be Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Thu, 1 Jun 2017 19:05:37 +0000 Subject: Minimal implementation of the \h (horizontal motion) escape sequence. Good enough to cope with the average DocBook insanity. --- term.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'term.c') diff --git a/term.c b/term.c index f2553d89..266c49e7 100644 --- a/term.c +++ b/term.c @@ -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 * Copyright (c) 2010-2017 Ingo Schwarze @@ -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; -- cgit v1.2.3