diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-06-28 23:26:09 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-06-28 23:26:09 +0000 |
commit | fa25d6bcf8d83e3ef6c401e70a10d5e73010dac8 (patch) | |
tree | 7c07585f2e85fc7eb81283a19e2a395445fd1435 /term.c | |
parent | a8118e85fefd1944161b9393a20595f4b1325640 (diff) | |
download | mandoc-fa25d6bcf8d83e3ef6c401e70a10d5e73010dac8.tar.gz |
Clean-up of variable-width glyph support. Adds no new code; only
restructured to make a bit more readable. Also removed an unused entry
in the PS engine structure.
Diffstat (limited to 'term.c')
-rw-r--r-- | term.c | 33 |
1 files changed, 18 insertions, 15 deletions
@@ -161,21 +161,17 @@ term_flushln(struct termp *p) */ vbl = p->flags & TERMP_NOLPAD ? 0 : p->offset; - /* - * FIXME: if bp is zero, we still output the first word before - * breaking the line. - */ - vis = vend = i = 0; - while (i < (int)p->col) { + while (i < (int)p->col) { /* - * Handle literal tab characters. + * Handle literal tab characters: collapse all + * subsequent tabs into a single huge set of spaces. */ for (j = i; j < (int)p->col; j++) { if ('\t' != p->buf[j]) break; - vend = (vis/p->tabwidth+1)*p->tabwidth; + vend = (vis / p->tabwidth + 1) * p->tabwidth; vbl += vend - vis; vis = vend; } @@ -191,15 +187,21 @@ term_flushln(struct termp *p) for (jhy = 0; j < (int)p->col; j++) { if ((j && ' ' == p->buf[j]) || '\t' == p->buf[j]) break; - if (8 != p->buf[j]) { - if (vend > vis && vend < bp && - ASCII_HYPH == p->buf[j]) - jhy = j; - vend += (*p->width)(p, p->buf[j]); - } else { + + /* Back over the the last printed character. */ + if (8 == p->buf[j]) { assert(j); vend -= (*p->width)(p, p->buf[j - 1]); + continue; } + + /* Regular word. */ + /* Break at the hyphen point if we overrun. */ + if (vend > vis && vend < bp && + ASCII_HYPH == p->buf[j]) + jhy = j; + + vend += (*p->width)(p, p->buf[j]); } /* @@ -308,7 +310,8 @@ term_flushln(struct termp *p) /* Right-pad. */ if (maxvis > vis + /* LINTED */ - ((TERMP_TWOSPACE & p->flags) ? (*p->width)(p, ' ') : 0)) { + ((TERMP_TWOSPACE & p->flags) ? + (*p->width)(p, ' ') : 0)) { p->viscol += maxvis - vis; (*p->advance)(p, maxvis - vis); vis += (maxvis - vis); |