tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
* new man(7) footer formats
@ 2011-11-01 18:07 Ingo Schwarze
  0 siblings, 0 replies; only message in thread
From: Ingo Schwarze @ 2011-11-01 18:07 UTC (permalink / raw)
  To: tech

Hi,

let's replace the man(7) footer format we have now, which is neither
compatible with groff nor similar to the mdoc(7) footer format,
by two new footer formats, controlled by the new termp mdocstyle
flag.  Also, suppress the two additional blank lines after the
header line and before the footer line in mdocstyle.

To be applied on top of the last diff, "mdoc(7) output style for man(7)".

OK?
  Ingo


--- man_term.c.orig
+++ man_term.c
@@ -956,6 +956,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;
@@ -963,30 +965,41 @@ print_man_foot(struct termp *p, const void *arg)
 	term_fontrepl(p, TERMFONT_NONE);
 
 	term_vspace(p);
-	term_vspace(p);
-	term_vspace(p);
+	if ( ! p->mdocstyle) {
+		term_vspace(p);
+		term_vspace(p);
+		snprintf(title, BUFSIZ, "%s(%s)", meta->title, meta->msec);
+	} else if (meta->source) {
+		strlcpy(title, meta->source, BUFSIZ);
+	} else {
+		title[0] = '\0';
+	}
+	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);
 }
 
 
@@ -1054,6 +1067,8 @@ print_man_head(struct termp *p, const void *arg)
 	 */
 
 	term_vspace(p);
-	term_vspace(p);
-	term_vspace(p);
+	if ( ! p->mdocstyle) {
+		term_vspace(p);
+		term_vspace(p);
+	}
 }
--
 To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-11-01 18:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-01 18:07 new man(7) footer formats Ingo Schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).