From 843cccd2fcf4de8a13a16071c949374ee597d16e Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Mon, 23 Dec 2013 02:20:09 +0000 Subject: Implement a long-standing desideratum, hanging indentation for .Fn in SYNOPSIS mode, exploiting the new trailspace feature by deliberately *NOT* using it. --- mdoc_term.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'mdoc_term.c') diff --git a/mdoc_term.c b/mdoc_term.c index e10ded9b..244be965 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -1538,6 +1538,7 @@ termp_ft_pre(DECL_ARGS) static int termp_fn_pre(DECL_ARGS) { + size_t width, rmargin = 0; int pretty; pretty = MDOC_SYNPRETTY & n->flags; @@ -1547,11 +1548,25 @@ termp_fn_pre(DECL_ARGS) if (NULL == (n = n->child)) return(0); + if (pretty) { + width = term_len(p, 4); + rmargin = p->rmargin; + p->rmargin = p->offset + width; + p->flags |= TERMP_NOBREAK | TERMP_HANG; + } + assert(MDOC_TEXT == n->type); term_fontpush(p, TERMFONT_BOLD); term_word(p, n->string); term_fontpop(p); + if (pretty) { + term_flushln(p); + p->flags &= ~(TERMP_NOBREAK | TERMP_HANG); + p->offset = p->rmargin; + p->rmargin = rmargin; + } + p->flags |= TERMP_NOSPACE; term_word(p, "("); p->flags |= TERMP_NOSPACE; @@ -1574,6 +1589,7 @@ termp_fn_pre(DECL_ARGS) if (pretty) { p->flags |= TERMP_NOSPACE; term_word(p, ";"); + term_flushln(p); } return(0); -- cgit