static void tbl_word(struct termp *tp, const struct tbl_dat *dp) { const void *prev_font; prev_font = term_fontq(tp); if (dp->layout->flags & TBL_CELL_BOLD) term_fontpush(tp, TERMFONT_BOLD); else if (dp->layout->flags & TBL_CELL_ITALIC) term_fontpush(tp, TERMFONT_UNDER); term_word(tp, dp->string); term_fontpopq(tp, prev_font); }
static void print_mdoc_node(DECL_ARGS) { int chld; struct termpair npair; size_t offset, rmargin; chld = 1; offset = p->offset; rmargin = p->rmargin; n->flags &= ~MDOC_ENDED; n->prev_font = p->fonti; memset(&npair, 0, sizeof(struct termpair)); npair.ppair = pair; /* * Keeps only work until the end of a line. If a keep was * invoked in a prior line, revert it to PREKEEP. */ if (p->flags & TERMP_KEEP && n->flags & MDOC_LINE) { p->flags &= ~TERMP_KEEP; p->flags |= TERMP_PREKEEP; } /* * After the keep flags have been set up, we may now * produce output. Note that some pre-handlers do so. */ switch (n->type) { case ROFFT_TEXT: if (' ' == *n->string && MDOC_LINE & n->flags) term_newln(p); if (MDOC_DELIMC & n->flags) p->flags |= TERMP_NOSPACE; term_word(p, n->string); if (MDOC_DELIMO & n->flags) p->flags |= TERMP_NOSPACE; break; case ROFFT_EQN: if ( ! (n->flags & MDOC_LINE)) p->flags |= TERMP_NOSPACE; term_eqn(p, n->eqn); if (n->next != NULL && ! (n->next->flags & MDOC_LINE)) p->flags |= TERMP_NOSPACE; break; case ROFFT_TBL: if (p->tbl.cols == NULL) term_newln(p); term_tbl(p, n->span); break; default: if (termacts[n->tok].pre && (n->end == ENDBODY_NOT || n->child != NULL)) chld = (*termacts[n->tok].pre) (p, &npair, meta, n); break; } if (chld && n->child) print_mdoc_nodelist(p, &npair, meta, n->child); term_fontpopq(p, (ENDBODY_NOT == n->end ? n : n->body)->prev_font); switch (n->type) { case ROFFT_TEXT: break; case ROFFT_TBL: break; case ROFFT_EQN: break; default: if ( ! termacts[n->tok].post || MDOC_ENDED & n->flags) break; (void)(*termacts[n->tok].post)(p, &npair, meta, n); /* * Explicit end tokens not only call the post * handler, but also tell the respective block * that it must not call the post handler again. */ if (ENDBODY_NOT != n->end) n->body->flags |= MDOC_ENDED; /* * End of line terminating an implicit block * while an explicit block is still open. * Continue the explicit block without spacing. */ if (ENDBODY_NOSPACE == n->end) p->flags |= TERMP_NOSPACE; break; } if (MDOC_EOS & n->flags) p->flags |= TERMP_SENTENCE; if (MDOC_ll != n->tok) { p->offset = offset; p->rmargin = rmargin; } }
/* ARGSUSED */ static void print_mdoc_node(DECL_ARGS) { int chld; const void *font; struct termpair npair; size_t offset, rmargin; chld = 1; offset = p->offset; rmargin = p->rmargin; font = term_fontq(p); memset(&npair, 0, sizeof(struct termpair)); npair.ppair = pair; /* * Keeps only work until the end of a line. If a keep was * invoked in a prior line, revert it to PREKEEP. * * Also let SYNPRETTY sections behave as if they were wrapped * in a `Bk' block. */ if (TERMP_KEEP & p->flags || MDOC_SYNPRETTY & n->flags) { if (n->prev && n->prev->line != n->line) { p->flags &= ~TERMP_KEEP; p->flags |= TERMP_PREKEEP; } else if (NULL == n->prev) { if (n->parent && n->parent->line != n->line) { p->flags &= ~TERMP_KEEP; p->flags |= TERMP_PREKEEP; } } } /* * Since SYNPRETTY sections aren't "turned off" with `Ek', * we have to intuit whether we should disable formatting. */ if ( ! (MDOC_SYNPRETTY & n->flags) && ((n->prev && MDOC_SYNPRETTY & n->prev->flags) || (n->parent && MDOC_SYNPRETTY & n->parent->flags))) p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP); /* * After the keep flags have been set up, we may now * produce output. Note that some pre-handlers do so. */ switch (n->type) { case (MDOC_TEXT): if (' ' == *n->string && MDOC_LINE & n->flags) term_newln(p); if (MDOC_DELIMC & n->flags) p->flags |= TERMP_NOSPACE; term_word(p, n->string); if (MDOC_DELIMO & n->flags) p->flags |= TERMP_NOSPACE; break; case (MDOC_EQN): term_eqn(p, n->eqn); break; case (MDOC_TBL): term_tbl(p, n->span); break; default: if (termacts[n->tok].pre && ENDBODY_NOT == n->end) chld = (*termacts[n->tok].pre) (p, &npair, m, n); break; } if (chld && n->child) print_mdoc_nodelist(p, &npair, m, n->child); term_fontpopq(p, font); switch (n->type) { case (MDOC_TEXT): break; case (MDOC_TBL): break; case (MDOC_EQN): break; default: if ( ! termacts[n->tok].post || MDOC_ENDED & n->flags) break; (void)(*termacts[n->tok].post)(p, &npair, m, n); /* * Explicit end tokens not only call the post * handler, but also tell the respective block * that it must not call the post handler again. */ if (ENDBODY_NOT != n->end) n->pending->flags |= MDOC_ENDED; /* * End of line terminating an implicit block * while an explicit block is still open. * Continue the explicit block without spacing. */ if (ENDBODY_NOSPACE == n->end) p->flags |= TERMP_NOSPACE; break; } if (MDOC_EOS & n->flags) p->flags |= TERMP_SENTENCE; p->offset = offset; p->rmargin = rmargin; }