Lines Matching refs:p

37 static	void		 adjbuf(struct termp *p, size_t);
43 term_free(struct termp *p) in term_free() argument
46 if (p->buf) in term_free()
47 free(p->buf); in term_free()
48 if (p->symtab) in term_free()
49 mchars_free(p->symtab); in term_free()
51 free(p); in term_free()
56 term_begin(struct termp *p, term_margin head, in term_begin() argument
60 p->headf = head; in term_begin()
61 p->footf = foot; in term_begin()
62 p->argf = arg; in term_begin()
63 (*p->begin)(p); in term_begin()
68 term_end(struct termp *p) in term_end() argument
71 (*p->end)(p); in term_end()
105 term_flushln(struct termp *p) in term_flushln() argument
130 assert (p->rmargin >= p->offset); in term_flushln()
131 dv = p->rmargin - p->offset; in term_flushln()
132 maxvis = (int)dv > p->overstep ? dv - (size_t)p->overstep : 0; in term_flushln()
133 dv = p->maxrmargin - p->offset; in term_flushln()
134 mmax = (int)dv > p->overstep ? dv - (size_t)p->overstep : 0; in term_flushln()
136 bp = TERMP_NOBREAK & p->flags ? mmax : maxvis; in term_flushln()
141 vbl = p->offset + p->overstep > p->viscol ? in term_flushln()
142 p->offset + p->overstep - p->viscol : 0; in term_flushln()
147 while (i < p->col) { in term_flushln()
153 while (i < p->col && '\t' == p->buf[i]) { in term_flushln()
154 vend = (vis / p->tabwidth + 1) * p->tabwidth; in term_flushln()
168 for (j = i, jhy = 0; j < p->col; j++) { in term_flushln()
169 if (' ' == p->buf[j] || '\t' == p->buf[j]) in term_flushln()
173 if (8 == p->buf[j]) { in term_flushln()
175 vend -= (*p->width)(p, p->buf[j - 1]); in term_flushln()
182 ASCII_HYPH == p->buf[j]) in term_flushln()
185 vend += (*p->width)(p, p->buf[j]); in term_flushln()
194 (*p->endline)(p); in term_flushln()
195 p->viscol = 0; in term_flushln()
196 if (TERMP_NOBREAK & p->flags) { in term_flushln()
197 vbl = p->rmargin; in term_flushln()
198 vend += p->rmargin - p->offset; in term_flushln()
200 vbl = p->offset; in term_flushln()
205 vbl += ntab * p->tabwidth; in term_flushln()
213 bp += (size_t)p->overstep; in term_flushln()
214 p->overstep = 0; in term_flushln()
218 for ( ; i < p->col; i++) { in term_flushln()
221 if ('\t' == p->buf[i]) in term_flushln()
223 if (' ' == p->buf[i]) { in term_flushln()
225 while (' ' == p->buf[i]) in term_flushln()
227 dv = (i - j) * (*p->width)(p, ' '); in term_flushln()
232 if (ASCII_NBRSP == p->buf[i]) { in term_flushln()
233 vbl += (*p->width)(p, ' '); in term_flushln()
243 (*p->advance)(p, vbl); in term_flushln()
244 p->viscol += vbl; in term_flushln()
248 if (ASCII_HYPH == p->buf[i]) { in term_flushln()
249 (*p->letter)(p, '-'); in term_flushln()
250 p->viscol += (*p->width)(p, '-'); in term_flushln()
254 (*p->letter)(p, p->buf[i]); in term_flushln()
255 if (8 == p->buf[i]) in term_flushln()
256 p->viscol -= (*p->width)(p, p->buf[i-1]); in term_flushln()
258 p->viscol += (*p->width)(p, p->buf[i]); in term_flushln()
270 p->col = 0; in term_flushln()
271 p->overstep = 0; in term_flushln()
273 if ( ! (TERMP_NOBREAK & p->flags)) { in term_flushln()
274 p->viscol = 0; in term_flushln()
275 (*p->endline)(p); in term_flushln()
279 if (TERMP_HANG & p->flags) { in term_flushln()
280 p->overstep = (int)(vis - maxvis + in term_flushln()
281 p->trailspace * (*p->width)(p, ' ')); in term_flushln()
290 if (p->trailspace && p->overstep < 0) in term_flushln()
291 p->overstep = 0; in term_flushln()
294 } else if (TERMP_DANGLE & p->flags) in term_flushln()
298 if (maxvis < vis + p->trailspace * (*p->width)(p, ' ')) { in term_flushln()
299 (*p->endline)(p); in term_flushln()
300 p->viscol = 0; in term_flushln()
311 term_newln(struct termp *p) in term_newln() argument
314 p->flags |= TERMP_NOSPACE; in term_newln()
315 if (p->col || p->viscol) in term_newln()
316 term_flushln(p); in term_newln()
327 term_vspace(struct termp *p) in term_vspace() argument
330 term_newln(p); in term_vspace()
331 p->viscol = 0; in term_vspace()
332 if (0 < p->skipvsp) in term_vspace()
333 p->skipvsp--; in term_vspace()
335 (*p->endline)(p); in term_vspace()
339 term_fontlast(struct termp *p) in term_fontlast() argument
343 f = p->fontl; in term_fontlast()
344 p->fontl = p->fontq[p->fonti]; in term_fontlast()
345 p->fontq[p->fonti] = f; in term_fontlast()
350 term_fontrepl(struct termp *p, enum termfont f) in term_fontrepl() argument
353 p->fontl = p->fontq[p->fonti]; in term_fontrepl()
354 p->fontq[p->fonti] = f; in term_fontrepl()
359 term_fontpush(struct termp *p, enum termfont f) in term_fontpush() argument
362 assert(p->fonti + 1 < 10); in term_fontpush()
363 p->fontl = p->fontq[p->fonti]; in term_fontpush()
364 p->fontq[++p->fonti] = f; in term_fontpush()
369 term_fontq(struct termp *p) in term_fontq() argument
372 return(&p->fontq[p->fonti]); in term_fontq()
377 term_fonttop(struct termp *p) in term_fonttop() argument
380 return(p->fontq[p->fonti]); in term_fonttop()
385 term_fontpopq(struct termp *p, const void *key) in term_fontpopq() argument
388 while (p->fonti >= 0 && key < (void *)(p->fontq + p->fonti)) in term_fontpopq()
389 p->fonti--; in term_fontpopq()
390 assert(p->fonti >= 0); in term_fontpopq()
395 term_fontpop(struct termp *p) in term_fontpop() argument
398 assert(p->fonti); in term_fontpop()
399 p->fonti--; in term_fontpop()
408 term_word(struct termp *p, const char *word) in term_word() argument
417 if ( ! (TERMP_NOSPACE & p->flags)) { in term_word()
418 if ( ! (TERMP_KEEP & p->flags)) { in term_word()
419 bufferc(p, ' '); in term_word()
420 if (TERMP_SENTENCE & p->flags) in term_word()
421 bufferc(p, ' '); in term_word()
423 bufferc(p, ASCII_NBRSP); in term_word()
425 if (TERMP_PREKEEP & p->flags) in term_word()
426 p->flags |= TERMP_KEEP; in term_word()
428 if ( ! (p->flags & TERMP_NONOSPACE)) in term_word()
429 p->flags &= ~TERMP_NOSPACE; in term_word()
431 p->flags |= TERMP_NOSPACE; in term_word()
433 p->flags &= ~TERMP_SENTENCE; in term_word()
437 if (TERMP_SKIPCHAR & p->flags) { in term_word()
438 p->flags &= ~TERMP_SKIPCHAR; in term_word()
442 if (TERMP_NBRWORD & p->flags) { in term_word()
444 encode(p, nbrsp, 1); in term_word()
451 encode(p, word, ssz); in term_word()
461 if (TERMENC_ASCII != p->enc) in term_word()
467 encode1(p, uc); in term_word()
470 uc = mchars_spec2cp(p->symtab, seq, sz); in term_word()
473 encode1(p, uc); in term_word()
481 encode1(p, '?'); in term_word()
486 encode(p, &c, 1); in term_word()
489 cp = mchars_spec2str(p->symtab, seq, sz, &ssz); in term_word()
491 encode(p, cp, ssz); in term_word()
493 encode(p, seq, sz); in term_word()
496 term_fontrepl(p, TERMFONT_BOLD); in term_word()
499 term_fontrepl(p, TERMFONT_UNDER); in term_word()
502 term_fontrepl(p, TERMFONT_BI); in term_word()
507 term_fontrepl(p, TERMFONT_NONE); in term_word()
510 term_fontlast(p); in term_word()
513 if (TERMP_SKIPCHAR & p->flags) in term_word()
514 p->flags &= ~TERMP_SKIPCHAR; in term_word()
516 p->flags |= TERMP_NOSPACE; in term_word()
519 p->flags |= TERMP_SKIPCHAR; in term_word()
525 p->flags &= ~TERMP_NBRWORD; in term_word()
529 adjbuf(struct termp *p, size_t sz) in adjbuf() argument
532 if (0 == p->maxcols) in adjbuf()
533 p->maxcols = 1024; in adjbuf()
534 while (sz >= p->maxcols) in adjbuf()
535 p->maxcols <<= 2; in adjbuf()
537 p->buf = mandoc_realloc(p->buf, sizeof(int) * p->maxcols); in adjbuf()
541 bufferc(struct termp *p, char c) in bufferc() argument
544 if (p->col + 1 >= p->maxcols) in bufferc()
545 adjbuf(p, p->col + 1); in bufferc()
547 p->buf[p->col++] = c; in bufferc()
556 encode1(struct termp *p, int c) in encode1() argument
560 if (TERMP_SKIPCHAR & p->flags) { in encode1()
561 p->flags &= ~TERMP_SKIPCHAR; in encode1()
565 if (p->col + 6 >= p->maxcols) in encode1()
566 adjbuf(p, p->col + 6); in encode1()
568 f = term_fonttop(p); in encode1()
571 p->buf[p->col++] = '_'; in encode1()
572 p->buf[p->col++] = 8; in encode1()
576 p->buf[p->col++] = '-'; in encode1()
578 p->buf[p->col++] = c; in encode1()
579 p->buf[p->col++] = 8; in encode1()
581 p->buf[p->col++] = c; in encode1()
585 encode(struct termp *p, const char *word, size_t sz) in encode() argument
589 if (TERMP_SKIPCHAR & p->flags) { in encode()
590 p->flags &= ~TERMP_SKIPCHAR; in encode()
600 if (TERMFONT_NONE == term_fonttop(p)) { in encode()
601 if (p->col + sz >= p->maxcols) in encode()
602 adjbuf(p, p->col + sz); in encode()
604 p->buf[p->col++] = word[i]; in encode()
610 if (p->col + 1 + (sz * 5) >= p->maxcols) in encode()
611 adjbuf(p, p->col + 1 + (sz * 5)); in encode()
616 encode1(p, word[i]); in encode()
618 p->buf[p->col++] = word[i]; in encode()
623 term_len(const struct termp *p, size_t sz) in term_len() argument
626 return((*p->width)(p, ' ') * sz); in term_len()
630 cond_width(const struct termp *p, int c, int *skip) in cond_width() argument
637 return((*p->width)(p, c)); in cond_width()
641 term_strlen(const struct termp *p, const char *cp) in term_strlen() argument
660 sz += cond_width(p, *cp++, &skip); in term_strlen()
670 if (TERMENC_ASCII != p->enc) in term_strlen()
677 sz += cond_width(p, c, &skip); in term_strlen()
681 (p->symtab, seq, ssz); in term_strlen()
684 sz += cond_width(p, c, &skip); in term_strlen()
694 sz += cond_width(p, '?', &skip); in term_strlen()
699 sz += cond_width(p, c, &skip); in term_strlen()
703 (p->symtab, seq, ssz, &rsz); in term_strlen()
727 sz += (*p->width)(p, *rhs++); in term_strlen()
730 sz += cond_width(p, ' ', &skip); in term_strlen()
734 sz += cond_width(p, '-', &skip); in term_strlen()
747 term_vspan(const struct termp *p, const struct roffsu *su) in term_vspan() argument
782 term_hspan(const struct termp *p, const struct roffsu *su) in term_hspan() argument
786 v = ((*p->hspan)(p, su)); in term_hspan()