version 1.53, 2017/06/16 20:01:06 |
version 1.55, 2017/06/27 18:25:02 |
Line 93 term_tbl(struct termp *tp, const struct tbl_span *sp) |
|
Line 93 term_tbl(struct termp *tp, const struct tbl_span *sp) |
|
|
|
tblcalc(&tp->tbl, sp, tp->tcol->offset, tp->tcol->rmargin); |
tblcalc(&tp->tbl, sp, tp->tcol->offset, tp->tcol->rmargin); |
|
|
|
/* Tables leak .ta settings to subsequent text. */ |
|
|
|
term_tab_set(tp, NULL); |
|
coloff = sp->opts->opts & (TBL_OPT_BOX | TBL_OPT_DBOX) || |
|
sp->opts->lvert; |
|
for (ic = 0; ic < sp->opts->cols; ic++) { |
|
coloff += tp->tbl.cols[ic].width; |
|
term_tab_iset(coloff); |
|
coloff += tp->tbl.cols[ic].spacing; |
|
} |
|
|
/* Center the table as a whole. */ |
/* Center the table as a whole. */ |
|
|
offset = tp->tcol->offset; |
offset = tp->tcol->offset; |
if (sp->opts->opts & TBL_OPT_CENTRE) { |
if (sp->opts->opts & TBL_OPT_CENTRE) { |
tsz = sp->opts->opts & (TBL_OPT_BOX | TBL_OPT_DBOX) |
tsz = sp->opts->opts & (TBL_OPT_BOX | TBL_OPT_DBOX) |
? 2 : !!sp->opts->lvert + !!sp->opts->rvert; |
? 2 : !!sp->opts->lvert + !!sp->opts->rvert; |
for (ic = 0; ic < sp->opts->cols; ic++) |
for (ic = 0; ic + 1 < sp->opts->cols; ic++) |
tsz += tp->tbl.cols[ic].width + 3; |
tsz += tp->tbl.cols[ic].width + |
tsz -= 3; |
tp->tbl.cols[ic].spacing; |
|
if (sp->opts->cols) |
|
tsz += tp->tbl.cols[sp->opts->cols - 1].width; |
if (offset + tsz > tp->tcol->rmargin) |
if (offset + tsz > tp->tcol->rmargin) |
tsz -= 1; |
tsz -= 1; |
tp->tcol->offset = offset + tp->tcol->rmargin > tsz ? |
tp->tcol->offset = offset + tp->tcol->rmargin > tsz ? |
Line 148 term_tbl(struct termp *tp, const struct tbl_span *sp) |
|
Line 161 term_tbl(struct termp *tp, const struct tbl_span *sp) |
|
} |
} |
coloff += tp->tbl.cols[ic].width; |
coloff += tp->tbl.cols[ic].width; |
tp->tcol->rmargin = coloff; |
tp->tcol->rmargin = coloff; |
coloff++; |
|
if (ic + 1 < sp->opts->cols) |
if (ic + 1 < sp->opts->cols) |
coloff += 2; |
coloff += tp->tbl.cols[ic].spacing; |
if (spans) { |
if (spans) { |
spans--; |
spans--; |
continue; |
continue; |
Line 164 term_tbl(struct termp *tp, const struct tbl_span *sp) |
|
Line 176 term_tbl(struct termp *tp, const struct tbl_span *sp) |
|
/* Set up a column for a right vertical frame. */ |
/* Set up a column for a right vertical frame. */ |
|
|
tp->tcol++; |
tp->tcol++; |
tp->tcol->offset = coloff; |
tp->tcol->offset = coloff + 1; |
tp->tcol->rmargin = tp->maxrmargin; |
tp->tcol->rmargin = tp->maxrmargin; |
|
|
/* Spans may have reduced the number of columns. */ |
/* Spans may have reduced the number of columns. */ |
Line 316 term_tbl(struct termp *tp, const struct tbl_span *sp) |
|
Line 328 term_tbl(struct termp *tp, const struct tbl_span *sp) |
|
tp->tcol + 1 == tp->tcols + tp->lasttcol)) |
tp->tcol + 1 == tp->tcols + tp->lasttcol)) |
continue; |
continue; |
|
|
if (tp->tcol->rmargin > tp->viscol) { |
if (tp->viscol < tp->tcol->rmargin) { |
(*tp->advance)(tp, tp->tcol->rmargin |
(*tp->advance)(tp, tp->tcol->rmargin |
- tp->viscol); |
- tp->viscol); |
tp->viscol = tp->tcol->rmargin; |
tp->viscol = tp->tcol->rmargin; |
} |
} |
|
while (tp->viscol < tp->tcol->rmargin + |
if (tp->tcol->rmargin + 1 > tp->viscol) { |
tp->tbl.cols[ic].spacing / 2) { |
(*tp->letter)(tp, fc); |
(*tp->letter)(tp, fc); |
tp->viscol++; |
tp->viscol++; |
} |
} |
Line 342 term_tbl(struct termp *tp, const struct tbl_span *sp) |
|
Line 354 term_tbl(struct termp *tp, const struct tbl_span *sp) |
|
break; |
break; |
} |
} |
} |
} |
|
if (tp->tbl.cols[ic].spacing) { |
|
(*tp->letter)(tp, fc == ' ' ? '|' : |
|
vert ? '+' : fc); |
|
tp->viscol++; |
|
} |
|
|
(*tp->letter)(tp, |
|
fc == ' ' ? '|' : vert ? '+' : fc); |
|
tp->viscol++; |
|
|
|
if (fc != ' ') { |
if (fc != ' ') { |
if (cp != NULL && |
if (cp != NULL && |
cp->pos == TBL_CELL_HORIZ) |
cp->pos == TBL_CELL_HORIZ) |
Line 357 term_tbl(struct termp *tp, const struct tbl_span *sp) |
|
Line 370 term_tbl(struct termp *tp, const struct tbl_span *sp) |
|
else |
else |
fc = ' '; |
fc = ' '; |
} |
} |
if (vert > 1 || fc != ' ') { |
if (tp->tbl.cols[ic].spacing > 2 && |
|
(vert > 1 || fc != ' ')) { |
(*tp->letter)(tp, fc == ' ' ? '|' : |
(*tp->letter)(tp, fc == ' ' ? '|' : |
vert > 1 ? '+' : fc); |
vert > 1 ? '+' : fc); |
tp->viscol++; |
tp->viscol++; |
|
|
tbl_hrule(struct termp *tp, const struct tbl_span *sp, int kind) |
tbl_hrule(struct termp *tp, const struct tbl_span *sp, int kind) |
{ |
{ |
const struct tbl_cell *cp, *cpn, *cpp; |
const struct tbl_cell *cp, *cpn, *cpp; |
|
const struct roffcol *col; |
int vert; |
int vert; |
char line, cross; |
char line, cross; |
|
|
Line 453 tbl_hrule(struct termp *tp, const struct tbl_span *sp, |
|
Line 468 tbl_hrule(struct termp *tp, const struct tbl_span *sp, |
|
if (cpn == cp) |
if (cpn == cp) |
cpn = NULL; |
cpn = NULL; |
for (;;) { |
for (;;) { |
tbl_char(tp, line, tp->tbl.cols[cp->col].width + 1); |
col = tp->tbl.cols + cp->col; |
|
tbl_char(tp, line, col->width + col->spacing / 2); |
vert = cp->vert; |
vert = cp->vert; |
if ((cp = cp->next) == NULL) |
if ((cp = cp->next) == NULL) |
break; |
break; |
Line 469 tbl_hrule(struct termp *tp, const struct tbl_span *sp, |
|
Line 485 tbl_hrule(struct termp *tp, const struct tbl_span *sp, |
|
} |
} |
if (sp->opts->opts & TBL_OPT_ALLBOX && !vert) |
if (sp->opts->opts & TBL_OPT_ALLBOX && !vert) |
vert = 1; |
vert = 1; |
if (vert) |
if (col->spacing) |
tbl_char(tp, cross, vert); |
tbl_char(tp, vert ? cross : line, 1); |
if (vert < 2) |
if (col->spacing > 2) |
tbl_char(tp, line, 2 - vert); |
tbl_char(tp, vert > 1 ? cross : line, 1); |
|
if (col->spacing > 4) |
|
tbl_char(tp, line, (col->spacing - 3) / 2); |
} |
} |
if (kind) { |
if (kind) { |
term_word(tp, "+"); |
term_word(tp, "+"); |