=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/mdoc_term.c,v retrieving revision 1.76 retrieving revision 1.77 diff -c -r1.76 -r1.77 *** src/usr.bin/mandoc/mdoc_term.c 2010/05/08 02:10:09 1.76 --- src/usr.bin/mandoc/mdoc_term.c 2010/05/14 14:47:44 1.77 *************** *** 1,4 **** ! /* $Id: mdoc_term.c,v 1.76 2010/05/08 02:10:09 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * --- 1,4 ---- ! /* $Id: mdoc_term.c,v 1.77 2010/05/14 14:47:44 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * *************** *** 18,23 **** --- 18,24 ---- #include #include + #include #include #include #include *************** *** 54,59 **** --- 55,61 ---- static int arg_getattrs(const int *, int *, size_t, const struct mdoc_node *); static int arg_getattr(int, const struct mdoc_node *); + static int arg_disptype(const struct mdoc_node *); static int arg_listtype(const struct mdoc_node *); static void print_bvspace(struct termp *, const struct mdoc_node *, *************** *** 477,482 **** --- 479,513 ---- static int + arg_disptype(const struct mdoc_node *n) + { + int i, len; + + assert(MDOC_BLOCK == n->type); + + len = (int)(n->args ? n->args->argc : 0); + + for (i = 0; i < len; i++) + switch (n->args->argv[i].arg) { + case (MDOC_Centred): + /* FALLTHROUGH */ + case (MDOC_Ragged): + /* FALLTHROUGH */ + case (MDOC_Filled): + /* FALLTHROUGH */ + case (MDOC_Unfilled): + /* FALLTHROUGH */ + case (MDOC_Literal): + return(n->args->argv[i].arg); + default: + break; + } + + return(-1); + } + + + static int arg_listtype(const struct mdoc_node *n) { int i, len; *************** *** 1050,1056 **** termp_nm_pre(DECL_ARGS) { ! if (SEC_SYNOPSIS == n->sec) term_newln(p); term_fontpush(p, TERMFONT_BOLD); --- 1081,1087 ---- termp_nm_pre(DECL_ARGS) { ! if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) term_newln(p); term_fontpush(p, TERMFONT_BOLD); *************** *** 1125,1131 **** return; } ! if (arg_getattr(MDOC_Split, n) > -1) { p->flags &= ~TERMP_NOSPLIT; p->flags |= TERMP_SPLIT; } else { --- 1156,1162 ---- return; } ! if (arg_hasattr(MDOC_Split, n)) { p->flags &= ~TERMP_NOSPLIT; p->flags |= TERMP_SPLIT; } else { *************** *** 1349,1355 **** termp_fd_post(DECL_ARGS) { ! if (n->sec != SEC_SYNOPSIS) return; term_newln(p); --- 1380,1386 ---- termp_fd_post(DECL_ARGS) { ! if (n->sec != SEC_SYNOPSIS || ! (MDOC_LINE & n->flags)) return; term_newln(p); *************** *** 1436,1442 **** termp_lb_post(DECL_ARGS) { ! if (SEC_LIBRARY == n->sec) term_newln(p); } --- 1467,1473 ---- termp_lb_post(DECL_ARGS) { ! if (SEC_LIBRARY == n->sec && MDOC_LINE & n->flags) term_newln(p); } *************** *** 1505,1511 **** termp_ft_pre(DECL_ARGS) { ! if (SEC_SYNOPSIS == n->sec) if (n->prev && MDOC_Fo == n->prev->tok) term_vspace(p); --- 1536,1542 ---- termp_ft_pre(DECL_ARGS) { ! if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) if (n->prev && MDOC_Fo == n->prev->tok) term_vspace(p); *************** *** 1519,1525 **** termp_ft_post(DECL_ARGS) { ! if (SEC_SYNOPSIS == n->sec) term_newln(p); } --- 1550,1556 ---- termp_ft_post(DECL_ARGS) { ! if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) term_newln(p); } *************** *** 1560,1566 **** termp_fn_post(DECL_ARGS) { ! if (n->sec == SEC_SYNOPSIS && n->next) term_vspace(p); } --- 1591,1597 ---- termp_fn_post(DECL_ARGS) { ! if (n->sec == SEC_SYNOPSIS && n->next && MDOC_LINE & n->flags) term_vspace(p); } *************** *** 1598,1603 **** --- 1629,1635 ---- { size_t tabwidth; int i, type; + size_t rm, rmax; const struct mdoc_node *nn; if (MDOC_BLOCK == n->type) { *************** *** 1608,1634 **** nn = n->parent; ! for (type = -1, i = 0; i < (int)nn->args->argc; i++) { ! switch (nn->args->argv[i].arg) { ! case (MDOC_Centred): ! /* FALLTHROUGH */ ! case (MDOC_Ragged): ! /* FALLTHROUGH */ ! case (MDOC_Filled): ! /* FALLTHROUGH */ ! case (MDOC_Unfilled): ! /* FALLTHROUGH */ ! case (MDOC_Literal): ! type = nn->args->argv[i].arg; ! break; ! case (MDOC_Offset): ! p->offset += a2offs(&nn->args->argv[i]); ! break; ! default: ! break; ! } ! } /* * If -ragged or -filled are specified, the block does nothing * but change the indentation. If -unfilled or -literal are --- 1640,1651 ---- nn = n->parent; ! type = arg_disptype(nn); ! assert(-1 != type); + if (-1 != (i = arg_getattr(MDOC_Offset, nn))) + p->offset += a2offs(&nn->args->argv[i]); + /* * If -ragged or -filled are specified, the block does nothing * but change the indentation. If -unfilled or -literal are *************** *** 1637,1648 **** * lines are allowed. */ - assert(type > -1); if (MDOC_Literal != type && MDOC_Unfilled != type) return(1); tabwidth = p->tabwidth; p->tabwidth = 8; for (nn = n->child; nn; nn = nn->next) { p->flags |= TERMP_NOSPACE; print_mdoc_node(p, pair, m, nn); --- 1654,1668 ---- * lines are allowed. */ if (MDOC_Literal != type && MDOC_Unfilled != type) return(1); tabwidth = p->tabwidth; p->tabwidth = 8; + rm = p->rmargin; + rmax = p->maxrmargin; + p->rmargin = p->maxrmargin = TERM_MAXMARGIN; + for (nn = n->child; nn; nn = nn->next) { p->flags |= TERMP_NOSPACE; print_mdoc_node(p, pair, m, nn); *************** *** 1653,1658 **** --- 1673,1680 ---- } p->tabwidth = tabwidth; + p->rmargin = rm; + p->maxrmargin = rmax; return(0); } *************** *** 1661,1671 **** --- 1683,1708 ---- static void termp_bd_post(DECL_ARGS) { + int type; + size_t rm, rmax; if (MDOC_BODY != n->type) return; + + type = arg_disptype(n->parent); + assert(-1 != type); + + rm = p->rmargin; + rmax = p->maxrmargin; + + if (MDOC_Literal == type || MDOC_Unfilled == type) + p->rmargin = p->maxrmargin = TERM_MAXMARGIN; + p->flags |= TERMP_NOSPACE; term_newln(p); + + p->rmargin = rm; + p->maxrmargin = rmax; } *************** *** 1855,1861 **** term_word(p, ">"); term_fontpop(p); ! if (SEC_SYNOPSIS != n->sec) return; term_newln(p); --- 1892,1898 ---- term_word(p, ">"); term_fontpop(p); ! if (SEC_SYNOPSIS != n->sec && ! (MDOC_LINE & n->flags)) return; term_newln(p);