version 1.233, 2014/10/29 00:17:43 |
version 1.237, 2014/12/02 10:08:06 |
Line 100 term_flushln(struct termp *p) |
|
Line 100 term_flushln(struct termp *p) |
|
size_t j; /* temporary loop index for p->buf */ |
size_t j; /* temporary loop index for p->buf */ |
size_t jhy; /* last hyph before overflow w/r/t j */ |
size_t jhy; /* last hyph before overflow w/r/t j */ |
size_t maxvis; /* output position of visible boundary */ |
size_t maxvis; /* output position of visible boundary */ |
size_t mmax; /* used in calculating bp */ |
size_t rmargin; /* the rightmost of the two margins */ |
|
|
/* |
/* |
* First, establish the maximum columns of "visible" content. |
* First, establish the maximum columns of "visible" content. |
Line 113 term_flushln(struct termp *p) |
|
Line 113 term_flushln(struct termp *p) |
|
* is negative, it gets sign extended. Subtracting that |
* is negative, it gets sign extended. Subtracting that |
* very large size_t effectively adds a small number to dv. |
* very large size_t effectively adds a small number to dv. |
*/ |
*/ |
assert (p->rmargin >= p->offset); |
rmargin = p->rmargin > p->offset ? p->rmargin : p->offset; |
dv = p->rmargin - p->offset; |
dv = p->rmargin - p->offset; |
maxvis = (int)dv > p->overstep ? dv - (size_t)p->overstep : 0; |
maxvis = (int)dv > p->overstep ? dv - (size_t)p->overstep : 0; |
dv = p->maxrmargin - p->offset; |
|
mmax = (int)dv > p->overstep ? dv - (size_t)p->overstep : 0; |
|
|
|
bp = TERMP_NOBREAK & p->flags ? mmax : maxvis; |
if (p->flags & TERMP_NOBREAK) { |
|
dv = p->maxrmargin > p->offset ? |
|
p->maxrmargin - p->offset : 0; |
|
bp = (int)dv > p->overstep ? |
|
dv - (size_t)p->overstep : 0; |
|
} else |
|
bp = maxvis; |
|
|
/* |
/* |
* Calculate the required amount of padding. |
* Calculate the required amount of padding. |
Line 188 term_flushln(struct termp *p) |
|
Line 192 term_flushln(struct termp *p) |
|
(*p->endline)(p); |
(*p->endline)(p); |
p->viscol = 0; |
p->viscol = 0; |
if (TERMP_BRIND & p->flags) { |
if (TERMP_BRIND & p->flags) { |
vbl = p->rmargin; |
vbl = rmargin; |
vend += p->rmargin - p->offset; |
vend += rmargin - p->offset; |
} else |
} else |
vbl = p->offset; |
vbl = p->offset; |
|
|
Line 254 term_flushln(struct termp *p) |
|
Line 258 term_flushln(struct termp *p) |
|
* If there was trailing white space, it was not printed; |
* If there was trailing white space, it was not printed; |
* so reset the cursor position accordingly. |
* so reset the cursor position accordingly. |
*/ |
*/ |
if (vis) |
if (vis > vbl) |
vis -= vbl; |
vis -= vbl; |
|
else |
|
vis = 0; |
|
|
p->col = 0; |
p->col = 0; |
p->overstep = 0; |
p->overstep = 0; |
Line 411 term_word(struct termp *p, const char *word) |
|
Line 417 term_word(struct termp *p, const char *word) |
|
else |
else |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
|
|
p->flags &= ~TERMP_SENTENCE; |
p->flags &= ~(TERMP_SENTENCE | TERMP_NONEWLINE); |
|
|
while ('\0' != *word) { |
while ('\0' != *word) { |
if ('\\' != *word) { |
if ('\\' != *word) { |
Line 481 term_word(struct termp *p, const char *word) |
|
Line 487 term_word(struct termp *p, const char *word) |
|
if (TERMP_SKIPCHAR & p->flags) |
if (TERMP_SKIPCHAR & p->flags) |
p->flags &= ~TERMP_SKIPCHAR; |
p->flags &= ~TERMP_SKIPCHAR; |
else if ('\0' == *word) |
else if ('\0' == *word) |
p->flags |= TERMP_NOSPACE; |
p->flags |= (TERMP_NOSPACE | TERMP_NONEWLINE); |
continue; |
continue; |
case ESCAPE_SKIPCHAR: |
case ESCAPE_SKIPCHAR: |
p->flags |= TERMP_SKIPCHAR; |
p->flags |= TERMP_SKIPCHAR; |
Line 684 term_strlen(const struct termp *p, const char *cp) |
|
Line 690 term_strlen(const struct termp *p, const char *cp) |
|
|
|
switch (esc) { |
switch (esc) { |
case ESCAPE_UNICODE: |
case ESCAPE_UNICODE: |
uc = mchars_num2uc(seq + 1, sz - 1); |
uc = mchars_num2uc(seq + 1, ssz - 1); |
break; |
break; |
case ESCAPE_NUMBERED: |
case ESCAPE_NUMBERED: |
uc = mchars_num2char(seq, ssz); |
uc = mchars_num2char(seq, ssz); |