=================================================================== RCS file: /cvs/mandoc/term.c,v retrieving revision 1.216 retrieving revision 1.219 diff -u -p -r1.216 -r1.219 --- mandoc/term.c 2014/01/22 20:58:39 1.216 +++ mandoc/term.c 2014/03/30 21:28:01 1.219 @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.216 2014/01/22 20:58:39 schwarze Exp $ */ +/* $Id: term.c,v 1.219 2014/03/30 21:28:01 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -23,12 +23,12 @@ #include #include -#include #include #include #include #include "mandoc.h" +#include "mandoc_aux.h" #include "out.h" #include "term.h" #include "main.h" @@ -183,6 +183,13 @@ term_flushln(struct termp *p) ASCII_BREAK == p->buf[j])) jhy = j; + /* + * Hyphenation now decided, put back a real + * hyphen such that we get the correct width. + */ + if (ASCII_HYPH == p->buf[j]) + p->buf[j] = '-'; + vend += (*p->width)(p, p->buf[j]); } @@ -248,12 +255,6 @@ term_flushln(struct termp *p) vbl = 0; } - if (ASCII_HYPH == p->buf[i]) { - (*p->letter)(p, '-'); - p->viscol += (*p->width)(p, '-'); - continue; - } - (*p->letter)(p, p->buf[i]); if (8 == p->buf[i]) p->viscol -= (*p->width)(p, p->buf[i-1]); @@ -620,6 +621,36 @@ encode(struct termp *p, const char *word, size_t sz) else p->buf[p->col++] = word[i]; } +} + +void +term_setwidth(struct termp *p, const char *wstr) +{ + struct roffsu su; + size_t width; + int iop; + + if (NULL != wstr) { + switch (*wstr) { + case ('+'): + iop = 1; + wstr++; + break; + case ('-'): + iop = -1; + wstr++; + break; + default: + iop = 0; + break; + } + if ( ! a2roffsu(wstr, &su, SCALE_MAX)) { + wstr = NULL; + iop = 0; + } + } + width = (NULL != wstr) ? term_hspan(p, &su) : 0; + (*p->setwidth)(p, iop, width); } size_t