Lines Matching defs:p
35 static void adjbuf(struct termp *p, size_t);
42 term_free(struct termp *p)
45 free(p->buf);
46 free(p->fontq);
47 free(p);
51 term_begin(struct termp *p, term_margin head,
55 p->headf = head;
56 p->footf = foot;
57 p->argf = arg;
58 (*p->begin)(p);
62 term_end(struct termp *p)
65 (*p->end)(p);
78 * the next column. However, if less than p->trailspace blanks,
92 term_flushln(struct termp *p)
94 size_t i; /* current input position in p->buf */
101 size_t j; /* temporary loop index for p->buf */
112 * but they are actually correct. If the int p->overstep
116 dv = p->rmargin > p->offset ? p->rmargin - p->offset : 0;
117 maxvis = (int)dv > p->overstep ? dv - (size_t)p->overstep : 0;
119 if (p->flags & TERMP_NOBREAK) {
120 dv = p->maxrmargin > p->offset ?
121 p->maxrmargin - p->offset : 0;
122 bp = (int)dv > p->overstep ?
123 dv - (size_t)p->overstep : 0;
130 vbl = p->offset + p->overstep > p->viscol ?
131 p->offset + p->overstep - p->viscol : 0;
136 while (i < p->col) {
142 while (i < p->col && '\t' == p->buf[i]) {
143 vend = (vis / p->tabwidth + 1) * p->tabwidth;
157 for (j = i, jhy = 0; j < p->col; j++) {
158 if (' ' == p->buf[j] || '\t' == p->buf[j])
162 if (8 == p->buf[j]) {
164 vend -= (*p->width)(p, p->buf[j - 1]);
171 (ASCII_HYPH == p->buf[j] ||
172 ASCII_BREAK == p->buf[j]))
179 if (ASCII_HYPH == p->buf[j])
180 p->buf[j] = '-';
182 vend += (*p->width)(p, p->buf[j]);
191 (*p->endline)(p);
192 p->viscol = 0;
193 if (TERMP_BRIND & p->flags) {
194 vbl = p->rmargin;
195 vend += p->rmargin;
196 vend -= p->offset;
198 vbl = p->offset;
203 vbl += ntab * p->tabwidth;
206 * Remove the p->overstep width.
207 * Again, if p->overstep is negative,
211 bp += (size_t)p->overstep;
212 p->overstep = 0;
216 for ( ; i < p->col; i++) {
219 if ('\t' == p->buf[i])
221 if (' ' == p->buf[i]) {
223 while (i < p->col && ' ' == p->buf[i])
225 dv = (i - j) * (*p->width)(p, ' ');
230 if (ASCII_NBRSP == p->buf[i]) {
231 vbl += (*p->width)(p, ' ');
234 if (ASCII_BREAK == p->buf[i])
243 (*p->advance)(p, vbl);
244 p->viscol += vbl;
248 (*p->letter)(p, p->buf[i]);
249 if (8 == p->buf[i])
250 p->viscol -= (*p->width)(p, p->buf[i-1]);
252 p->viscol += (*p->width)(p, p->buf[i]);
266 p->col = 0;
267 p->overstep = 0;
269 if ( ! (TERMP_NOBREAK & p->flags)) {
270 p->viscol = 0;
271 (*p->endline)(p);
275 if (TERMP_HANG & p->flags) {
276 p->overstep += (int)(p->offset + vis - p->rmargin +
277 p->trailspace * (*p->width)(p, ' '));
286 if (p->trailspace && p->overstep < 0)
287 p->overstep = 0;
290 } else if (TERMP_DANGLE & p->flags)
294 if (maxvis < vis + p->trailspace * (*p->width)(p, ' ')) {
295 (*p->endline)(p);
296 p->viscol = 0;
306 term_newln(struct termp *p)
309 p->flags |= TERMP_NOSPACE;
310 if (p->col || p->viscol)
311 term_flushln(p);
321 term_vspace(struct termp *p)
324 term_newln(p);
325 p->viscol = 0;
326 if (0 < p->skipvsp)
327 p->skipvsp--;
329 (*p->endline)(p);
334 term_fontlast(struct termp *p)
338 f = p->fontl;
339 p->fontl = p->fontq[p->fonti];
340 p->fontq[p->fonti] = f;
345 term_fontrepl(struct termp *p, enum termfont f)
348 p->fontl = p->fontq[p->fonti];
349 p->fontq[p->fonti] = f;
354 term_fontpush(struct termp *p, enum termfont f)
357 p->fontl = p->fontq[p->fonti];
358 if (++p->fonti == p->fontsz) {
359 p->fontsz += 8;
360 p->fontq = mandoc_reallocarray(p->fontq,
361 p->fontsz, sizeof(enum termfont *));
363 p->fontq[p->fonti] = f;
368 term_fontpopq(struct termp *p, int i)
372 if (p->fonti > i)
373 p->fonti = i;
378 term_fontpop(struct termp *p)
381 assert(p->fonti);
382 p->fonti--;
391 term_word(struct termp *p, const char *word)
399 if ( ! (TERMP_NOSPACE & p->flags)) {
400 if ( ! (TERMP_KEEP & p->flags)) {
401 bufferc(p, ' ');
402 if (TERMP_SENTENCE & p->flags)
403 bufferc(p, ' ');
405 bufferc(p, ASCII_NBRSP);
407 if (TERMP_PREKEEP & p->flags)
408 p->flags |= TERMP_KEEP;
410 if ( ! (p->flags & TERMP_NONOSPACE))
411 p->flags &= ~TERMP_NOSPACE;
413 p->flags |= TERMP_NOSPACE;
415 p->flags &= ~(TERMP_SENTENCE | TERMP_NONEWLINE);
416 p->skipvsp = 0;
420 if (TERMP_SKIPCHAR & p->flags) {
421 p->flags &= ~TERMP_SKIPCHAR;
425 if (TERMP_NBRWORD & p->flags) {
427 encode(p, nbrsp, 1);
434 encode(p, word, ssz);
454 if (p->enc == TERMENC_ASCII) {
455 cp = mchars_spec2str(p->symtab,
458 encode(p, cp, ssz);
460 uc = mchars_spec2cp(p->symtab, seq, sz);
462 encode1(p, uc);
466 term_fontrepl(p, TERMFONT_BOLD);
469 term_fontrepl(p, TERMFONT_UNDER);
472 term_fontrepl(p, TERMFONT_BI);
477 term_fontrepl(p, TERMFONT_NONE);
480 term_fontlast(p);
483 if (TERMP_SKIPCHAR & p->flags)
484 p->flags &= ~TERMP_SKIPCHAR;
486 p->flags |= (TERMP_NOSPACE | TERMP_NONEWLINE);
489 p->flags |= TERMP_SKIPCHAR;
498 encode1(p, *seq++);
500 encode(p, "\b", 1);
511 if (p->enc == TERMENC_ASCII) {
513 encode(p, cp, strlen(cp));
518 encode1(p, uc);
521 p->flags &= ~TERMP_NBRWORD;
525 adjbuf(struct termp *p, size_t sz)
528 if (0 == p->maxcols)
529 p->maxcols = 1024;
530 while (sz >= p->maxcols)
531 p->maxcols <<= 2;
533 p->buf = mandoc_reallocarray(p->buf, p->maxcols, sizeof(int));
537 bufferc(struct termp *p, char c)
540 if (p->col + 1 >= p->maxcols)
541 adjbuf(p, p->col + 1);
543 p->buf[p->col++] = c;
552 encode1(struct termp *p, int c)
556 if (TERMP_SKIPCHAR & p->flags) {
557 p->flags &= ~TERMP_SKIPCHAR;
561 if (p->col + 6 >= p->maxcols)
562 adjbuf(p, p->col + 6);
564 f = p->fontq[p->fonti];
567 p->buf[p->col++] = '_';
568 p->buf[p->col++] = 8;
572 p->buf[p->col++] = '-';
574 p->buf[p->col++] = c;
575 p->buf[p->col++] = 8;
577 p->buf[p->col++] = c;
581 encode(struct termp *p, const char *word, size_t sz)
585 if (TERMP_SKIPCHAR & p->flags) {
586 p->flags &= ~TERMP_SKIPCHAR;
596 if (p->fontq[p->fonti] == TERMFONT_NONE) {
597 if (p->col + sz >= p->maxcols)
598 adjbuf(p, p->col + sz);
600 p->buf[p->col++] = word[i];
606 if (p->col + 1 + (sz * 5) >= p->maxcols)
607 adjbuf(p, p->col + 1 + (sz * 5));
612 encode1(p, word[i]);
614 p->buf[p->col++] = word[i];
619 term_setwidth(struct termp *p, const char *wstr)
641 width = term_hspan(p, &su);
645 (*p->setwidth)(p, iop, width);
649 term_len(const struct termp *p, size_t sz)
652 return((*p->width)(p, ' ') * sz);
656 cond_width(const struct termp *p, int c, int *skip)
663 return((*p->width)(p, c));
667 term_strlen(const struct termp *p, const char *cp)
687 sz += cond_width(p, *cp++, &skip);
708 if (p->enc == TERMENC_ASCII) {
709 rhs = mchars_spec2str(p->symtab,
714 uc = mchars_spec2cp(p->symtab,
717 sz += cond_width(p, uc, &skip);
731 i = (*p->width)(p, *seq++);
747 if (p->enc == TERMENC_ASCII) {
754 sz += cond_width(p, uc, &skip);
770 sz += (*p->width)(p, *rhs++);
773 sz += cond_width(p, ' ', &skip);
777 sz += cond_width(p, '-', &skip);
791 term_vspan(const struct termp *p, const struct roffsu *su)
835 term_hspan(const struct termp *p, const struct roffsu *su)
839 v = (*p->hspan)(p, su);