version 1.203, 2012/05/31 22:29:13 |
version 1.206, 2012/11/16 17:16:55 |
|
|
term_flushln(struct termp *p) |
term_flushln(struct termp *p) |
{ |
{ |
int i; /* current input position in p->buf */ |
int i; /* current input position in p->buf */ |
|
int ntab; /* number of tabs to prepend */ |
size_t vis; /* current visual position on output */ |
size_t vis; /* current visual position on output */ |
size_t vbl; /* number of blanks to prepend to output */ |
size_t vbl; /* number of blanks to prepend to output */ |
size_t vend; /* end of word visual position on output */ |
size_t vend; /* end of word visual position on output */ |
Line 144 term_flushln(struct termp *p) |
|
Line 145 term_flushln(struct termp *p) |
|
* Handle literal tab characters: collapse all |
* Handle literal tab characters: collapse all |
* subsequent tabs into a single huge set of spaces. |
* subsequent tabs into a single huge set of spaces. |
*/ |
*/ |
|
ntab = 0; |
while (i < p->col && '\t' == p->buf[i]) { |
while (i < p->col && '\t' == p->buf[i]) { |
vend = (vis / p->tabwidth + 1) * p->tabwidth; |
vend = (vis / p->tabwidth + 1) * p->tabwidth; |
vbl += vend - vis; |
vbl += vend - vis; |
vis = vend; |
vis = vend; |
|
ntab++; |
i++; |
i++; |
} |
} |
|
|
Line 192 term_flushln(struct termp *p) |
|
Line 195 term_flushln(struct termp *p) |
|
} else |
} else |
vbl = p->offset; |
vbl = p->offset; |
|
|
|
/* use pending tabs on the new line */ |
|
|
|
if (0 < ntab) |
|
vbl += ntab * p->tabwidth; |
|
|
/* Remove the p->overstep width. */ |
/* Remove the p->overstep width. */ |
|
|
bp += (size_t)p->overstep; |
bp += (size_t)p->overstep; |
Line 265 term_flushln(struct termp *p) |
|
Line 273 term_flushln(struct termp *p) |
|
p->overstep = (int)(vis - maxvis + (*p->width)(p, ' ')); |
p->overstep = (int)(vis - maxvis + (*p->width)(p, ' ')); |
|
|
/* |
/* |
* Behave exactly the same way as groff: |
|
* If we have overstepped the margin, temporarily move |
* If we have overstepped the margin, temporarily move |
* it to the right and flag the rest of the line to be |
* it to the right and flag the rest of the line to be |
* shorter. |
* shorter. |
* If we landed right at the margin, be happy. |
|
* If we are one step before the margin, temporarily |
|
* move it one step LEFT and flag the rest of the line |
|
* to be longer. |
|
*/ |
*/ |
if (p->overstep < -1) |
if (p->overstep < 0) |
p->overstep = 0; |
p->overstep = 0; |
return; |
return; |
|
|
|
|
term_fontpopq(struct termp *p, const void *key) |
term_fontpopq(struct termp *p, const void *key) |
{ |
{ |
|
|
while (p->fonti >= 0 && key != &p->fontq[p->fonti]) |
while (p->fonti >= 0 && key < (void *)(p->fontq + p->fonti)) |
p->fonti--; |
p->fonti--; |
assert(p->fonti >= 0); |
assert(p->fonti >= 0); |
} |
} |