summaryrefslogtreecommitdiffstats
path: root/eqn_term.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-07-24 10:09:03 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-07-24 10:09:03 +0000
commit0db02e2364d93cad88a1df785984438635066e39 (patch)
treee2692c9f56fe6ad6ad2dd87adb78c02298d14a2f /eqn_term.c
parent7151bb8eeed729397435c0c693efc5546cfda123 (diff)
downloadmandoc-0db02e2364d93cad88a1df785984438635066e39.tar.gz
Tuned the initial eqn output, making it completely simple. This
completes a full initial eqn system, so I'm tagging a release on it.
Diffstat (limited to 'eqn_term.c')
-rw-r--r--eqn_term.c54
1 files changed, 24 insertions, 30 deletions
diff --git a/eqn_term.c b/eqn_term.c
index ee0a75fb..af4b2cb3 100644
--- a/eqn_term.c
+++ b/eqn_term.c
@@ -27,10 +27,15 @@
#include "out.h"
#include "term.h"
+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 *);
-static void eqn_box_post(struct termp *, const struct eqn_box *);
-static void eqn_box_pre(struct termp *, const struct eqn_box *);
-static void eqn_text(struct termp *, const struct eqn_box *);
void
term_eqn(struct termp *p, const struct eqn *ep)
@@ -38,6 +43,7 @@ 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,38 +51,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 (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 (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);
-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);
}