From: Ingo Schwarze <schwarze@usta.de>
To: tech@mdocml.bsd.lv
Subject: [WIP] SYNOPSIS indentation
Date: Sat, 26 Jun 2010 15:47:12 +0200 [thread overview]
Message-ID: <20100626134712.GC22002@iris.usta.de> (raw)
Hi,
here is the other patch i hacked up on the plane.
It is still work in progress, there are few bugs in
horizontal spacing still, but it mostly does the job
and certainly shows the spirit.
Again, this is based on OpenBSD-current, and needs to
be rebased on bsd.lv HEAD.
This is best used together with the .Bk patch just sent,
but does not depend on it.
Yours,
Ingo
Index: mdoc_macro.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/mdoc_macro.c,v
retrieving revision 1.46
diff -u -p -r1.46 mdoc_macro.c
--- mdoc_macro.c 6 Jun 2010 20:30:08 -0000 1.46
+++ mdoc_macro.c 26 Jun 2010 13:41:03 -0000
@@ -93,7 +93,7 @@ const struct mdoc_macro __mdoc_macros[MD
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* In */
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Li */
{ blk_full, 0 }, /* Nd */
- { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Nm */
+ { ctx_synopsis, MDOC_CALLABLE | MDOC_PARSED }, /* Nm */
{ blk_part_imp, MDOC_CALLABLE | MDOC_PARSED }, /* Op */
{ obsolete, 0 }, /* Ot */
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Pa */
@@ -422,6 +422,8 @@ rew_dohalt(enum mdoct tok, enum mdoc_typ
break;
case (MDOC_Nd):
/* FALLTHROUGH */
+ case (MDOC_Nm):
+ /* FALLTHROUGH */
case (MDOC_Ss):
assert(MDOC_TAIL != type);
if (type == p->type && tok == p->tok)
@@ -528,11 +530,15 @@ rew_dobreak(enum mdoct tok, const struct
return(MDOC_It == p->tok);
case (MDOC_Nd):
return(MDOC_Nd == p->tok);
+ case (MDOC_Nm):
+ return(MDOC_Nm == p->tok);
case (MDOC_Ss):
return(MDOC_Ss == p->tok);
case (MDOC_Sh):
if (MDOC_Nd == p->tok)
return(1);
+ if (MDOC_Nm == p->tok)
+ return(1);
if (MDOC_Ss == p->tok)
return(1);
return(MDOC_Sh == p->tok);
@@ -1612,7 +1618,9 @@ ctx_synopsis(MACRO_PROT_ARGS)
* up formatting the block scope, then child nodes will inherit
* the formatting. Be careful.
*/
-
+ if (MDOC_Nm == tok)
+ return(blk_full(m, tok, line, ppos, pos, buf));
+ assert(MDOC_Vt == tok);
return(blk_part_imp(m, tok, line, ppos, pos, buf));
}
Index: mdoc_term.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/mdoc_term.c,v
retrieving revision 1.87
diff -u -p -r1.87 mdoc_term.c
--- mdoc_term.c 10 Jun 2010 22:50:10 -0000 1.87
+++ mdoc_term.c 26 Jun 2010 13:41:05 -0000
@@ -82,6 +83,7 @@ static void termp_fo_post(DECL_ARGS);
static void termp_in_post(DECL_ARGS);
static void termp_it_post(DECL_ARGS);
static void termp_lb_post(DECL_ARGS);
+static void termp_nm_post(DECL_ARGS);
static void termp_op_post(DECL_ARGS);
static void termp_pf_post(DECL_ARGS);
static void termp_pq_post(DECL_ARGS);
@@ -166,7 +169,7 @@ static const struct termact termacts[MDO
{ termp_in_pre, termp_in_post }, /* In */
{ termp_li_pre, NULL }, /* Li */
{ termp_nd_pre, NULL }, /* Nd */
- { termp_nm_pre, NULL }, /* Nm */
+ { termp_nm_pre, termp_nm_post }, /* Nm */
{ termp_op_pre, termp_op_post }, /* Op */
{ NULL, NULL }, /* Ot */
{ termp_under_pre, NULL }, /* Pa */
@@ -1053,6 +1056,24 @@ termp_it_post(DECL_ARGS)
static int
termp_nm_pre(DECL_ARGS)
{
+ size_t offset;
+
+ switch (n->type) {
+ case (MDOC_BLOCK):
+ return(1);
+ case (MDOC_HEAD):
+ p->flags |= TERMP_NOBREAK | TERMP_HANG;
+ offset = n->child ? 6 : strlen(m->name)+1;
+ p->rmargin = p->offset + offset;
+ break;
+ case (MDOC_BODY):
+ p->flags |= TERMP_NOLPAD | TERMP_NOSPACE;
+ offset = n->prev->child ? 6 : strlen(m->name)+1;
+ p->offset += offset;
+ return(1);
+ default:
+ break;
+ }
if (NULL == n->child && NULL == m->name)
return(1);
@@ -1062,11 +1083,33 @@ termp_nm_pre(DECL_ARGS)
term_fontpush(p, TERMFONT_BOLD);
if (NULL == n->child)
term_word(p, m->name);
+
return(1);
}
/* ARGSUSED */
+static void
+termp_nm_post(DECL_ARGS)
+{
+
+ switch (n->type) {
+ case (MDOC_HEAD):
+ term_flushln(p);
+ p->flags &= ~(TERMP_NOBREAK | TERMP_HANG);
+ break;
+ case (MDOC_BODY):
+ term_flushln(p);
+ p->flags &= ~TERMP_NOLPAD;
+ break;
+ default:
+ break;
+ }
+ return;
+}
+
+
+/* ARGSUSED */
static int
termp_fl_pre(DECL_ARGS)
{
--
To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv
next reply other threads:[~2010-06-26 13:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-26 13:47 Ingo Schwarze [this message]
2010-06-26 14:01 ` Kristaps Dzonsons
2010-06-30 23:24 ` [PATCH] .Nm indentation in the SYNOPSIS Ingo Schwarze
2010-07-01 9:38 ` Kristaps Dzonsons
2010-07-01 12:59 ` Ingo Schwarze
2010-07-01 13:15 ` Kristaps Dzonsons
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100626134712.GC22002@iris.usta.de \
--to=schwarze@usta.de \
--cc=tech@mdocml.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).