260e9a87725c090ba5835b1f9f0b62fa2f96036fYuri Pankov/* $Id: eqn_term.c,v 1.8 2015/01/01 15:36:08 schwarze Exp $ */
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
260e9a87725c090ba5835b1f9f0b62fa2f96036fYuri Pankov * Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore * Permission to use, copy, modify, and distribute this software for any
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore * purpose with or without fee is hereby granted, provided that the above
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore * copyright notice and this permission notice appear in all copies.
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amorestatic const enum termfont fontmap[EQNFONT__MAX] = {
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amorestatic void eqn_box(struct termp *, const struct eqn_box *);
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amoreterm_eqn(struct termp *p, const struct eqn *ep)
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amoreeqn_box(struct termp *p, const struct eqn_box *bp)
260e9a87725c090ba5835b1f9f0b62fa2f96036fYuri Pankov (bp->type == EQN_PILE && (bp->prev || bp->next)) ||
260e9a87725c090ba5835b1f9f0b62fa2f96036fYuri Pankov (bp->parent != NULL && bp->parent->pos == EQNPOS_SQRT)) {
260e9a87725c090ba5835b1f9f0b62fa2f96036fYuri Pankov if (bp->parent->type == EQN_SUBEXPR && bp->prev != NULL)
260e9a87725c090ba5835b1f9f0b62fa2f96036fYuri Pankov term_word(p, bp->left != NULL ? bp->left : "(");
260e9a87725c090ba5835b1f9f0b62fa2f96036fYuri Pankov if (bp->type == EQN_MATRIX && child->type == EQN_LIST)
260e9a87725c090ba5835b1f9f0b62fa2f96036fYuri Pankov (bp->type == EQN_PILE && (bp->prev || bp->next)) ||
260e9a87725c090ba5835b1f9f0b62fa2f96036fYuri Pankov (bp->parent != NULL && bp->parent->pos == EQNPOS_SQRT)) {
260e9a87725c090ba5835b1f9f0b62fa2f96036fYuri Pankov term_word(p, bp->right != NULL ? bp->right : ")");
260e9a87725c090ba5835b1f9f0b62fa2f96036fYuri Pankov if (bp->parent->type == EQN_SUBEXPR && bp->next != NULL)