Lines Matching defs:tp

156 term_tbl(struct termp *tp, const struct tbl_span *sp)
180 tp->flags |= TERMP_NOSPACE | TERMP_NONOSPACE;
181 save_offset = tp->tcol->offset;
182 enw = term_len(tp, 1);
189 if (tp->tbl.cols == NULL) {
190 borders_locale = tp->enc == TERMENC_UTF8 ?
193 tp->tbl.len = term_tbl_len;
194 tp->tbl.slen = term_tbl_strlen;
195 tp->tbl.arg = tp;
197 tblcalc(&tp->tbl, sp, tp->tcol->offset, tp->tcol->rmargin);
201 offset = tp->tcol->offset;
216 tsz = term_len(tp,
223 tsz += tp->tbl.cols[ic].width +
224 term_len(tp, tp->tbl.cols[ic].spacing);
226 tsz += tp->tbl.cols[sp->opts->cols - 1].width;
228 if (offset + tsz > tp->tcol->rmargin)
230 offset = offset + tp->tcol->rmargin > tsz ?
231 ((offset + tp->tcol->rmargin - tsz) / enw / 2) *
233 tp->tcol->offset = offset;
238 if (tp->enc == TERMENC_ASCII &&
240 tbl_hrule(tp, NULL, sp, sp, TBL_OPT_DBOX);
242 tbl_hrule(tp, NULL, sp, sp, TBL_OPT_BOX);
247 tp->flags |= TERMP_MULTICOL;
248 tp->tcol->offset = offset;
254 term_setcol(tp, 1);
257 term_setcol(tp, sp->opts->cols + 2);
258 coloff = tp->tcol->offset;
265 tp->tcol->rmargin = coloff;
273 tp->tcol++;
274 tp->tcol->offset = coloff;
276 coloff += tp->tbl.cols[ic].width;
277 tp->tcol->rmargin = coloff;
279 coloff += term_len(tp,
280 tp->tbl.cols[ic].spacing);
294 tp->tcol++;
295 tp->tcol->offset = coloff + enw;
296 tp->tcol->rmargin = tp->maxrmargin;
300 tp->lasttcol = tp->tcol - tp->tcols;
304 tp->tcol = tp->tcols;
305 coloff = tp->tcols[1].offset;
318 tp->tcol++;
319 tp->col = 0;
320 tp->flags &= ~(TERMP_BACKAFTER | TERMP_BACKBEFORE);
321 tbl_data(tp, sp->opts, cp, dp, tp->tbl.cols + ic,
323 coloff += term_len(tp, tp->tbl.cols[ic].spacing);
336 tp->tcol = tp->tcols;
356 (*tp->advance)(tp, tp->tcols->offset);
357 tbl_direct_border(tp, fc, enw);
358 tbl_direct_border(tp, BHORIZ * rhori, enw);
365 tbl_hrule(tp, sp->prev, sp, sp->next, 0);
393 tp->flags |= TERMP_CENTER;
396 tp->flags |= TERMP_RIGHT;
400 tp->tcol->offset += enw;
433 tp->enc == TERMENC_UTF8))
469 tp->tcol++;
470 if (tp->tcol->col < tp->tcol->lastcol)
471 term_flushln(tp);
472 tp->flags &= ~(TERMP_CENTER | TERMP_RIGHT);
474 tp->tcol->offset -= enw;
475 if (tp->tcol->col < tp->tcol->lastcol)
487 tp->tcol + 1 ==
488 tp->tcols + tp->lasttcol)) {
494 if (tp->viscol < tp->tcol->rmargin)
495 (*tp->advance)(tp,
496 tp->tcol->rmargin - tp->viscol);
497 while (tp->viscol < tp->tcol->rmargin +
498 term_len(tp, tp->tbl.cols[ic].spacing / 2))
499 tbl_direct_border(tp,
502 if (tp->tcol + 1 == tp->tcols + tp->lasttcol)
517 if (tp->tbl.cols[ic].spacing)
518 tbl_direct_border(tp,
522 if (tp->enc == TERMENC_UTF8)
525 if (tp->tbl.cols[ic].spacing > 2 &&
527 tbl_direct_border(tp,
568 tp->tcol++;
569 if (tp->tcol->offset > tp->viscol)
570 tbl_direct_border(tp,
572 tp->tcol->offset - tp->viscol);
574 tbl_direct_border(tp, fc, enw);
576 (*tp->endline)(tp);
585 term_setcol(tp, 1);
586 tp->flags &= ~TERMP_MULTICOL;
587 tp->tcol->rmargin = tp->maxrmargin;
590 tbl_hrule(tp, sp, sp, NULL, TBL_OPT_BOX);
591 if (tp->enc == TERMENC_ASCII &&
593 tbl_hrule(tp, sp, sp, NULL, TBL_OPT_DBOX);
594 assert(tp->tbl.cols);
595 free(tp->tbl.cols);
596 tp->tbl.cols = NULL;
600 tbl_hrule(tp, sp, sp, sp->next, TBL_OPT_ALLBOX);
602 tp->tcol->offset = save_offset;
603 tp->flags &= ~TERMP_NONOSPACE;
607 tbl_hrule(struct termp *tp, const struct tbl_span *spp,
633 bw = opts & TBL_OPT_DBOX ? (tp->enc == TERMENC_UTF8 ? 2 : 1) :
640 enw = term_len(tp, 1);
641 if (tp->viscol == 0)
642 (*tp->advance)(tp, tp->tcols->offset);
644 tbl_direct_border(tp,
649 tbl_direct_border(tp,
654 col = tp->tbl.cols;
659 col = tp->tbl.cols + cp->col;
668 tbl_direct_border(tp, BHORIZ * lw,
669 col->width + term_len(tp, col->spacing / 2));
700 if (col + 1 == tp->tbl.cols + sp->opts->cols)
721 tbl_direct_border(tp, BLEFT * lw +
728 if (tp->enc != TERMENC_ASCII || (uw < 2 && dw < 2))
731 tbl_direct_border(tp,
737 tbl_direct_border(tp,
739 term_len(tp, (col->spacing - 3) / 2));
745 tbl_direct_border(tp,
751 (*tp->endline)(tp);
756 tbl_data(struct termp *tp, const struct tbl_opts *opts,
762 tbl_fill_border(tp, BHORIZ, coloff, col->width);
765 tbl_fill_border(tp, BHORIZ * 2, coloff, col->width);
779 tbl_fill_border(tp, BHORIZ, coloff, col->width);
783 tbl_fill_border(tp, BHORIZ * 2, coloff, col->width);
794 tbl_literal(tp, dp, col, coloff);
797 tbl_number(tp, opts, dp, col, coloff);
812 tbl_fill_string(struct termp *tp, const char *cp, size_t *coloff, size_t len)
819 sz = term_strlen(tp, cp);
820 target = tp->tcol->offset + len;
822 term_word(tp, cp);
832 tbl_fill_char(struct termp *tp, char c, size_t *coloff, size_t len)
838 tbl_fill_string(tp, cp, coloff, len);
846 tbl_fill_border(struct termp *tp, int c, size_t *coloff, size_t len)
852 tbl_fill_string(tp, buf, coloff, len);
854 tbl_fill_char(tp, c, coloff, len);
862 tbl_direct_border(struct termp *tp, int c, size_t len)
869 sz = (*tp->getwidth)(tp, c);
870 enw2 = (*tp->getwidth)(tp, ' ') / 2;
871 target = tp->viscol + len;
872 while (tp->viscol + enw2 < target) {
873 (*tp->letter)(tp, c);
874 tp->viscol += sz;
879 tbl_literal(struct termp *tp, const struct tbl_dat *dp,
890 width += term_len(tp, tp->tbl.cols[ic].spacing);
892 width += tp->tbl.cols[ic].width;
894 tbl_word(tp, dp);
899 tbl_number(struct termp *tp, const struct tbl_opts *opts,
934 totsz = term_strlen(tp, dp->string);
942 intsz += term_strlen(tp, buf);
961 tbl_fill_char(tp, ASCII_NBRSP, coloff, pad);
962 tbl_word(tp, dp);
967 tbl_word(struct termp *tp, const struct tbl_dat *dp)
971 prev_font = tp->fonti;
974 term_fontpush(tp, TERMFONT_BI);
978 term_fontpush(tp, TERMFONT_BOLD);
982 term_fontpush(tp, TERMFONT_UNDER);
991 term_word(tp, dp->string);
993 term_fontpopq(tp, prev_font);