From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp1.rz.uni-karlsruhe.de (Debian-exim@smtp1.rz.uni-karlsruhe.de [129.13.185.217]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id o5QDlF8o016796 for ; Sat, 26 Jun 2010 09:47:15 -0400 (EDT) Received: from hekate.usta.de (asta-nat.asta.uni-karlsruhe.de [172.22.63.82]) by smtp1.rz.uni-karlsruhe.de with esmtp (Exim 4.63 #1) id 1OSViy-0002Eg-KM; Sat, 26 Jun 2010 15:47:14 +0200 Received: from donnerwolke.usta.de ([172.24.96.3]) by hekate.usta.de with esmtp (Exim 4.71) (envelope-from ) id 1OSViy-0001A5-I8 for tech@mdocml.bsd.lv; Sat, 26 Jun 2010 15:47:12 +0200 Received: from iris.usta.de ([172.24.96.5] helo=usta.de) by donnerwolke.usta.de with esmtp (Exim 4.69) (envelope-from ) id 1OSViy-00056R-HH for tech@mdocml.bsd.lv; Sat, 26 Jun 2010 15:47:12 +0200 Received: from schwarze by usta.de with local (Exim 4.71) (envelope-from ) id 1OSViy-0004Ga-GC for tech@mdocml.bsd.lv; Sat, 26 Jun 2010 15:47:12 +0200 Date: Sat, 26 Jun 2010 15:47:12 +0200 From: Ingo Schwarze To: tech@mdocml.bsd.lv Subject: [WIP] SYNOPSIS indentation Message-ID: <20100626134712.GC22002@iris.usta.de> X-Mailinglist: mdocml-tech Reply-To: tech@mdocml.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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