version 1.1, 2011/07/22 10:50:46 |
version 1.6, 2014/08/10 23:54:41 |
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
*/ |
*/ |
#ifdef HAVE_CONFIG_H |
|
#include "config.h" |
#include "config.h" |
#endif |
|
|
|
|
#include <sys/types.h> |
|
|
#include <assert.h> |
#include <assert.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
|
|
#include "out.h" |
#include "out.h" |
#include "term.h" |
#include "term.h" |
|
|
static void eqn_box(struct termp *p, const struct eqn_box *); |
static const enum termfont fontmap[EQNFONT__MAX] = { |
static void eqn_box_post(struct termp *p, const struct eqn_box *); |
TERMFONT_NONE, /* EQNFONT_NONE */ |
static void eqn_box_pre(struct termp *p, const struct eqn_box *); |
TERMFONT_NONE, /* EQNFONT_ROMAN */ |
static void eqn_text(struct termp *p, const struct eqn_box *); |
TERMFONT_BOLD, /* EQNFONT_BOLD */ |
|
TERMFONT_BOLD, /* EQNFONT_FAT */ |
|
TERMFONT_UNDER /* EQNFONT_ITALIC */ |
|
}; |
|
|
|
static void eqn_box(struct termp *, const struct eqn_box *); |
|
|
|
|
void |
void |
term_eqn(struct termp *p, const struct eqn *ep) |
term_eqn(struct termp *p, const struct eqn *ep) |
{ |
{ |
|
|
p->flags |= TERMP_NONOSPACE; |
p->flags |= TERMP_NONOSPACE; |
eqn_box(p, ep->root); |
eqn_box(p, ep->root); |
|
term_word(p, " "); |
p->flags &= ~TERMP_NONOSPACE; |
p->flags &= ~TERMP_NONOSPACE; |
} |
} |
|
|
|
|
eqn_box(struct termp *p, const struct eqn_box *bp) |
eqn_box(struct termp *p, const struct eqn_box *bp) |
{ |
{ |
|
|
eqn_box_pre(p, bp); |
if (EQNFONT_NONE != bp->font) |
eqn_text(p, bp); |
term_fontpush(p, fontmap[(int)bp->font]); |
|
|
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 (bp->left) |
if (bp->left) |
term_word(p, bp->left); |
term_word(p, bp->left); |
} |
if (EQN_SUBEXPR == bp->type) |
|
term_word(p, "("); |
|
|
static void |
if (bp->text) |
eqn_box_post(struct termp *p, const struct eqn_box *bp) |
term_word(p, bp->text); |
{ |
|
|
|
if (EQN_LIST == bp->type) |
if (bp->first) |
term_word(p, "}"); |
eqn_box(p, bp->first); |
|
|
|
if (EQN_SUBEXPR == bp->type) |
|
term_word(p, ")"); |
if (bp->right) |
if (bp->right) |
term_word(p, bp->right); |
term_word(p, bp->right); |
if (bp->above) |
if (EQNFONT_NONE != bp->font) |
term_word(p, "|"); |
term_fontpop(p); |
} |
|
|
|
static void |
if (bp->next) |
eqn_text(struct termp *p, const struct eqn_box *bp) |
eqn_box(p, bp->next); |
{ |
|
|
|
if (bp->text) |
|
term_word(p, bp->text); |
|
} |
} |