=================================================================== RCS file: /cvs/mandoc/eqn_term.c,v retrieving revision 1.1 retrieving revision 1.5 diff -u -p -r1.1 -r1.5 --- mandoc/eqn_term.c 2011/07/22 10:50:46 1.1 +++ mandoc/eqn_term.c 2014/04/20 16:46:04 1.5 @@ -1,4 +1,4 @@ -/* $Id: eqn_term.c,v 1.1 2011/07/22 10:50:46 kristaps Exp $ */ +/* $Id: eqn_term.c,v 1.5 2014/04/20 16:46:04 schwarze Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons * @@ -27,17 +27,24 @@ #include "out.h" #include "term.h" -static void eqn_box(struct termp *p, const struct eqn_box *); -static void eqn_box_post(struct termp *p, const struct eqn_box *); -static void eqn_box_pre(struct termp *p, const struct eqn_box *); -static void eqn_text(struct termp *p, const struct eqn_box *); +static const enum termfont fontmap[EQNFONT__MAX] = { + TERMFONT_NONE, /* EQNFONT_NONE */ + TERMFONT_NONE, /* EQNFONT_ROMAN */ + TERMFONT_BOLD, /* EQNFONT_BOLD */ + TERMFONT_BOLD, /* EQNFONT_FAT */ + TERMFONT_UNDER /* EQNFONT_ITALIC */ +}; +static void eqn_box(struct termp *, const struct eqn_box *); + + void term_eqn(struct termp *p, const struct eqn *ep) { p->flags |= TERMP_NONOSPACE; eqn_box(p, ep->root); + term_word(p, " "); p->flags &= ~TERMP_NONOSPACE; } @@ -45,44 +52,26 @@ static void eqn_box(struct termp *p, const struct eqn_box *bp) { - eqn_box_pre(p, bp); - eqn_text(p, bp); - - if (bp->first) - eqn_box(p, bp->first); - - eqn_box_post(p, bp); - - if (bp->next) - eqn_box(p, bp->next); -} - -static void -eqn_box_pre(struct termp *p, const struct eqn_box *bp) -{ - - if (EQN_LIST == bp->type) - term_word(p, "{"); + 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, "("); -static void -eqn_box_post(struct termp *p, const struct eqn_box *bp) -{ + if (bp->text) + term_word(p, bp->text); - if (EQN_LIST == bp->type) - term_word(p, "}"); + 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 (bp->above) - term_word(p, "|"); -} + if (EQNFONT_NONE != bp->font) + term_fontpop(p); -static void -eqn_text(struct termp *p, const struct eqn_box *bp) -{ - - if (bp->text) - term_word(p, bp->text); + if (bp->next) + eqn_box(p, bp->next); }