version 1.269, 2017/06/12 19:05:47 |
version 1.272, 2017/06/14 18:23:37 |
Line 116 term_flushln(struct termp *p) |
|
Line 116 term_flushln(struct termp *p) |
|
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 */ |
int ntab; /* number of tabs to prepend */ |
int ntab; /* number of tabs to prepend */ |
|
int breakline; /* after this word */ |
|
|
vbl = (p->flags & TERMP_NOPAD) || p->tcol->offset < p->viscol ? |
vbl = (p->flags & TERMP_NOPAD) || p->tcol->offset < p->viscol ? |
0 : p->tcol->offset - p->viscol; |
0 : p->tcol->offset - p->viscol; |
Line 155 term_flushln(struct termp *p) |
|
Line 156 term_flushln(struct termp *p) |
|
*/ |
*/ |
|
|
jhy = 0; |
jhy = 0; |
|
breakline = 0; |
for (j = p->tcol->col; j < p->tcol->lastcol; j++) { |
for (j = p->tcol->col; j < p->tcol->lastcol; j++) { |
|
if (p->tcol->buf[j] == '\n') { |
|
if ((p->flags & TERMP_BRIND) == 0) |
|
breakline = 1; |
|
continue; |
|
} |
if (p->tcol->buf[j] == ' ' || p->tcol->buf[j] == '\t') |
if (p->tcol->buf[j] == ' ' || p->tcol->buf[j] == '\t') |
break; |
break; |
|
|
Line 221 term_flushln(struct termp *p) |
|
Line 228 term_flushln(struct termp *p) |
|
for ( ; p->tcol->col < p->tcol->lastcol; p->tcol->col++) { |
for ( ; p->tcol->col < p->tcol->lastcol; p->tcol->col++) { |
if (vend > bp && jhy > 0 && p->tcol->col > jhy) |
if (vend > bp && jhy > 0 && p->tcol->col > jhy) |
break; |
break; |
|
if (p->tcol->buf[p->tcol->col] == '\n') |
|
continue; |
if (p->tcol->buf[p->tcol->col] == '\t') |
if (p->tcol->buf[p->tcol->col] == '\t') |
break; |
break; |
if (p->tcol->buf[p->tcol->col] == ' ') { |
if (p->tcol->buf[p->tcol->col] == ' ') { |
Line 260 term_flushln(struct termp *p) |
|
Line 269 term_flushln(struct termp *p) |
|
p->tcol->buf[p->tcol->col]); |
p->tcol->buf[p->tcol->col]); |
} |
} |
vis = vend; |
vis = vend; |
|
|
|
if (breakline == 0) |
|
continue; |
|
|
|
/* Explicitly requested output line break. */ |
|
|
|
if (p->flags & TERMP_MULTICOL) |
|
return; |
|
|
|
endline(p); |
|
breakline = 0; |
|
vis = vend = 0; |
|
|
|
/* Re-establish indentation. */ |
|
|
|
vbl = p->tcol->offset; |
|
maxvis = p->tcol->rmargin > vbl ? |
|
p->tcol->rmargin - vbl : 0; |
|
bp = !(p->flags & TERMP_NOBREAK) ? maxvis : |
|
p->maxrmargin > vbl ? p->maxrmargin - vbl : 0; |
} |
} |
|
|
/* |
/* |
Line 487 term_word(struct termp *p, const char *word) |
|
Line 516 term_word(struct termp *p, const char *word) |
|
case ESCAPE_FONTPREV: |
case ESCAPE_FONTPREV: |
term_fontlast(p); |
term_fontlast(p); |
continue; |
continue; |
|
case ESCAPE_BREAK: |
|
bufferc(p, '\n'); |
|
continue; |
case ESCAPE_NOSPACE: |
case ESCAPE_NOSPACE: |
if (p->flags & TERMP_BACKAFTER) |
if (p->flags & TERMP_BACKAFTER) |
p->flags &= ~TERMP_BACKAFTER; |
p->flags &= ~TERMP_BACKAFTER; |
Line 496 term_word(struct termp *p, const char *word) |
|
Line 528 term_word(struct termp *p, const char *word) |
|
case ESCAPE_HORIZ: |
case ESCAPE_HORIZ: |
if (a2roffsu(seq, &su, SCALE_EM) == NULL) |
if (a2roffsu(seq, &su, SCALE_EM) == NULL) |
continue; |
continue; |
uc = term_hspan(p, &su) / 24; |
uc = term_hen(p, &su); |
if (uc > 0) |
if (uc > 0) |
while (uc-- > 0) |
while (uc-- > 0) |
bufferc(p, ASCII_NBRSP); |
bufferc(p, ASCII_NBRSP); |
Line 515 term_word(struct termp *p, const char *word) |
|
Line 547 term_word(struct termp *p, const char *word) |
|
} |
} |
continue; |
continue; |
case ESCAPE_HLINE: |
case ESCAPE_HLINE: |
if ((seq = a2roffsu(seq, &su, SCALE_EM)) == NULL) |
if ((cp = a2roffsu(seq, &su, SCALE_EM)) == NULL) |
continue; |
continue; |
uc = term_hspan(p, &su) / 24; |
uc = term_hen(p, &su); |
if (uc <= 0) { |
if (uc <= 0) { |
if (p->tcol->rmargin <= p->tcol->offset) |
if (p->tcol->rmargin <= p->tcol->offset) |
continue; |
continue; |
lsz = p->tcol->rmargin - p->tcol->offset; |
lsz = p->tcol->rmargin - p->tcol->offset; |
} else |
} else |
lsz = uc; |
lsz = uc; |
if (*seq == '\0') |
if (*cp == seq[-1]) |
uc = -1; |
uc = -1; |
else if (*seq == '\\') { |
else if (*cp == '\\') { |
seq++; |
seq = cp + 1; |
esc = mandoc_escape(&seq, &cp, &sz); |
esc = mandoc_escape(&seq, &cp, &sz); |
switch (esc) { |
switch (esc) { |
case ESCAPE_UNICODE: |
case ESCAPE_UNICODE: |
Line 544 term_word(struct termp *p, const char *word) |
|
Line 576 term_word(struct termp *p, const char *word) |
|
break; |
break; |
} |
} |
} else |
} else |
uc = *seq; |
uc = *cp; |
if (uc < 0x20 || (uc > 0x7E && uc < 0xA0)) |
if (uc < 0x20 || (uc > 0x7E && uc < 0xA0)) |
uc = '_'; |
uc = '_'; |
if (p->enc == TERMENC_ASCII) { |
if (p->enc == TERMENC_ASCII) { |
Line 934 term_vspan(const struct termp *p, const struct roffsu |
|
Line 966 term_vspan(const struct termp *p, const struct roffsu |
|
} |
} |
|
|
/* |
/* |
* Convert a scaling width to basic units, rounding down. |
* Convert a scaling width to basic units, rounding towards 0. |
*/ |
*/ |
int |
int |
term_hspan(const struct termp *p, const struct roffsu *su) |
term_hspan(const struct termp *p, const struct roffsu *su) |
{ |
{ |
|
|
return (*p->hspan)(p, su); |
return (*p->hspan)(p, su); |
|
} |
|
|
|
/* |
|
* Convert a scaling width to basic units, rounding to closest. |
|
*/ |
|
int |
|
term_hen(const struct termp *p, const struct roffsu *su) |
|
{ |
|
int bu; |
|
|
|
if ((bu = (*p->hspan)(p, su)) >= 0) |
|
return (bu + 11) / 24; |
|
else |
|
return -((-bu + 11) / 24); |
} |
} |