aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/term.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-06-28 23:26:09 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-06-28 23:26:09 +0000
commit1333797c489e45a9ce20753440cdba7ebadf299d (patch)
treefc0642696dec7ae778a6d97f87d3138e1313de36 /term.c
parent7e1ed558d5e8927b3247d0f3d61fc05fb041fe09 (diff)
downloadmandoc-1333797c489e45a9ce20753440cdba7ebadf299d.tar.gz
mandoc-1333797c489e45a9ce20753440cdba7ebadf299d.tar.zst
mandoc-1333797c489e45a9ce20753440cdba7ebadf299d.zip
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.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/term.c b/term.c
index 31e91e92..02dc9732 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.153 2010/06/28 22:46:21 kristaps Exp $ */
+/* $Id: term.c,v 1.154 2010/06/28 23:26:09 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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);