Lines Matching refs:tp
162 term_tbl(struct termp *tp, const struct tbl_span *sp) in term_tbl() argument
174 tp->flags |= TERMP_NOSPACE | TERMP_NONOSPACE; in term_tbl()
175 save_offset = tp->tcol->offset; in term_tbl()
182 if (tp->tbl.cols == NULL) { in term_tbl()
183 borders_locale = tp->enc == TERMENC_UTF8 ? in term_tbl()
186 tp->tbl.len = term_tbl_len; in term_tbl()
187 tp->tbl.slen = term_tbl_strlen; in term_tbl()
188 tp->tbl.sulen = term_tbl_sulen; in term_tbl()
189 tp->tbl.arg = tp; in term_tbl()
191 tblcalc(&tp->tbl, sp, tp->tcol->offset, tp->tcol->rmargin); in term_tbl()
195 offset = tp->tcol->offset; in term_tbl()
200 tsz += tp->tbl.cols[ic].width + in term_tbl()
201 tp->tbl.cols[ic].spacing; in term_tbl()
203 tsz += tp->tbl.cols[sp->opts->cols - 1].width; in term_tbl()
204 if (offset + tsz > tp->tcol->rmargin) in term_tbl()
206 offset = offset + tp->tcol->rmargin > tsz ? in term_tbl()
207 (offset + tp->tcol->rmargin - tsz) / 2 : 0; in term_tbl()
208 tp->tcol->offset = offset; in term_tbl()
213 if (tp->enc == TERMENC_ASCII && in term_tbl()
215 tbl_hrule(tp, NULL, sp, sp, TBL_OPT_DBOX); in term_tbl()
217 tbl_hrule(tp, NULL, sp, sp, TBL_OPT_BOX); in term_tbl()
222 tp->flags |= TERMP_MULTICOL; in term_tbl()
223 tp->tcol->offset = offset; in term_tbl()
229 term_setcol(tp, 1); in term_tbl()
232 term_setcol(tp, sp->opts->cols + 2); in term_tbl()
233 coloff = tp->tcol->offset; in term_tbl()
240 tp->tcol->rmargin = coloff; in term_tbl()
248 tp->tcol++; in term_tbl()
249 tp->tcol->offset = coloff; in term_tbl()
251 coloff += tp->tbl.cols[ic].width; in term_tbl()
252 tp->tcol->rmargin = coloff; in term_tbl()
254 coloff += tp->tbl.cols[ic].spacing; in term_tbl()
268 tp->tcol++; in term_tbl()
269 tp->tcol->offset = coloff + 1; in term_tbl()
270 tp->tcol->rmargin = tp->maxrmargin; in term_tbl()
274 tp->lasttcol = tp->tcol - tp->tcols; in term_tbl()
278 tp->tcol = tp->tcols; in term_tbl()
291 tp->tcol++; in term_tbl()
292 tp->col = 0; in term_tbl()
293 tbl_data(tp, sp->opts, cp, dp, tp->tbl.cols + ic); in term_tbl()
306 tp->tcol = tp->tcols; in term_tbl()
326 (*tp->advance)(tp, tp->tcols->offset); in term_tbl()
327 tp->viscol = tp->tcol->offset; in term_tbl()
328 tbl_direct_border(tp, fc, 1); in term_tbl()
335 tbl_hrule(tp, sp->prev, sp, sp->next, 0); in term_tbl()
392 tp->enc == TERMENC_UTF8)) in term_tbl()
428 tp->tcol++; in term_tbl()
429 if (tp->tcol->col < tp->tcol->lastcol) in term_tbl()
430 term_flushln(tp); in term_tbl()
431 if (tp->tcol->col < tp->tcol->lastcol) in term_tbl()
443 tp->tcol + 1 == in term_tbl()
444 tp->tcols + tp->lasttcol)) { in term_tbl()
450 if (tp->viscol < tp->tcol->rmargin) { in term_tbl()
451 (*tp->advance)(tp, tp->tcol->rmargin in term_tbl()
452 - tp->viscol); in term_tbl()
453 tp->viscol = tp->tcol->rmargin; in term_tbl()
455 while (tp->viscol < tp->tcol->rmargin + in term_tbl()
456 tp->tbl.cols[ic].spacing / 2) in term_tbl()
457 tbl_direct_border(tp, in term_tbl()
460 if (tp->tcol + 1 == tp->tcols + tp->lasttcol) in term_tbl()
475 if (tp->tbl.cols[ic].spacing) in term_tbl()
476 tbl_direct_border(tp, in term_tbl()
480 if (tp->enc == TERMENC_UTF8) in term_tbl()
483 if (tp->tbl.cols[ic].spacing > 2 && in term_tbl()
485 tbl_direct_border(tp, in term_tbl()
526 tp->tcol++; in term_tbl()
528 tbl_direct_border(tp, in term_tbl()
530 } while (tp->viscol < tp->tcol->offset); in term_tbl()
532 tbl_direct_border(tp, fc, 1); in term_tbl()
534 (*tp->endline)(tp); in term_tbl()
535 tp->viscol = 0; in term_tbl()
544 term_setcol(tp, 1); in term_tbl()
545 tp->flags &= ~TERMP_MULTICOL; in term_tbl()
546 tp->tcol->rmargin = tp->maxrmargin; in term_tbl()
549 tbl_hrule(tp, sp, sp, NULL, TBL_OPT_BOX); in term_tbl()
550 tp->skipvsp = 1; in term_tbl()
552 if (tp->enc == TERMENC_ASCII && in term_tbl()
554 tbl_hrule(tp, sp, sp, NULL, TBL_OPT_DBOX); in term_tbl()
555 tp->skipvsp = 2; in term_tbl()
557 assert(tp->tbl.cols); in term_tbl()
558 free(tp->tbl.cols); in term_tbl()
559 tp->tbl.cols = NULL; in term_tbl()
563 tbl_hrule(tp, sp, sp, sp->next, TBL_OPT_ALLBOX); in term_tbl()
565 tp->tcol->offset = save_offset; in term_tbl()
566 tp->flags &= ~TERMP_NONOSPACE; in term_tbl()
570 tbl_hrule(struct termp *tp, const struct tbl_span *spp, in tbl_hrule() argument
595 bw = opts & TBL_OPT_DBOX ? (tp->enc == TERMENC_UTF8 ? 2 : 1) : in tbl_hrule()
602 if (tp->viscol == 0) { in tbl_hrule()
603 (*tp->advance)(tp, tp->tcols->offset); in tbl_hrule()
604 tp->viscol = tp->tcols->offset; in tbl_hrule()
607 tbl_direct_border(tp, in tbl_hrule()
613 col = tp->tbl.cols; in tbl_hrule()
618 col = tp->tbl.cols + cp->col; in tbl_hrule()
627 tbl_direct_border(tp, BHORIZ * lw, in tbl_hrule()
659 if (col + 1 == tp->tbl.cols + sp->opts->cols) in tbl_hrule()
680 tbl_direct_border(tp, BLEFT * lw + in tbl_hrule()
687 if (tp->enc != TERMENC_ASCII || (uw < 2 && dw < 2)) in tbl_hrule()
690 tbl_direct_border(tp, in tbl_hrule()
696 tbl_direct_border(tp, in tbl_hrule()
703 tbl_direct_border(tp, in tbl_hrule()
709 (*tp->endline)(tp); in tbl_hrule()
710 tp->viscol = 0; in tbl_hrule()
715 tbl_data(struct termp *tp, const struct tbl_opts *opts, in tbl_data() argument
721 tbl_fill_border(tp, BHORIZ, col->width); in tbl_data()
724 tbl_fill_border(tp, BHORIZ * 2, col->width); in tbl_data()
738 tbl_fill_border(tp, BHORIZ, col->width); in tbl_data()
742 tbl_fill_border(tp, BHORIZ * 2, col->width); in tbl_data()
753 tbl_literal(tp, dp, col); in tbl_data()
756 tbl_number(tp, opts, dp, col); in tbl_data()
767 tbl_fill_string(struct termp *tp, const char *cp, size_t len) in tbl_fill_string() argument
771 sz = term_strlen(tp, cp); in tbl_fill_string()
773 term_word(tp, cp); in tbl_fill_string()
777 tbl_fill_char(struct termp *tp, char c, size_t len) in tbl_fill_char() argument
783 tbl_fill_string(tp, cp, len); in tbl_fill_char()
787 tbl_fill_border(struct termp *tp, int c, size_t len) in tbl_fill_border() argument
793 tbl_fill_string(tp, buf, len); in tbl_fill_border()
795 tbl_fill_char(tp, c, len); in tbl_fill_border()
799 tbl_direct_border(struct termp *tp, int c, size_t len) in tbl_direct_border() argument
804 sz = (*tp->width)(tp, c); in tbl_direct_border()
806 (*tp->letter)(tp, c); in tbl_direct_border()
807 tp->viscol += sz; in tbl_direct_border()
812 tbl_literal(struct termp *tp, const struct tbl_dat *dp, in tbl_literal() argument
819 len = term_strlen(tp, dp->string); in tbl_literal()
824 width += tp->tbl.cols[++ic].width + 3; in tbl_literal()
831 padl = term_len(tp, 1); in tbl_literal()
848 tbl_fill_char(tp, ASCII_NBRSP, padl); in tbl_literal()
849 tbl_word(tp, dp); in tbl_literal()
850 tbl_fill_char(tp, ASCII_NBRSP, padr); in tbl_literal()
854 tbl_number(struct termp *tp, const struct tbl_opts *opts, in tbl_number() argument
884 totsz = term_strlen(tp, dp->string); in tbl_number()
892 intsz += term_strlen(tp, buf); in tbl_number()
911 tbl_fill_char(tp, ASCII_NBRSP, padl); in tbl_number()
912 tbl_word(tp, dp); in tbl_number()
917 tbl_fill_char(tp, ASCII_NBRSP, col->width - padl - totsz); in tbl_number()
921 tbl_word(struct termp *tp, const struct tbl_dat *dp) in tbl_word() argument
925 prev_font = tp->fonti; in tbl_word()
928 term_fontpush(tp, TERMFONT_BI); in tbl_word()
932 term_fontpush(tp, TERMFONT_BOLD); in tbl_word()
936 term_fontpush(tp, TERMFONT_UNDER); in tbl_word()
945 term_word(tp, dp->string); in tbl_word()
947 term_fontpopq(tp, prev_font); in tbl_word()