static int termp_xr_pre(DECL_ARGS) { if (NULL == (n = n->child)) return 0; assert(n->type == ROFFT_TEXT); term_word(p, n->string); if (NULL == (n = n->next)) return 0; p->flags |= TERMP_NOSPACE; term_word(p, "("); p->flags |= TERMP_NOSPACE; assert(n->type == ROFFT_TEXT); term_word(p, n->string); p->flags |= TERMP_NOSPACE; term_word(p, ")"); return 0; }
static void termp____post(DECL_ARGS) { /* * Handle lists of authors. In general, print each followed by * a comma. Don't print the comma if there are only two * authors. */ if (MDOC__A == n->tok && n->next && MDOC__A == n->next->tok) if (NULL == n->next->next || MDOC__A != n->next->next->tok) if (NULL == n->prev || MDOC__A != n->prev->tok) return; /* TODO: %U. */ if (NULL == n->parent || MDOC_Rs != n->parent->tok) return; p->flags |= TERMP_NOSPACE; if (NULL == n->next) { term_word(p, "."); p->flags |= TERMP_SENTENCE; } else term_word(p, ","); }
static int termp_lk_pre(DECL_ARGS) { const struct roff_node *link, *descr; if (NULL == (link = n->child)) return 0; if (NULL != (descr = link->next)) { term_fontpush(p, TERMFONT_UNDER); while (NULL != descr) { term_word(p, descr->string); descr = descr->next; } p->flags |= TERMP_NOSPACE; term_word(p, ":"); term_fontpop(p); } term_fontpush(p, TERMFONT_BOLD); term_word(p, link->string); term_fontpop(p); return 0; }
/* ARGSUSED */ static int termp_lk_pre(DECL_ARGS) { const struct mdoc_node *nn, *sv; term_fontpush(p, TERMFONT_UNDER); nn = sv = n->child; if (NULL == nn || NULL == nn->next) return(1); for (nn = nn->next; nn; nn = nn->next) term_word(p, nn->string); term_fontpop(p); p->flags |= TERMP_NOSPACE; term_word(p, ":"); term_fontpush(p, TERMFONT_BOLD); term_word(p, sv->string); term_fontpop(p); return(0); }
static void eqn_box(struct termp *p, const struct eqn_box *bp) { if (EQNFONT_NONE != bp->font) term_fontpush(p, fontmap[(int)bp->font]); if (bp->left) term_word(p, bp->left); if (EQN_SUBEXPR == bp->type) term_word(p, "("); if (bp->text) term_word(p, bp->text); if (bp->first) eqn_box(p, bp->first); if (EQN_SUBEXPR == bp->type) term_word(p, ")"); if (bp->right) term_word(p, bp->right); if (EQNFONT_NONE != bp->font) term_fontpop(p); if (bp->next) eqn_box(p, bp->next); }
/* ARGSUSED */ static int termp_fa_pre(DECL_ARGS) { const struct mdoc_node *nn; if (n->parent->tok != MDOC_Fo) { term_fontpush(p, TERMFONT_UNDER); return(1); } for (nn = n->child; nn; nn = nn->next) { term_fontpush(p, TERMFONT_UNDER); term_word(p, nn->string); term_fontpop(p); if (nn->next) { p->flags |= TERMP_NOSPACE; term_word(p, ","); } } if (n->child && n->next && n->next->tok == MDOC_Fa) { p->flags |= TERMP_NOSPACE; term_word(p, ","); } return(0); }
/* ARGSUSED */ static int termp_xr_pre(DECL_ARGS) { if (NULL == (n = n->child)) return(0); assert(MDOC_TEXT == n->type); term_word(p, n->string); if (NULL == (n = n->next)) return(0); p->flags |= TERMP_NOSPACE; term_word(p, "("); p->flags |= TERMP_NOSPACE; assert(MDOC_TEXT == n->type); term_word(p, n->string); p->flags |= TERMP_NOSPACE; term_word(p, ")"); return(0); }
static void print_man_foot(struct termp *p, const void *arg) { const struct man_meta *meta; meta = (const struct man_meta *)arg; term_fontrepl(p, TERMFONT_NONE); term_vspace(p); term_vspace(p); term_vspace(p); p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; p->rmargin = p->maxrmargin - term_strlen(p, meta->date); p->offset = 0; /* term_strlen() can return zero. */ if (p->rmargin == p->maxrmargin) p->rmargin--; if (meta->source) term_word(p, meta->source); if (meta->source) term_word(p, ""); term_flushln(p); p->flags |= TERMP_NOLPAD | TERMP_NOSPACE; p->offset = p->rmargin; p->rmargin = p->maxrmargin; p->flags &= ~TERMP_NOBREAK; term_word(p, meta->date); term_flushln(p); }
/* ARGSUSED */ static void termp_fo_post(DECL_ARGS) { if (MDOC_BODY != n->type) return; term_word(p, ")"); if (MDOC_SYNPRETTY & n->flags) term_word(p, ";"); }
/* * Rules above and below the table are always single * and have an additional plus at the beginning and end. * For double frames, this function is called twice, * and the outer one does not have crossings. */ static void tbl_hframe(struct termp *tp, const struct tbl_span *sp, int outer) { const struct tbl_head *hp; term_word(tp, "+"); for (hp = sp->head; hp; hp = hp->next) tbl_char(tp, outer || TBL_HEAD_DATA == hp->pos ? '-' : '+', tbl_rulewidth(tp, hp)); term_word(tp, "+"); term_flushln(tp); }
static void print_mdoc_foot(struct termp *p, const void *arg) { const struct mdoc_meta *meta; size_t sz; meta = (const struct mdoc_meta *)arg; term_fontrepl(p, TERMFONT_NONE); /* * Output the footer in new-groff style, that is, three columns * with the middle being the manual date and flanking columns * being the operating system: * * SYSTEM DATE SYSTEM */ term_vspace(p); p->offset = 0; sz = term_strlen(p, meta->date); p->rmargin = p->maxrmargin > sz ? (p->maxrmargin + term_len(p, 1) - sz) / 2 : 0; p->trailspace = 1; p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; term_word(p, meta->os); term_flushln(p); p->offset = p->rmargin; sz = term_strlen(p, meta->os); p->rmargin = p->maxrmargin > sz ? p->maxrmargin - sz : 0; p->flags |= TERMP_NOSPACE; term_word(p, meta->date); term_flushln(p); p->offset = p->rmargin; p->rmargin = p->maxrmargin; p->trailspace = 0; p->flags &= ~TERMP_NOBREAK; p->flags |= TERMP_NOSPACE; term_word(p, meta->os); term_flushln(p); p->offset = 0; p->rmargin = p->maxrmargin; p->flags = 0; }
/* ARGSUSED */ static int termp_nd_pre(DECL_ARGS) { if (MDOC_BODY != n->type) return(1); #if defined(__OpenBSD__) || defined(__linux__) term_word(p, "\\(en"); #else term_word(p, "\\(em"); #endif return(1); }
static void print_mdoc_foot(struct termp *p, const void *arg) { char buf[DATESIZ], os[BUFSIZ]; const struct mdoc_meta *m; m = (const struct mdoc_meta *)arg; term_fontrepl(p, TERMFONT_NONE); /* * Output the footer in new-groff style, that is, three columns * with the middle being the manual date and flanking columns * being the operating system: * * SYSTEM DATE SYSTEM */ time2a(m->date, buf, DATESIZ); strlcpy(os, m->os, BUFSIZ); term_vspace(p); p->offset = 0; p->rmargin = (p->maxrmargin - term_strlen(p, buf) + term_len(p, 1)) / 2; p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; term_word(p, os); term_flushln(p); p->offset = p->rmargin; p->rmargin = p->maxrmargin - term_strlen(p, os); p->flags |= TERMP_NOLPAD | TERMP_NOSPACE; term_word(p, buf); term_flushln(p); p->offset = p->rmargin; p->rmargin = p->maxrmargin; p->flags &= ~TERMP_NOBREAK; p->flags |= TERMP_NOLPAD | TERMP_NOSPACE; term_word(p, os); term_flushln(p); p->offset = 0; p->rmargin = p->maxrmargin; p->flags = 0; }
/* * Rules above and below the table are always single * and have an additional plus at the beginning and end. * For double frames, this function is called twice, * and the outer one does not have crossings. */ static void tbl_hframe(struct termp *tp, const struct tbl_span *sp, int outer) { const struct tbl_head *hp; term_word(tp, "+"); for (hp = sp->head; hp; hp = hp->next) { if (hp->prev && hp->vert) tbl_char(tp, (outer ? '-' : '+'), hp->vert); tbl_char(tp, '-', tbl_rulewidth(tp, hp)); } term_word(tp, "+"); term_flushln(tp); }
static void tbl_vrule(struct termp *tp, const struct tbl_head *hp) { switch (hp->pos) { case (TBL_HEAD_VERT): term_word(tp, "|"); break; case (TBL_HEAD_DVERT): term_word(tp, "||"); break; default: break; } }
/* ARGSUSED */ static void termp_fo_post(DECL_ARGS) { if (MDOC_BODY != n->type) return; p->flags |= TERMP_NOSPACE; term_word(p, ")"); if (MDOC_SYNPRETTY & n->flags) { p->flags |= TERMP_NOSPACE; term_word(p, ";"); } }
static void tbl_vframe(struct termp *tp, const struct tbl *tbl) { if (TBL_OPT_BOX & tbl->opts || TBL_OPT_DBOX & tbl->opts) term_word(tp, "|"); }
static void tbl_literal(struct termp *tp, const struct tbl_dat *dp, const struct roffcol *col) { size_t len, padl, padr; assert(dp->string); len = term_strlen(tp, dp->string); padr = col->width > len ? col->width - len : 0; padl = 0; switch (dp->layout->pos) { case (TBL_CELL_LONG): padl = term_len(tp, 1); padr = padr > padl ? padr - padl : 0; break; case (TBL_CELL_CENTRE): if (2 > padr) break; padl = padr / 2; padr -= padl; break; case (TBL_CELL_RIGHT): padl = padr; padr = 0; break; default: break; } tbl_char(tp, ASCII_NBRSP, padl); term_word(tp, dp->string); tbl_char(tp, ASCII_NBRSP, padr); }
/* ARGSUSED */ static int termp_xx_pre(DECL_ARGS) { const char *pp; pp = NULL; switch (n->tok) { case (MDOC_Bsx): pp = "BSD/OS"; break; case (MDOC_Dx): pp = "DragonFly"; break; case (MDOC_Fx): pp = "FreeBSD"; break; case (MDOC_Nx): pp = "NetBSD"; break; case (MDOC_Ox): pp = "OpenBSD"; break; case (MDOC_Ux): pp = "UNIX"; break; default: break; } assert(pp); term_word(p, pp); return(1); }
static void post_UR(DECL_ARGS) { if (n->type != ROFFT_BLOCK) return; term_word(p, "<"); p->flags |= TERMP_NOSPACE; if (NULL != n->child->child) print_man_node(p, mt, n->child->child, meta); p->flags |= TERMP_NOSPACE; term_word(p, ">"); }
static void termp_fo_post(DECL_ARGS) { if (n->type != ROFFT_BODY) return; p->flags |= TERMP_NOSPACE; term_word(p, ")"); if (MDOC_SYNPRETTY & n->flags) { p->flags |= TERMP_NOSPACE; term_word(p, ";"); term_flushln(p); } }
static void roff_term_pre_ce(ROFF_TERM_ARGS) { const struct roff_node *nc1, *nc2; roff_term_pre_br(p, n); p->flags |= n->tok == ROFF_ce ? TERMP_CENTER : TERMP_RIGHT; nc1 = n->child->next; while (nc1 != NULL) { nc2 = nc1; do { nc2 = nc2->next; } while (nc2 != NULL && (nc2->type != ROFFT_TEXT || (nc2->flags & NODE_LINE) == 0)); while (nc1 != nc2) { if (nc1->type == ROFFT_TEXT) term_word(p, nc1->string); else roff_term_pre(p, nc1); nc1 = nc1->next; } p->flags |= TERMP_NOSPACE; term_flushln(p); } p->flags &= ~(TERMP_CENTER | TERMP_RIGHT); }
/* ARGSUSED */ static void termp_bx_post(DECL_ARGS) { if (n->child) p->flags |= TERMP_NOSPACE; term_word(p, "BSD"); }
static int termp_nd_pre(DECL_ARGS) { if (n->type == MDOC_BODY) term_word(p, "\\(en"); return(1); }
static int termp_ud_pre(DECL_ARGS) { term_word(p, "currently under development."); p->flags |= TERMP_SENTENCE; return 0; }
static int termp_bt_pre(DECL_ARGS) { term_word(p, "is currently in beta test."); p->flags |= TERMP_SENTENCE; return 0; }
static int termp_nd_pre(DECL_ARGS) { if (n->type == ROFFT_BODY) term_word(p, "\\(en"); return 1; }
static void termp_quote_post(DECL_ARGS) { if (n->type != ROFFT_BODY && n->type != ROFFT_ELEM) return; p->flags |= TERMP_NOSPACE; switch (n->tok) { case MDOC_Ao: case MDOC_Aq: term_word(p, n->child != NULL && n->child->next == NULL && n->child->tok == MDOC_Mt ? ">" : "\\(ra"); break; case MDOC_Bro: case MDOC_Brq: term_word(p, "}"); break; case MDOC_Oo: case MDOC_Op: case MDOC_Bo: case MDOC_Bq: term_word(p, "]"); break; case MDOC_Do: case MDOC_Dq: term_word(p, "\\(Rq"); break; case MDOC_En: if (n->norm->Es == NULL || n->norm->Es->child == NULL || n->norm->Es->child->next == NULL) p->flags &= ~TERMP_NOSPACE; else term_word(p, n->norm->Es->child->next->string); break; case MDOC_Po: case MDOC_Pq: term_word(p, ")"); break; case MDOC__T: case MDOC_Qo: case MDOC_Qq: term_word(p, "\""); break; case MDOC_Ql: case MDOC_So: case MDOC_Sq: term_word(p, "\\(cq"); break; default: abort(); } }
static int termp_ex_pre(DECL_ARGS) { struct roff_node *nch; term_newln(p); term_word(p, "The"); for (nch = n->child; nch != NULL; nch = nch->next) { term_fontpush(p, TERMFONT_BOLD); term_word(p, nch->string); term_fontpop(p); if (nch->next == NULL) continue; if (nch->prev != NULL || nch->next->next != NULL) { p->flags |= TERMP_NOSPACE; term_word(p, ","); } if (nch->next->next == NULL) term_word(p, "and"); } if (n->child != NULL && n->child->next != NULL) term_word(p, "utilities exit\\~0"); else term_word(p, "utility exits\\~0"); term_word(p, "on success, and\\~>0 if an error occurs."); p->flags |= TERMP_SENTENCE; return 0; }
static int termp_ex_pre(DECL_ARGS) { int nchild; term_newln(p); term_word(p, "The"); nchild = n->nchild; for (n = n->child; n; n = n->next) { term_fontpush(p, TERMFONT_BOLD); term_word(p, n->string); term_fontpop(p); if (nchild > 2 && n->next) { p->flags |= TERMP_NOSPACE; term_word(p, ","); } if (n->next && NULL == n->next->next) term_word(p, "and"); } if (nchild > 1) term_word(p, "utilities exit\\~0"); else term_word(p, "utility exits\\~0"); term_word(p, "on success, and\\~>0 if an error occurs."); p->flags |= TERMP_SENTENCE; return 0; }