version 1.146, 2014/04/20 16:46:04 |
version 1.149, 2014/06/20 23:02:31 |
|
|
#include <string.h> |
#include <string.h> |
|
|
#include "mandoc.h" |
#include "mandoc.h" |
|
#include "mandoc_aux.h" |
#include "out.h" |
#include "out.h" |
#include "man.h" |
#include "man.h" |
#include "term.h" |
#include "term.h" |
Line 1049 print_man_nodelist(DECL_ARGS) |
|
Line 1050 print_man_nodelist(DECL_ARGS) |
|
static void |
static void |
print_man_foot(struct termp *p, const void *arg) |
print_man_foot(struct termp *p, const void *arg) |
{ |
{ |
char title[BUFSIZ]; |
const struct man_meta *meta; |
size_t datelen; |
char *title; |
const struct man_meta *meta; |
size_t datelen; |
|
|
meta = (const struct man_meta *)arg; |
meta = (const struct man_meta *)arg; |
assert(meta->title); |
assert(meta->title); |
Line 1060 print_man_foot(struct termp *p, const void *arg) |
|
Line 1061 print_man_foot(struct termp *p, const void *arg) |
|
|
|
term_fontrepl(p, TERMFONT_NONE); |
term_fontrepl(p, TERMFONT_NONE); |
|
|
term_vspace(p); |
if (meta->hasbody) |
|
term_vspace(p); |
|
|
/* |
/* |
* Temporary, undocumented option to imitate mdoc(7) output. |
* Temporary, undocumented option to imitate mdoc(7) output. |
Line 1069 print_man_foot(struct termp *p, const void *arg) |
|
Line 1071 print_man_foot(struct termp *p, const void *arg) |
|
*/ |
*/ |
|
|
if ( ! p->mdocstyle) { |
if ( ! p->mdocstyle) { |
term_vspace(p); |
if (meta->hasbody) { |
term_vspace(p); |
term_vspace(p); |
snprintf(title, BUFSIZ, "%s(%s)", meta->title, meta->msec); |
term_vspace(p); |
|
} |
|
mandoc_asprintf(&title, "%s(%s)", |
|
meta->title, meta->msec); |
} else if (meta->source) { |
} else if (meta->source) { |
strlcpy(title, meta->source, BUFSIZ); |
title = mandoc_strdup(meta->source); |
} else { |
} else { |
title[0] = '\0'; |
title = mandoc_strdup(""); |
} |
} |
datelen = term_strlen(p, meta->date); |
datelen = term_strlen(p, meta->date); |
|
|
Line 1111 print_man_foot(struct termp *p, const void *arg) |
|
Line 1116 print_man_foot(struct termp *p, const void *arg) |
|
|
|
term_word(p, title); |
term_word(p, title); |
term_flushln(p); |
term_flushln(p); |
|
free(title); |
} |
} |
|
|
static void |
static void |
print_man_head(struct termp *p, const void *arg) |
print_man_head(struct termp *p, const void *arg) |
{ |
{ |
char buf[BUFSIZ], title[BUFSIZ]; |
const struct man_meta *meta; |
size_t buflen, titlen; |
const char *volume; |
const struct man_meta *meta; |
char *title; |
|
size_t vollen, titlen; |
|
|
meta = (const struct man_meta *)arg; |
meta = (const struct man_meta *)arg; |
assert(meta->title); |
assert(meta->title); |
assert(meta->msec); |
assert(meta->msec); |
|
|
if (meta->vol) |
volume = NULL == meta->vol ? "" : meta->vol; |
strlcpy(buf, meta->vol, BUFSIZ); |
vollen = term_strlen(p, volume); |
else |
|
buf[0] = '\0'; |
|
buflen = term_strlen(p, buf); |
|
|
|
/* Top left corner: manual title and section. */ |
/* Top left corner: manual title and section. */ |
|
|
snprintf(title, BUFSIZ, "%s(%s)", meta->title, meta->msec); |
mandoc_asprintf(&title, "%s(%s)", meta->title, meta->msec); |
titlen = term_strlen(p, title); |
titlen = term_strlen(p, title); |
|
|
p->flags |= TERMP_NOBREAK | TERMP_NOSPACE; |
p->flags |= TERMP_NOBREAK | TERMP_NOSPACE; |
p->trailspace = 1; |
p->trailspace = 1; |
p->offset = 0; |
p->offset = 0; |
p->rmargin = 2 * (titlen+1) + buflen < p->maxrmargin ? |
p->rmargin = 2 * (titlen+1) + vollen < p->maxrmargin ? |
(p->maxrmargin - |
(p->maxrmargin - vollen + term_len(p, 1)) / 2 : |
term_strlen(p, buf) + term_len(p, 1)) / 2 : |
p->maxrmargin - vollen; |
p->maxrmargin - buflen; |
|
|
|
term_word(p, title); |
term_word(p, title); |
term_flushln(p); |
term_flushln(p); |
Line 1150 print_man_head(struct termp *p, const void *arg) |
|
Line 1153 print_man_head(struct termp *p, const void *arg) |
|
|
|
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
p->offset = p->rmargin; |
p->offset = p->rmargin; |
p->rmargin = p->offset + buflen + titlen < p->maxrmargin ? |
p->rmargin = p->offset + vollen + titlen < p->maxrmargin ? |
p->maxrmargin - titlen : p->maxrmargin; |
p->maxrmargin - titlen : p->maxrmargin; |
|
|
term_word(p, buf); |
term_word(p, volume); |
term_flushln(p); |
term_flushln(p); |
|
|
/* Top right corner: title and section, again. */ |
/* Top right corner: title and section, again. */ |
Line 1183 print_man_head(struct termp *p, const void *arg) |
|
Line 1186 print_man_head(struct termp *p, const void *arg) |
|
term_vspace(p); |
term_vspace(p); |
term_vspace(p); |
term_vspace(p); |
} |
} |
|
free(title); |
} |
} |