[BACK]Return to eqn_term.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Annotation of mandoc/eqn_term.c, Revision 1.5

1.5     ! schwarze    1: /*     $Id: eqn_term.c,v 1.4 2011/07/24 10:09:03 kristaps Exp $ */
1.1       kristaps    2: /*
                      3:  * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
                      4:  *
                      5:  * Permission to use, copy, modify, and distribute this software for any
                      6:  * purpose with or without fee is hereby granted, provided that the above
                      7:  * copyright notice and this permission notice appear in all copies.
                      8:  *
                      9:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     10:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     11:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     12:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     13:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     14:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     15:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     16:  */
                     17: #ifdef HAVE_CONFIG_H
                     18: #include "config.h"
                     19: #endif
                     20:
                     21: #include <assert.h>
                     22: #include <stdio.h>
                     23: #include <stdlib.h>
                     24: #include <string.h>
                     25:
                     26: #include "mandoc.h"
                     27: #include "out.h"
                     28: #include "term.h"
                     29:
1.4       kristaps   30: static const enum termfont fontmap[EQNFONT__MAX] = {
                     31:        TERMFONT_NONE, /* EQNFONT_NONE */
                     32:        TERMFONT_NONE, /* EQNFONT_ROMAN */
                     33:        TERMFONT_BOLD, /* EQNFONT_BOLD */
                     34:        TERMFONT_BOLD, /* EQNFONT_FAT */
                     35:        TERMFONT_UNDER /* EQNFONT_ITALIC */
                     36: };
                     37:
1.3       kristaps   38: static void    eqn_box(struct termp *, const struct eqn_box *);
1.1       kristaps   39:
1.5     ! schwarze   40:
1.1       kristaps   41: void
                     42: term_eqn(struct termp *p, const struct eqn *ep)
                     43: {
                     44:
                     45:        p->flags |= TERMP_NONOSPACE;
                     46:        eqn_box(p, ep->root);
1.4       kristaps   47:        term_word(p, " ");
1.1       kristaps   48:        p->flags &= ~TERMP_NONOSPACE;
                     49: }
                     50:
                     51: static void
                     52: eqn_box(struct termp *p, const struct eqn_box *bp)
                     53: {
                     54:
1.4       kristaps   55:        if (EQNFONT_NONE != bp->font)
                     56:                term_fontpush(p, fontmap[(int)bp->font]);
                     57:        if (bp->left)
                     58:                term_word(p, bp->left);
                     59:        if (EQN_SUBEXPR == bp->type)
                     60:                term_word(p, "(");
                     61:
                     62:        if (bp->text)
                     63:                term_word(p, bp->text);
1.1       kristaps   64:
                     65:        if (bp->first)
                     66:                eqn_box(p, bp->first);
                     67:
1.4       kristaps   68:        if (EQN_SUBEXPR == bp->type)
                     69:                term_word(p, ")");
                     70:        if (bp->right)
                     71:                term_word(p, bp->right);
1.5     ! schwarze   72:        if (EQNFONT_NONE != bp->font)
1.4       kristaps   73:                term_fontpop(p);
1.1       kristaps   74:
                     75:        if (bp->next)
                     76:                eqn_box(p, bp->next);
                     77: }

CVSweb