From ee8f80a2285cf242861f49768d05d2efe5c1688b Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sun, 13 Nov 2011 15:33:41 +0000 Subject: Make the man(7) page footer the same as in groff. --- man_term.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/man_term.c b/man_term.c index 63662337..73178879 100644 --- a/man_term.c +++ b/man_term.c @@ -1,4 +1,4 @@ -/* $Id: man_term.c,v 1.122 2011/11/13 13:15:14 schwarze Exp $ */ +/* $Id: man_term.c,v 1.123 2011/11/13 15:33:41 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2011 Ingo Schwarze @@ -958,6 +958,8 @@ print_man_nodelist(DECL_ARGS) static void print_man_foot(struct termp *p, const void *arg) { + char title[BUFSIZ]; + size_t datelen; const struct man_meta *meta; meta = (const struct man_meta *)arg; @@ -967,28 +969,33 @@ print_man_foot(struct termp *p, const void *arg) term_vspace(p); term_vspace(p); term_vspace(p); + snprintf(title, BUFSIZ, "%s(%s)", meta->title, meta->msec); + datelen = term_strlen(p, meta->date); p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; - p->rmargin = p->maxrmargin - term_strlen(p, meta->date); p->offset = 0; - - /* term_strlen() can return zero. */ - if (p->rmargin == p->maxrmargin) - p->rmargin--; + p->rmargin = (p->maxrmargin - datelen + term_len(p, 1)) / 2; if (meta->source) term_word(p, meta->source); - if (meta->source) - term_word(p, ""); term_flushln(p); p->flags |= TERMP_NOSPACE; p->offset = p->rmargin; - p->rmargin = p->maxrmargin; - p->flags &= ~TERMP_NOBREAK; + p->rmargin = p->maxrmargin - term_strlen(p, title); + if (p->offset + datelen >= p->rmargin) + p->rmargin = p->offset + datelen; term_word(p, meta->date); term_flushln(p); + + p->flags &= ~TERMP_NOBREAK; + p->flags |= TERMP_NOSPACE; + p->offset = p->rmargin; + p->rmargin = p->maxrmargin; + + term_word(p, title); + term_flushln(p); } -- cgit v1.2.3-56-ge451