version 1.255, 2015/10/23 14:50:58 |
version 1.260, 2017/05/07 17:31:45 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
Line 141 term_flushln(struct termp *p) |
|
Line 141 term_flushln(struct termp *p) |
|
* subsequent tabs into a single huge set of spaces. |
* subsequent tabs into a single huge set of spaces. |
*/ |
*/ |
ntab = 0; |
ntab = 0; |
while (i < p->col && '\t' == p->buf[i]) { |
while (i < p->col && p->buf[i] == '\t') { |
vend = (vis / p->tabwidth + 1) * p->tabwidth; |
vend = term_tab_next(vis); |
vbl += vend - vis; |
vbl += vend - vis; |
vis = vend; |
vis = vend; |
ntab++; |
ntab++; |
Line 160 term_flushln(struct termp *p) |
|
Line 160 term_flushln(struct termp *p) |
|
if (' ' == p->buf[j] || '\t' == p->buf[j]) |
if (' ' == p->buf[j] || '\t' == p->buf[j]) |
break; |
break; |
|
|
/* Back over the the last printed character. */ |
/* Back over the last printed character. */ |
if (8 == p->buf[j]) { |
if (8 == p->buf[j]) { |
assert(j); |
assert(j); |
vend -= (*p->width)(p, p->buf[j - 1]); |
vend -= (*p->width)(p, p->buf[j - 1]); |
Line 192 term_flushln(struct termp *p) |
|
Line 192 term_flushln(struct termp *p) |
|
vend -= vis; |
vend -= vis; |
(*p->endline)(p); |
(*p->endline)(p); |
p->viscol = 0; |
p->viscol = 0; |
if (TERMP_BRIND & p->flags) { |
|
vbl = p->rmargin; |
|
vend += p->rmargin; |
|
vend -= p->offset; |
|
} else |
|
vbl = p->offset; |
|
|
|
/* use pending tabs on the new line */ |
/* Use pending tabs on the new line. */ |
|
|
if (0 < ntab) |
vbl = 0; |
vbl += ntab * p->tabwidth; |
while (ntab--) |
|
vbl = term_tab_next(vbl); |
|
|
|
/* Re-establish indentation. */ |
|
|
|
if (p->flags & TERMP_BRIND) { |
|
vbl += p->rmargin; |
|
vend += p->rmargin - p->offset; |
|
} else |
|
vbl += p->offset; |
|
|
/* |
/* |
* Remove the p->overstep width. |
* Remove the p->overstep width. |
* Again, if p->overstep is negative, |
* Again, if p->overstep is negative, |
Line 365 term_fontpush(struct termp *p, enum termfont f) |
|
Line 368 term_fontpush(struct termp *p, enum termfont f) |
|
if (++p->fonti == p->fontsz) { |
if (++p->fonti == p->fontsz) { |
p->fontsz += 8; |
p->fontsz += 8; |
p->fontq = mandoc_reallocarray(p->fontq, |
p->fontq = mandoc_reallocarray(p->fontq, |
p->fontsz, sizeof(enum termfont *)); |
p->fontsz, sizeof(*p->fontq)); |
} |
} |
p->fontq[p->fonti] = f; |
p->fontq[p->fonti] = f; |
} |
} |
Line 504 term_word(struct termp *p, const char *word) |
|
Line 507 term_word(struct termp *p, const char *word) |
|
} |
} |
} |
} |
/* Trim trailing backspace/blank pair. */ |
/* Trim trailing backspace/blank pair. */ |
if (p->col > 2 && p->buf[p->col - 1] == ' ') |
if (p->col > 2 && |
|
(p->buf[p->col - 1] == ' ' || |
|
p->buf[p->col - 1] == '\t')) |
p->col -= 2; |
p->col -= 2; |
continue; |
continue; |
default: |
default: |
Line 568 encode1(struct termp *p, int c) |
|
Line 573 encode1(struct termp *p, int c) |
|
p->fontq[p->fonti] : TERMFONT_NONE; |
p->fontq[p->fonti] : TERMFONT_NONE; |
|
|
if (p->flags & TERMP_BACKBEFORE) { |
if (p->flags & TERMP_BACKBEFORE) { |
if (p->buf[p->col - 1] == ' ') |
if (p->buf[p->col - 1] == ' ' || p->buf[p->col - 1] == '\t') |
p->col--; |
p->col--; |
else |
else |
p->buf[p->col++] = 8; |
p->buf[p->col++] = 8; |
Line 604 encode(struct termp *p, const char *word, size_t sz) |
|
Line 609 encode(struct termp *p, const char *word, size_t sz) |
|
if (ASCII_HYPH == word[i] || |
if (ASCII_HYPH == word[i] || |
isgraph((unsigned char)word[i])) |
isgraph((unsigned char)word[i])) |
encode1(p, word[i]); |
encode1(p, word[i]); |
else |
else { |
p->buf[p->col++] = word[i]; |
p->buf[p->col++] = word[i]; |
|
|
|
/* |
|
* Postpone the effect of \z while handling |
|
* an overstrike sequence from ascii_uc2str(). |
|
*/ |
|
|
|
if (word[i] == '\b' && |
|
(p->flags & TERMP_BACKBEFORE)) { |
|
p->flags &= ~TERMP_BACKBEFORE; |
|
p->flags |= TERMP_BACKAFTER; |
|
} |
|
} |
} |
} |
} |
} |
|
|