aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2013-12-23 02:20:09 +0000
committerIngo Schwarze <schwarze@openbsd.org>2013-12-23 02:20:09 +0000
commit34224dec94613f2de8682103514f13b796cbb181 (patch)
tree91136f003da814dc56e7c47018f372a9f5e6378f /mdoc_term.c
parent7763823a09119fdfe1ca1e3baef83ca1b5a39713 (diff)
downloadmandoc-34224dec94613f2de8682103514f13b796cbb181.tar.gz
mandoc-34224dec94613f2de8682103514f13b796cbb181.tar.zst
mandoc-34224dec94613f2de8682103514f13b796cbb181.zip
Implement a long-standing desideratum,
hanging indentation for .Fn in SYNOPSIS mode, exploiting the new trailspace feature by deliberately *NOT* using it.
Diffstat (limited to 'mdoc_term.c')
-rw-r--r--mdoc_term.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index 04ec9a66..7207df39 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.250 2013/12/22 23:34:13 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.251 2013/12/23 02:20:09 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
@@ -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);