version 1.33, 2015/01/27 05:21:45 |
version 1.35, 2015/01/30 02:09:04 |
Line 63 term_tbl(struct termp *tp, const struct tbl_span *sp) |
|
Line 63 term_tbl(struct termp *tp, const struct tbl_span *sp) |
|
const struct tbl_head *hp; |
const struct tbl_head *hp; |
const struct tbl_cell *cp; |
const struct tbl_cell *cp; |
const struct tbl_dat *dp; |
const struct tbl_dat *dp; |
|
static size_t offset; |
|
size_t rmargin, maxrmargin, tsz; |
int horiz, spans, vert; |
int horiz, spans, vert; |
size_t rmargin, maxrmargin; |
|
|
|
rmargin = tp->rmargin; |
rmargin = tp->rmargin; |
maxrmargin = tp->maxrmargin; |
maxrmargin = tp->maxrmargin; |
Line 90 term_tbl(struct termp *tp, const struct tbl_span *sp) |
|
Line 91 term_tbl(struct termp *tp, const struct tbl_span *sp) |
|
|
|
tblcalc(&tp->tbl, sp, rmargin - tp->offset); |
tblcalc(&tp->tbl, sp, rmargin - tp->offset); |
|
|
|
/* Center the table as a whole. */ |
|
|
|
offset = tp->offset; |
|
if (sp->opts->opts & TBL_OPT_CENTRE) { |
|
tsz = sp->opts->opts & (TBL_OPT_BOX | TBL_OPT_DBOX) |
|
? 2 : !!sp->opts->lvert + !!sp->opts->rvert; |
|
for (hp = sp->head; hp != NULL; hp = hp->next) |
|
tsz += tp->tbl.cols[hp->ident].width + 3; |
|
tsz -= 3; |
|
if (offset + tsz > rmargin) |
|
tsz -= 1; |
|
tp->offset = (offset + rmargin > tsz) ? |
|
(offset + rmargin - tsz) / 2 : 0; |
|
} |
|
|
/* Horizontal frame at the start of boxed tables. */ |
/* Horizontal frame at the start of boxed tables. */ |
|
|
if (sp->opts->opts & TBL_OPT_DBOX) |
if (sp->opts->opts & TBL_OPT_DBOX) |
Line 189 term_tbl(struct termp *tp, const struct tbl_span *sp) |
|
Line 205 term_tbl(struct termp *tp, const struct tbl_span *sp) |
|
assert(tp->tbl.cols); |
assert(tp->tbl.cols); |
free(tp->tbl.cols); |
free(tp->tbl.cols); |
tp->tbl.cols = NULL; |
tp->tbl.cols = NULL; |
|
tp->offset = offset; |
} |
} |
|
|
tp->flags &= ~TERMP_NONOSPACE; |
tp->flags &= ~TERMP_NONOSPACE; |
tp->rmargin = rmargin; |
tp->rmargin = rmargin; |
tp->maxrmargin = maxrmargin; |
tp->maxrmargin = maxrmargin; |
|
|
} |
} |
|
|
/* |
/* |
Line 246 tbl_data(struct termp *tp, const struct tbl_opts *opts |
|
Line 262 tbl_data(struct termp *tp, const struct tbl_opts *opts |
|
const struct roffcol *col) |
const struct roffcol *col) |
{ |
{ |
|
|
if (NULL == dp) { |
if (dp == NULL) { |
tbl_char(tp, ASCII_NBRSP, col->width); |
tbl_char(tp, ASCII_NBRSP, col->width); |
return; |
return; |
} |
} |
assert(dp->layout); |
|
|
|
switch (dp->pos) { |
switch (dp->pos) { |
case TBL_DATA_NONE: |
case TBL_DATA_NONE: |
Line 380 tbl_number(struct termp *tp, const struct tbl_opts *op |
|
Line 395 tbl_number(struct termp *tp, const struct tbl_opts *op |
|
|
|
psz = term_strlen(tp, buf); |
psz = term_strlen(tp, buf); |
|
|
if (NULL != (cp = strrchr(dp->string, opts->decimal))) { |
if ((cp = strrchr(dp->string, opts->decimal)) != NULL) { |
buf[1] = '\0'; |
|
for (ssz = 0, i = 0; cp != &dp->string[i]; i++) { |
for (ssz = 0, i = 0; cp != &dp->string[i]; i++) { |
buf[0] = dp->string[i]; |
buf[0] = dp->string[i]; |
ssz += term_strlen(tp, buf); |
ssz += term_strlen(tp, buf); |