version 1.234, 2011/09/19 22:36:16 |
version 1.235, 2011/09/20 09:02:23 |
|
|
print_mdoc_head(struct termp *p, const void *arg) |
print_mdoc_head(struct termp *p, const void *arg) |
{ |
{ |
char buf[BUFSIZ], title[BUFSIZ]; |
char buf[BUFSIZ], title[BUFSIZ]; |
|
size_t buflen, titlen; |
const struct mdoc_meta *m; |
const struct mdoc_meta *m; |
|
|
m = (const struct mdoc_meta *)arg; |
m = (const struct mdoc_meta *)arg; |
|
|
p->rmargin = p->maxrmargin; |
|
p->offset = 0; |
|
|
|
/* |
/* |
* The header is strange. It has three components, which are |
* The header is strange. It has three components, which are |
* really two with the first duplicated. It goes like this: |
* really two with the first duplicated. It goes like this: |
Line 478 print_mdoc_head(struct termp *p, const void *arg) |
|
Line 476 print_mdoc_head(struct termp *p, const void *arg) |
|
* switches on the manual section. |
* switches on the manual section. |
*/ |
*/ |
|
|
|
p->offset = 0; |
|
p->rmargin = p->maxrmargin; |
|
|
assert(m->vol); |
assert(m->vol); |
strlcpy(buf, m->vol, BUFSIZ); |
strlcpy(buf, m->vol, BUFSIZ); |
|
buflen = term_strlen(p, buf); |
|
|
if (m->arch) { |
if (m->arch) { |
strlcat(buf, " (", BUFSIZ); |
strlcat(buf, " (", BUFSIZ); |
Line 488 print_mdoc_head(struct termp *p, const void *arg) |
|
Line 490 print_mdoc_head(struct termp *p, const void *arg) |
|
} |
} |
|
|
snprintf(title, BUFSIZ, "%s(%s)", m->title, m->msec); |
snprintf(title, BUFSIZ, "%s(%s)", m->title, m->msec); |
|
titlen = term_strlen(p, title); |
|
|
p->offset = 0; |
|
p->rmargin = (p->maxrmargin - |
|
term_strlen(p, buf) + term_len(p, 1)) / 2; |
|
p->flags |= TERMP_NOBREAK | TERMP_NOSPACE; |
p->flags |= TERMP_NOBREAK | TERMP_NOSPACE; |
|
p->offset = 0; |
|
p->rmargin = 2 * (titlen+1) + buflen < p->maxrmargin ? |
|
(p->maxrmargin - |
|
term_strlen(p, buf) + term_len(p, 1)) / 2 : |
|
p->maxrmargin - buflen; |
|
|
term_word(p, title); |
term_word(p, title); |
term_flushln(p); |
term_flushln(p); |
|
|
p->offset = p->rmargin; |
|
p->rmargin = p->maxrmargin - term_strlen(p, title); |
|
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
|
p->offset = p->rmargin; |
|
p->rmargin = p->offset + buflen + titlen < p->maxrmargin ? |
|
p->maxrmargin - titlen : p->maxrmargin; |
|
|
term_word(p, buf); |
term_word(p, buf); |
term_flushln(p); |
term_flushln(p); |
|
|
p->offset = p->rmargin; |
|
p->rmargin = p->maxrmargin; |
|
p->flags &= ~TERMP_NOBREAK; |
p->flags &= ~TERMP_NOBREAK; |
p->flags |= TERMP_NOSPACE; |
if (p->rmargin + titlen <= p->maxrmargin) { |
|
p->flags |= TERMP_NOSPACE; |
|
p->offset = p->rmargin; |
|
p->rmargin = p->maxrmargin; |
|
term_word(p, title); |
|
term_flushln(p); |
|
} |
|
|
term_word(p, title); |
p->flags &= ~TERMP_NOSPACE; |
term_flushln(p); |
|
|
|
p->offset = 0; |
p->offset = 0; |
p->rmargin = p->maxrmargin; |
p->rmargin = p->maxrmargin; |
p->flags &= ~TERMP_NOSPACE; |
|
} |
} |
|
|
|
|