man_term.c (316420) | man_term.c (322249) |
---|---|
1/* $Id: man_term.c,v 1.188 2017/01/10 13:47:00 schwarze Exp $ */ | 1/* $Id: man_term.c,v 1.208 2017/06/25 11:42:02 schwarze Exp $ */ |
2/* 3 * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> | 2/* 3 * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> |
4 * Copyright (c) 2010-2015 Ingo Schwarze | 4 * Copyright (c) 2010-2015, 2017 Ingo Schwarze <schwarze@openbsd.org> |
5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR --- 50 unchanged lines hidden (view full) --- 63static void print_man_head(struct termp *, 64 const struct roff_meta *); 65static void print_man_foot(struct termp *, 66 const struct roff_meta *); 67static void print_bvspace(struct termp *, 68 const struct roff_node *, int); 69 70static int pre_B(DECL_ARGS); | 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR --- 50 unchanged lines hidden (view full) --- 63static void print_man_head(struct termp *, 64 const struct roff_meta *); 65static void print_man_foot(struct termp *, 66 const struct roff_meta *); 67static void print_bvspace(struct termp *, 68 const struct roff_node *, int); 69 70static int pre_B(DECL_ARGS); |
71static int pre_DT(DECL_ARGS); |
|
71static int pre_HP(DECL_ARGS); 72static int pre_I(DECL_ARGS); 73static int pre_IP(DECL_ARGS); 74static int pre_OP(DECL_ARGS); 75static int pre_PD(DECL_ARGS); 76static int pre_PP(DECL_ARGS); 77static int pre_RS(DECL_ARGS); 78static int pre_SH(DECL_ARGS); 79static int pre_SS(DECL_ARGS); 80static int pre_TP(DECL_ARGS); 81static int pre_UR(DECL_ARGS); 82static int pre_alternate(DECL_ARGS); | 72static int pre_HP(DECL_ARGS); 73static int pre_I(DECL_ARGS); 74static int pre_IP(DECL_ARGS); 75static int pre_OP(DECL_ARGS); 76static int pre_PD(DECL_ARGS); 77static int pre_PP(DECL_ARGS); 78static int pre_RS(DECL_ARGS); 79static int pre_SH(DECL_ARGS); 80static int pre_SS(DECL_ARGS); 81static int pre_TP(DECL_ARGS); 82static int pre_UR(DECL_ARGS); 83static int pre_alternate(DECL_ARGS); |
83static int pre_ft(DECL_ARGS); | |
84static int pre_ign(DECL_ARGS); 85static int pre_in(DECL_ARGS); 86static int pre_literal(DECL_ARGS); | 84static int pre_ign(DECL_ARGS); 85static int pre_in(DECL_ARGS); 86static int pre_literal(DECL_ARGS); |
87static int pre_ll(DECL_ARGS); 88static int pre_sp(DECL_ARGS); | |
89 90static void post_IP(DECL_ARGS); 91static void post_HP(DECL_ARGS); 92static void post_RS(DECL_ARGS); 93static void post_SH(DECL_ARGS); 94static void post_SS(DECL_ARGS); 95static void post_TP(DECL_ARGS); 96static void post_UR(DECL_ARGS); 97 | 87 88static void post_IP(DECL_ARGS); 89static void post_HP(DECL_ARGS); 90static void post_RS(DECL_ARGS); 91static void post_SH(DECL_ARGS); 92static void post_SS(DECL_ARGS); 93static void post_TP(DECL_ARGS); 94static void post_UR(DECL_ARGS); 95 |
98static const struct termact termacts[MAN_MAX] = { 99 { pre_sp, NULL, MAN_NOTEXT }, /* br */ | 96static const struct termact __termacts[MAN_MAX - MAN_TH] = { |
100 { NULL, NULL, 0 }, /* TH */ 101 { pre_SH, post_SH, 0 }, /* SH */ 102 { pre_SS, post_SS, 0 }, /* SS */ 103 { pre_TP, post_TP, 0 }, /* TP */ 104 { pre_PP, NULL, 0 }, /* LP */ 105 { pre_PP, NULL, 0 }, /* PP */ 106 { pre_PP, NULL, 0 }, /* P */ 107 { pre_IP, post_IP, 0 }, /* IP */ --- 4 unchanged lines hidden (view full) --- 112 { pre_alternate, NULL, 0 }, /* IB */ 113 { pre_alternate, NULL, 0 }, /* BR */ 114 { pre_alternate, NULL, 0 }, /* RB */ 115 { NULL, NULL, 0 }, /* R */ 116 { pre_B, NULL, 0 }, /* B */ 117 { pre_I, NULL, 0 }, /* I */ 118 { pre_alternate, NULL, 0 }, /* IR */ 119 { pre_alternate, NULL, 0 }, /* RI */ | 97 { NULL, NULL, 0 }, /* TH */ 98 { pre_SH, post_SH, 0 }, /* SH */ 99 { pre_SS, post_SS, 0 }, /* SS */ 100 { pre_TP, post_TP, 0 }, /* TP */ 101 { pre_PP, NULL, 0 }, /* LP */ 102 { pre_PP, NULL, 0 }, /* PP */ 103 { pre_PP, NULL, 0 }, /* P */ 104 { pre_IP, post_IP, 0 }, /* IP */ --- 4 unchanged lines hidden (view full) --- 109 { pre_alternate, NULL, 0 }, /* IB */ 110 { pre_alternate, NULL, 0 }, /* BR */ 111 { pre_alternate, NULL, 0 }, /* RB */ 112 { NULL, NULL, 0 }, /* R */ 113 { pre_B, NULL, 0 }, /* B */ 114 { pre_I, NULL, 0 }, /* I */ 115 { pre_alternate, NULL, 0 }, /* IR */ 116 { pre_alternate, NULL, 0 }, /* RI */ |
120 { pre_sp, NULL, MAN_NOTEXT }, /* sp */ | |
121 { pre_literal, NULL, 0 }, /* nf */ 122 { pre_literal, NULL, 0 }, /* fi */ 123 { NULL, NULL, 0 }, /* RE */ 124 { pre_RS, post_RS, 0 }, /* RS */ | 117 { pre_literal, NULL, 0 }, /* nf */ 118 { pre_literal, NULL, 0 }, /* fi */ 119 { NULL, NULL, 0 }, /* RE */ 120 { pre_RS, post_RS, 0 }, /* RS */ |
125 { pre_ign, NULL, 0 }, /* DT */ | 121 { pre_DT, NULL, 0 }, /* DT */ |
126 { pre_ign, NULL, MAN_NOTEXT }, /* UC */ 127 { pre_PD, NULL, MAN_NOTEXT }, /* PD */ 128 { pre_ign, NULL, 0 }, /* AT */ 129 { pre_in, NULL, MAN_NOTEXT }, /* in */ | 122 { pre_ign, NULL, MAN_NOTEXT }, /* UC */ 123 { pre_PD, NULL, MAN_NOTEXT }, /* PD */ 124 { pre_ign, NULL, 0 }, /* AT */ 125 { pre_in, NULL, MAN_NOTEXT }, /* in */ |
130 { pre_ft, NULL, MAN_NOTEXT }, /* ft */ | |
131 { pre_OP, NULL, 0 }, /* OP */ 132 { pre_literal, NULL, 0 }, /* EX */ 133 { pre_literal, NULL, 0 }, /* EE */ 134 { pre_UR, post_UR, 0 }, /* UR */ 135 { NULL, NULL, 0 }, /* UE */ | 126 { pre_OP, NULL, 0 }, /* OP */ 127 { pre_literal, NULL, 0 }, /* EX */ 128 { pre_literal, NULL, 0 }, /* EE */ 129 { pre_UR, post_UR, 0 }, /* UR */ 130 { NULL, NULL, 0 }, /* UE */ |
136 { pre_ll, NULL, MAN_NOTEXT }, /* ll */ | 131 { pre_UR, post_UR, 0 }, /* MT */ 132 { NULL, NULL, 0 }, /* ME */ |
137}; | 133}; |
134static const struct termact *termacts = __termacts - MAN_TH; |
|
138 139 140void 141terminal_man(void *arg, const struct roff_man *man) 142{ 143 struct termp *p; 144 struct roff_node *n; 145 struct mtermp mt; | 135 136 137void 138terminal_man(void *arg, const struct roff_man *man) 139{ 140 struct termp *p; 141 struct roff_node *n; 142 struct mtermp mt; |
143 size_t save_defindent; |
|
146 147 p = (struct termp *)arg; | 144 145 p = (struct termp *)arg; |
148 p->overstep = 0; 149 p->rmargin = p->maxrmargin = p->defrmargin; 150 p->tabwidth = term_len(p, 5); | 146 save_defindent = p->defindent; 147 if (p->synopsisonly == 0 && p->defindent == 0) 148 p->defindent = 7; 149 p->tcol->rmargin = p->maxrmargin = p->defrmargin; 150 term_tab_set(p, NULL); 151 term_tab_set(p, "T"); 152 term_tab_set(p, ".5i"); |
151 152 memset(&mt, 0, sizeof(struct mtermp)); 153 mt.lmargin[mt.lmargincur] = term_len(p, p->defindent); 154 mt.offset = term_len(p, p->defindent); 155 mt.pardist = 1; 156 157 n = man->first->child; 158 if (p->synopsisonly) { --- 6 unchanged lines hidden (view full) --- 165 n->child->next->child, 166 &man->meta); 167 term_newln(p); 168 break; 169 } 170 n = n->next; 171 } 172 } else { | 153 154 memset(&mt, 0, sizeof(struct mtermp)); 155 mt.lmargin[mt.lmargincur] = term_len(p, p->defindent); 156 mt.offset = term_len(p, p->defindent); 157 mt.pardist = 1; 158 159 n = man->first->child; 160 if (p->synopsisonly) { --- 6 unchanged lines hidden (view full) --- 167 n->child->next->child, 168 &man->meta); 169 term_newln(p); 170 break; 171 } 172 n = n->next; 173 } 174 } else { |
173 if (p->defindent == 0) 174 p->defindent = 7; | |
175 term_begin(p, print_man_head, print_man_foot, &man->meta); 176 p->flags |= TERMP_NOSPACE; 177 if (n != NULL) 178 print_man_nodelist(p, &mt, n, &man->meta); 179 term_end(p); 180 } | 175 term_begin(p, print_man_head, print_man_foot, &man->meta); 176 p->flags |= TERMP_NOSPACE; 177 if (n != NULL) 178 print_man_nodelist(p, &mt, n, &man->meta); 179 term_end(p); 180 } |
181 p->defindent = save_defindent; |
|
181} 182 183/* 184 * Printing leading vertical space before a block. 185 * This is used for the paragraph macros. 186 * The rules are pretty simple, since there's very little nesting going 187 * on here. Basically, if we're the first within another block (SS/SH), 188 * then don't emit vertical space. If we are (RS), then do. If not the --- 22 unchanged lines hidden (view full) --- 211static int 212pre_ign(DECL_ARGS) 213{ 214 215 return 0; 216} 217 218static int | 182} 183 184/* 185 * Printing leading vertical space before a block. 186 * This is used for the paragraph macros. 187 * The rules are pretty simple, since there's very little nesting going 188 * on here. Basically, if we're the first within another block (SS/SH), 189 * then don't emit vertical space. If we are (RS), then do. If not the --- 22 unchanged lines hidden (view full) --- 212static int 213pre_ign(DECL_ARGS) 214{ 215 216 return 0; 217} 218 219static int |
219pre_ll(DECL_ARGS) 220{ 221 222 term_setwidth(p, n->child != NULL ? n->child->string : NULL); 223 return 0; 224} 225 226static int | |
227pre_I(DECL_ARGS) 228{ 229 230 term_fontrepl(p, TERMFONT_UNDER); 231 return 1; 232} 233 234static int 235pre_literal(DECL_ARGS) 236{ 237 238 term_newln(p); 239 | 220pre_I(DECL_ARGS) 221{ 222 223 term_fontrepl(p, TERMFONT_UNDER); 224 return 1; 225} 226 227static int 228pre_literal(DECL_ARGS) 229{ 230 231 term_newln(p); 232 |
240 if (MAN_nf == n->tok || MAN_EX == n->tok) | 233 if (n->tok == MAN_nf || n->tok == MAN_EX) |
241 mt->fl |= MANT_LITERAL; 242 else 243 mt->fl &= ~MANT_LITERAL; 244 245 /* 246 * Unlike .IP and .TP, .HP does not have a HEAD. 247 * So in case a second call to term_flushln() is needed, 248 * indentation has to be set up explicitly. 249 */ | 234 mt->fl |= MANT_LITERAL; 235 else 236 mt->fl &= ~MANT_LITERAL; 237 238 /* 239 * Unlike .IP and .TP, .HP does not have a HEAD. 240 * So in case a second call to term_flushln() is needed, 241 * indentation has to be set up explicitly. 242 */ |
250 if (MAN_HP == n->parent->tok && p->rmargin < p->maxrmargin) { 251 p->offset = p->rmargin; 252 p->rmargin = p->maxrmargin; | 243 if (n->parent->tok == MAN_HP && p->tcol->rmargin < p->maxrmargin) { 244 p->tcol->offset = p->tcol->rmargin; 245 p->tcol->rmargin = p->maxrmargin; |
253 p->trailspace = 0; 254 p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND); 255 p->flags |= TERMP_NOSPACE; 256 } 257 258 return 0; 259} 260 261static int 262pre_PD(DECL_ARGS) 263{ 264 struct roffsu su; 265 266 n = n->child; 267 if (n == NULL) { 268 mt->pardist = 1; 269 return 0; 270 } 271 assert(n->type == ROFFT_TEXT); | 246 p->trailspace = 0; 247 p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND); 248 p->flags |= TERMP_NOSPACE; 249 } 250 251 return 0; 252} 253 254static int 255pre_PD(DECL_ARGS) 256{ 257 struct roffsu su; 258 259 n = n->child; 260 if (n == NULL) { 261 mt->pardist = 1; 262 return 0; 263 } 264 assert(n->type == ROFFT_TEXT); |
272 if (a2roffsu(n->string, &su, SCALE_VS)) | 265 if (a2roffsu(n->string, &su, SCALE_VS) != NULL) |
273 mt->pardist = term_vspan(p, &su); 274 return 0; 275} 276 277static int 278pre_alternate(DECL_ARGS) 279{ 280 enum termfont font[2]; --- 73 unchanged lines hidden (view full) --- 354 355 term_fontrepl(p, TERMFONT_NONE); 356 p->flags |= TERMP_NOSPACE; 357 term_word(p, "]"); 358 return 0; 359} 360 361static int | 266 mt->pardist = term_vspan(p, &su); 267 return 0; 268} 269 270static int 271pre_alternate(DECL_ARGS) 272{ 273 enum termfont font[2]; --- 73 unchanged lines hidden (view full) --- 347 348 term_fontrepl(p, TERMFONT_NONE); 349 p->flags |= TERMP_NOSPACE; 350 term_word(p, "]"); 351 return 0; 352} 353 354static int |
362pre_ft(DECL_ARGS) 363{ 364 const char *cp; 365 366 if (NULL == n->child) { 367 term_fontlast(p); 368 return 0; 369 } 370 371 cp = n->child->string; 372 switch (*cp) { 373 case '4': 374 case '3': 375 case 'B': 376 term_fontrepl(p, TERMFONT_BOLD); 377 break; 378 case '2': 379 case 'I': 380 term_fontrepl(p, TERMFONT_UNDER); 381 break; 382 case 'P': 383 term_fontlast(p); 384 break; 385 case '1': 386 case 'C': 387 case 'R': 388 term_fontrepl(p, TERMFONT_NONE); 389 break; 390 default: 391 break; 392 } 393 return 0; 394} 395 396static int | |
397pre_in(DECL_ARGS) 398{ 399 struct roffsu su; 400 const char *cp; 401 size_t v; 402 int less; 403 404 term_newln(p); 405 | 355pre_in(DECL_ARGS) 356{ 357 struct roffsu su; 358 const char *cp; 359 size_t v; 360 int less; 361 362 term_newln(p); 363 |
406 if (NULL == n->child) { 407 p->offset = mt->offset; | 364 if (n->child == NULL) { 365 p->tcol->offset = mt->offset; |
408 return 0; 409 } 410 411 cp = n->child->string; 412 less = 0; 413 414 if ('-' == *cp) 415 less = -1; 416 else if ('+' == *cp) 417 less = 1; 418 else 419 cp--; 420 | 366 return 0; 367 } 368 369 cp = n->child->string; 370 less = 0; 371 372 if ('-' == *cp) 373 less = -1; 374 else if ('+' == *cp) 375 less = 1; 376 else 377 cp--; 378 |
421 if ( ! a2roffsu(++cp, &su, SCALE_EN)) | 379 if (a2roffsu(++cp, &su, SCALE_EN) == NULL) |
422 return 0; 423 | 380 return 0; 381 |
424 v = (term_hspan(p, &su) + 11) / 24; | 382 v = term_hen(p, &su); |
425 426 if (less < 0) | 383 384 if (less < 0) |
427 p->offset -= p->offset > v ? v : p->offset; | 385 p->tcol->offset -= p->tcol->offset > v ? v : p->tcol->offset; |
428 else if (less > 0) | 386 else if (less > 0) |
429 p->offset += v; | 387 p->tcol->offset += v; |
430 else | 388 else |
431 p->offset = v; 432 if (p->offset > SHRT_MAX) 433 p->offset = term_len(p, p->defindent); | 389 p->tcol->offset = v; 390 if (p->tcol->offset > SHRT_MAX) 391 p->tcol->offset = term_len(p, p->defindent); |
434 435 return 0; 436} 437 438static int | 392 393 return 0; 394} 395 396static int |
439pre_sp(DECL_ARGS) | 397pre_DT(DECL_ARGS) |
440{ | 398{ |
441 struct roffsu su; 442 int i, len; 443 444 if ((NULL == n->prev && n->parent)) { 445 switch (n->parent->tok) { 446 case MAN_SH: 447 case MAN_SS: 448 case MAN_PP: 449 case MAN_LP: 450 case MAN_P: 451 return 0; 452 default: 453 break; 454 } 455 } 456 457 if (n->tok == MAN_br) 458 len = 0; 459 else if (n->child == NULL) 460 len = 1; 461 else { 462 if ( ! a2roffsu(n->child->string, &su, SCALE_VS)) 463 su.scale = 1.0; 464 len = term_vspan(p, &su); 465 } 466 467 if (len == 0) 468 term_newln(p); 469 else if (len < 0) 470 p->skipvsp -= len; 471 else 472 for (i = 0; i < len; i++) 473 term_vspace(p); 474 475 /* 476 * Handle an explicit break request in the same way 477 * as an overflowing line. 478 */ 479 480 if (p->flags & TERMP_BRIND) { 481 p->offset = p->rmargin; 482 p->rmargin = p->maxrmargin; 483 p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND); 484 } 485 | 399 term_tab_set(p, NULL); 400 term_tab_set(p, "T"); 401 term_tab_set(p, ".5i"); |
486 return 0; 487} 488 489static int 490pre_HP(DECL_ARGS) 491{ 492 struct roffsu su; 493 const struct roff_node *nn; --- 12 unchanged lines hidden (view full) --- 506 if ( ! (MANT_LITERAL & mt->fl)) { 507 p->flags |= TERMP_NOBREAK | TERMP_BRIND; 508 p->trailspace = 2; 509 } 510 511 /* Calculate offset. */ 512 513 if ((nn = n->parent->head->child) != NULL && | 402 return 0; 403} 404 405static int 406pre_HP(DECL_ARGS) 407{ 408 struct roffsu su; 409 const struct roff_node *nn; --- 12 unchanged lines hidden (view full) --- 422 if ( ! (MANT_LITERAL & mt->fl)) { 423 p->flags |= TERMP_NOBREAK | TERMP_BRIND; 424 p->trailspace = 2; 425 } 426 427 /* Calculate offset. */ 428 429 if ((nn = n->parent->head->child) != NULL && |
514 a2roffsu(nn->string, &su, SCALE_EN)) { 515 len = term_hspan(p, &su) / 24; | 430 a2roffsu(nn->string, &su, SCALE_EN) != NULL) { 431 len = term_hen(p, &su); |
516 if (len < 0 && (size_t)(-len) > mt->offset) 517 len = -mt->offset; 518 else if (len > SHRT_MAX) 519 len = term_len(p, p->defindent); 520 mt->lmargin[mt->lmargincur] = len; 521 } else 522 len = mt->lmargin[mt->lmargincur]; 523 | 432 if (len < 0 && (size_t)(-len) > mt->offset) 433 len = -mt->offset; 434 else if (len > SHRT_MAX) 435 len = term_len(p, p->defindent); 436 mt->lmargin[mt->lmargincur] = len; 437 } else 438 len = mt->lmargin[mt->lmargincur]; 439 |
524 p->offset = mt->offset; 525 p->rmargin = mt->offset + len; | 440 p->tcol->offset = mt->offset; 441 p->tcol->rmargin = mt->offset + len; |
526 return 1; 527} 528 529static void 530post_HP(DECL_ARGS) 531{ 532 533 switch (n->type) { --- 7 unchanged lines hidden (view full) --- 541 * mode even if there isn't any output. 542 */ 543 544 if (n->child == NULL) 545 term_vspace(p); 546 547 p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND); 548 p->trailspace = 0; | 442 return 1; 443} 444 445static void 446post_HP(DECL_ARGS) 447{ 448 449 switch (n->type) { --- 7 unchanged lines hidden (view full) --- 457 * mode even if there isn't any output. 458 */ 459 460 if (n->child == NULL) 461 term_vspace(p); 462 463 p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND); 464 p->trailspace = 0; |
549 p->offset = mt->offset; 550 p->rmargin = p->maxrmargin; | 465 p->tcol->offset = mt->offset; 466 p->tcol->rmargin = p->maxrmargin; |
551 break; 552 default: 553 break; 554 } 555} 556 557static int 558pre_PP(DECL_ARGS) 559{ 560 561 switch (n->type) { 562 case ROFFT_BLOCK: 563 mt->lmargin[mt->lmargincur] = term_len(p, p->defindent); 564 print_bvspace(p, n, mt->pardist); 565 break; 566 default: | 467 break; 468 default: 469 break; 470 } 471} 472 473static int 474pre_PP(DECL_ARGS) 475{ 476 477 switch (n->type) { 478 case ROFFT_BLOCK: 479 mt->lmargin[mt->lmargincur] = term_len(p, p->defindent); 480 print_bvspace(p, n, mt->pardist); 481 break; 482 default: |
567 p->offset = mt->offset; | 483 p->tcol->offset = mt->offset; |
568 break; 569 } 570 571 return n->type != ROFFT_HEAD; 572} 573 574static int 575pre_IP(DECL_ARGS) --- 15 unchanged lines hidden (view full) --- 591 /* FALLTHROUGH */ 592 default: 593 return 1; 594 } 595 596 /* Calculate the offset from the optional second argument. */ 597 if ((nn = n->parent->head->child) != NULL && 598 (nn = nn->next) != NULL && | 484 break; 485 } 486 487 return n->type != ROFFT_HEAD; 488} 489 490static int 491pre_IP(DECL_ARGS) --- 15 unchanged lines hidden (view full) --- 507 /* FALLTHROUGH */ 508 default: 509 return 1; 510 } 511 512 /* Calculate the offset from the optional second argument. */ 513 if ((nn = n->parent->head->child) != NULL && 514 (nn = nn->next) != NULL && |
599 a2roffsu(nn->string, &su, SCALE_EN)) { 600 len = term_hspan(p, &su) / 24; | 515 a2roffsu(nn->string, &su, SCALE_EN) != NULL) { 516 len = term_hen(p, &su); |
601 if (len < 0 && (size_t)(-len) > mt->offset) 602 len = -mt->offset; 603 else if (len > SHRT_MAX) 604 len = term_len(p, p->defindent); 605 mt->lmargin[mt->lmargincur] = len; 606 } else 607 len = mt->lmargin[mt->lmargincur]; 608 609 switch (n->type) { 610 case ROFFT_HEAD: | 517 if (len < 0 && (size_t)(-len) > mt->offset) 518 len = -mt->offset; 519 else if (len > SHRT_MAX) 520 len = term_len(p, p->defindent); 521 mt->lmargin[mt->lmargincur] = len; 522 } else 523 len = mt->lmargin[mt->lmargincur]; 524 525 switch (n->type) { 526 case ROFFT_HEAD: |
611 p->offset = mt->offset; 612 p->rmargin = mt->offset + len; | 527 p->tcol->offset = mt->offset; 528 p->tcol->rmargin = mt->offset + len; |
613 614 savelit = MANT_LITERAL & mt->fl; 615 mt->fl &= ~MANT_LITERAL; 616 617 if (n->child) 618 print_man_node(p, mt, n->child, meta); 619 620 if (savelit) 621 mt->fl |= MANT_LITERAL; 622 623 return 0; 624 case ROFFT_BODY: | 529 530 savelit = MANT_LITERAL & mt->fl; 531 mt->fl &= ~MANT_LITERAL; 532 533 if (n->child) 534 print_man_node(p, mt, n->child, meta); 535 536 if (savelit) 537 mt->fl |= MANT_LITERAL; 538 539 return 0; 540 case ROFFT_BODY: |
625 p->offset = mt->offset + len; 626 p->rmargin = p->maxrmargin; | 541 p->tcol->offset = mt->offset + len; 542 p->tcol->rmargin = p->maxrmargin; |
627 break; 628 default: 629 break; 630 } 631 632 return 1; 633} 634 635static void 636post_IP(DECL_ARGS) 637{ 638 639 switch (n->type) { 640 case ROFFT_HEAD: 641 term_flushln(p); 642 p->flags &= ~TERMP_NOBREAK; 643 p->trailspace = 0; | 543 break; 544 default: 545 break; 546 } 547 548 return 1; 549} 550 551static void 552post_IP(DECL_ARGS) 553{ 554 555 switch (n->type) { 556 case ROFFT_HEAD: 557 term_flushln(p); 558 p->flags &= ~TERMP_NOBREAK; 559 p->trailspace = 0; |
644 p->rmargin = p->maxrmargin; | 560 p->tcol->rmargin = p->maxrmargin; |
645 break; 646 case ROFFT_BODY: 647 term_newln(p); | 561 break; 562 case ROFFT_BODY: 563 term_newln(p); |
648 p->offset = mt->offset; | 564 p->tcol->offset = mt->offset; |
649 break; 650 default: 651 break; 652 } 653} 654 655static int 656pre_TP(DECL_ARGS) --- 16 unchanged lines hidden (view full) --- 673 default: 674 return 1; 675 } 676 677 /* Calculate offset. */ 678 679 if ((nn = n->parent->head->child) != NULL && 680 nn->string != NULL && ! (NODE_LINE & nn->flags) && | 565 break; 566 default: 567 break; 568 } 569} 570 571static int 572pre_TP(DECL_ARGS) --- 16 unchanged lines hidden (view full) --- 589 default: 590 return 1; 591 } 592 593 /* Calculate offset. */ 594 595 if ((nn = n->parent->head->child) != NULL && 596 nn->string != NULL && ! (NODE_LINE & nn->flags) && |
681 a2roffsu(nn->string, &su, SCALE_EN)) { 682 len = term_hspan(p, &su) / 24; | 597 a2roffsu(nn->string, &su, SCALE_EN) != NULL) { 598 len = term_hen(p, &su); |
683 if (len < 0 && (size_t)(-len) > mt->offset) 684 len = -mt->offset; 685 else if (len > SHRT_MAX) 686 len = term_len(p, p->defindent); 687 mt->lmargin[mt->lmargincur] = len; 688 } else 689 len = mt->lmargin[mt->lmargincur]; 690 691 switch (n->type) { 692 case ROFFT_HEAD: | 599 if (len < 0 && (size_t)(-len) > mt->offset) 600 len = -mt->offset; 601 else if (len > SHRT_MAX) 602 len = term_len(p, p->defindent); 603 mt->lmargin[mt->lmargincur] = len; 604 } else 605 len = mt->lmargin[mt->lmargincur]; 606 607 switch (n->type) { 608 case ROFFT_HEAD: |
693 p->offset = mt->offset; 694 p->rmargin = mt->offset + len; | 609 p->tcol->offset = mt->offset; 610 p->tcol->rmargin = mt->offset + len; |
695 696 savelit = MANT_LITERAL & mt->fl; 697 mt->fl &= ~MANT_LITERAL; 698 699 /* Don't print same-line elements. */ 700 nn = n->child; 701 while (NULL != nn && 0 == (NODE_LINE & nn->flags)) 702 nn = nn->next; 703 704 while (NULL != nn) { 705 print_man_node(p, mt, nn, meta); 706 nn = nn->next; 707 } 708 709 if (savelit) 710 mt->fl |= MANT_LITERAL; 711 return 0; 712 case ROFFT_BODY: | 611 612 savelit = MANT_LITERAL & mt->fl; 613 mt->fl &= ~MANT_LITERAL; 614 615 /* Don't print same-line elements. */ 616 nn = n->child; 617 while (NULL != nn && 0 == (NODE_LINE & nn->flags)) 618 nn = nn->next; 619 620 while (NULL != nn) { 621 print_man_node(p, mt, nn, meta); 622 nn = nn->next; 623 } 624 625 if (savelit) 626 mt->fl |= MANT_LITERAL; 627 return 0; 628 case ROFFT_BODY: |
713 p->offset = mt->offset + len; 714 p->rmargin = p->maxrmargin; | 629 p->tcol->offset = mt->offset + len; 630 p->tcol->rmargin = p->maxrmargin; |
715 p->trailspace = 0; 716 p->flags &= ~(TERMP_NOBREAK | TERMP_BRTRSP); 717 break; 718 default: 719 break; 720 } 721 722 return 1; --- 4 unchanged lines hidden (view full) --- 727{ 728 729 switch (n->type) { 730 case ROFFT_HEAD: 731 term_flushln(p); 732 break; 733 case ROFFT_BODY: 734 term_newln(p); | 631 p->trailspace = 0; 632 p->flags &= ~(TERMP_NOBREAK | TERMP_BRTRSP); 633 break; 634 default: 635 break; 636 } 637 638 return 1; --- 4 unchanged lines hidden (view full) --- 643{ 644 645 switch (n->type) { 646 case ROFFT_HEAD: 647 term_flushln(p); 648 break; 649 case ROFFT_BODY: 650 term_newln(p); |
735 p->offset = mt->offset; | 651 p->tcol->offset = mt->offset; |
736 break; 737 default: 738 break; 739 } 740} 741 742static int 743pre_SS(DECL_ARGS) --- 18 unchanged lines hidden (view full) --- 762 if (n == NULL || (n->tok == MAN_SS && n->body->child == NULL)) 763 break; 764 765 for (i = 0; i < mt->pardist; i++) 766 term_vspace(p); 767 break; 768 case ROFFT_HEAD: 769 term_fontrepl(p, TERMFONT_BOLD); | 652 break; 653 default: 654 break; 655 } 656} 657 658static int 659pre_SS(DECL_ARGS) --- 18 unchanged lines hidden (view full) --- 678 if (n == NULL || (n->tok == MAN_SS && n->body->child == NULL)) 679 break; 680 681 for (i = 0; i < mt->pardist; i++) 682 term_vspace(p); 683 break; 684 case ROFFT_HEAD: 685 term_fontrepl(p, TERMFONT_BOLD); |
770 p->offset = term_len(p, 3); 771 p->rmargin = mt->offset; | 686 p->tcol->offset = term_len(p, 3); 687 p->tcol->rmargin = mt->offset; |
772 p->trailspace = mt->offset; 773 p->flags |= TERMP_NOBREAK | TERMP_BRIND; 774 break; 775 case ROFFT_BODY: | 688 p->trailspace = mt->offset; 689 p->flags |= TERMP_NOBREAK | TERMP_BRIND; 690 break; 691 case ROFFT_BODY: |
776 p->offset = mt->offset; 777 p->rmargin = p->maxrmargin; | 692 p->tcol->offset = mt->offset; 693 p->tcol->rmargin = p->maxrmargin; |
778 p->trailspace = 0; 779 p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND); 780 break; 781 default: 782 break; 783 } 784 785 return 1; --- 28 unchanged lines hidden (view full) --- 814 815 /* 816 * No vertical space before the first section 817 * and after an empty section. 818 */ 819 820 do { 821 n = n->prev; | 694 p->trailspace = 0; 695 p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND); 696 break; 697 default: 698 break; 699 } 700 701 return 1; --- 28 unchanged lines hidden (view full) --- 730 731 /* 732 * No vertical space before the first section 733 * and after an empty section. 734 */ 735 736 do { 737 n = n->prev; |
822 } while (n != NULL && termacts[n->tok].flags & MAN_NOTEXT); | 738 } while (n != NULL && n->tok != TOKEN_NONE && 739 termacts[n->tok].flags & MAN_NOTEXT); |
823 if (n == NULL || (n->tok == MAN_SH && n->body->child == NULL)) 824 break; 825 826 for (i = 0; i < mt->pardist; i++) 827 term_vspace(p); 828 break; 829 case ROFFT_HEAD: 830 term_fontrepl(p, TERMFONT_BOLD); | 740 if (n == NULL || (n->tok == MAN_SH && n->body->child == NULL)) 741 break; 742 743 for (i = 0; i < mt->pardist; i++) 744 term_vspace(p); 745 break; 746 case ROFFT_HEAD: 747 term_fontrepl(p, TERMFONT_BOLD); |
831 p->offset = 0; 832 p->rmargin = mt->offset; | 748 p->tcol->offset = 0; 749 p->tcol->rmargin = mt->offset; |
833 p->trailspace = mt->offset; 834 p->flags |= TERMP_NOBREAK | TERMP_BRIND; 835 break; 836 case ROFFT_BODY: | 750 p->trailspace = mt->offset; 751 p->flags |= TERMP_NOBREAK | TERMP_BRIND; 752 break; 753 case ROFFT_BODY: |
837 p->offset = mt->offset; 838 p->rmargin = p->maxrmargin; | 754 p->tcol->offset = mt->offset; 755 p->tcol->rmargin = p->maxrmargin; |
839 p->trailspace = 0; 840 p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND); 841 break; 842 default: 843 break; 844 } 845 846 return 1; --- 29 unchanged lines hidden (view full) --- 876 default: 877 break; 878 } 879 880 n = n->parent->head; 881 n->aux = SHRT_MAX + 1; 882 if (n->child == NULL) 883 n->aux = mt->lmargin[mt->lmargincur]; | 756 p->trailspace = 0; 757 p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND); 758 break; 759 default: 760 break; 761 } 762 763 return 1; --- 29 unchanged lines hidden (view full) --- 793 default: 794 break; 795 } 796 797 n = n->parent->head; 798 n->aux = SHRT_MAX + 1; 799 if (n->child == NULL) 800 n->aux = mt->lmargin[mt->lmargincur]; |
884 else if (a2roffsu(n->child->string, &su, SCALE_EN)) 885 n->aux = term_hspan(p, &su) / 24; | 801 else if (a2roffsu(n->child->string, &su, SCALE_EN) != NULL) 802 n->aux = term_hen(p, &su); |
886 if (n->aux < 0 && (size_t)(-n->aux) > mt->offset) 887 n->aux = -mt->offset; 888 else if (n->aux > SHRT_MAX) 889 n->aux = term_len(p, p->defindent); 890 891 mt->offset += n->aux; | 803 if (n->aux < 0 && (size_t)(-n->aux) > mt->offset) 804 n->aux = -mt->offset; 805 else if (n->aux > SHRT_MAX) 806 n->aux = term_len(p, p->defindent); 807 808 mt->offset += n->aux; |
892 p->offset = mt->offset; 893 p->rmargin = p->maxrmargin; | 809 p->tcol->offset = mt->offset; 810 p->tcol->rmargin = p->maxrmargin; |
894 895 if (++mt->lmarginsz < MAXMARGINS) 896 mt->lmargincur = mt->lmarginsz; 897 898 mt->lmargin[mt->lmargincur] = term_len(p, p->defindent); 899 return 1; 900} 901 --- 7 unchanged lines hidden (view full) --- 909 case ROFFT_HEAD: 910 return; 911 default: 912 term_newln(p); 913 break; 914 } 915 916 mt->offset -= n->parent->head->aux; | 811 812 if (++mt->lmarginsz < MAXMARGINS) 813 mt->lmargincur = mt->lmarginsz; 814 815 mt->lmargin[mt->lmargincur] = term_len(p, p->defindent); 816 return 1; 817} 818 --- 7 unchanged lines hidden (view full) --- 826 case ROFFT_HEAD: 827 return; 828 default: 829 term_newln(p); 830 break; 831 } 832 833 mt->offset -= n->parent->head->aux; |
917 p->offset = mt->offset; | 834 p->tcol->offset = mt->offset; |
918 919 if (--mt->lmarginsz < MAXMARGINS) 920 mt->lmargincur = mt->lmarginsz; 921} 922 923static int 924pre_UR(DECL_ARGS) 925{ --- 16 unchanged lines hidden (view full) --- 942 943 p->flags |= TERMP_NOSPACE; 944 term_word(p, ">"); 945} 946 947static void 948print_man_node(DECL_ARGS) 949{ | 835 836 if (--mt->lmarginsz < MAXMARGINS) 837 mt->lmargincur = mt->lmarginsz; 838} 839 840static int 841pre_UR(DECL_ARGS) 842{ --- 16 unchanged lines hidden (view full) --- 859 860 p->flags |= TERMP_NOSPACE; 861 term_word(p, ">"); 862} 863 864static void 865print_man_node(DECL_ARGS) 866{ |
950 size_t rm, rmax; | |
951 int c; 952 953 switch (n->type) { 954 case ROFFT_TEXT: 955 /* 956 * If we have a blank line, output a vertical space. 957 * If we have a space as the first character, break 958 * before printing the line's data. 959 */ | 867 int c; 868 869 switch (n->type) { 870 case ROFFT_TEXT: 871 /* 872 * If we have a blank line, output a vertical space. 873 * If we have a space as the first character, break 874 * before printing the line's data. 875 */ |
960 if ('\0' == *n->string) { 961 term_vspace(p); | 876 if (*n->string == '\0') { 877 if (p->flags & TERMP_NONEWLINE) 878 term_newln(p); 879 else 880 term_vspace(p); |
962 return; | 881 return; |
963 } else if (' ' == *n->string && NODE_LINE & n->flags) | 882 } else if (*n->string == ' ' && n->flags & NODE_LINE && 883 (p->flags & TERMP_NONEWLINE) == 0) |
964 term_newln(p); 965 966 term_word(p, n->string); 967 goto out; 968 969 case ROFFT_EQN: 970 if ( ! (n->flags & NODE_LINE)) 971 p->flags |= TERMP_NOSPACE; --- 5 unchanged lines hidden (view full) --- 977 if (p->tbl.cols == NULL) 978 term_vspace(p); 979 term_tbl(p, n->span); 980 return; 981 default: 982 break; 983 } 984 | 884 term_newln(p); 885 886 term_word(p, n->string); 887 goto out; 888 889 case ROFFT_EQN: 890 if ( ! (n->flags & NODE_LINE)) 891 p->flags |= TERMP_NOSPACE; --- 5 unchanged lines hidden (view full) --- 897 if (p->tbl.cols == NULL) 898 term_vspace(p); 899 term_tbl(p, n->span); 900 return; 901 default: 902 break; 903 } 904 |
905 if (n->tok < ROFF_MAX) { 906 roff_term_pre(p, n); 907 return; 908 } 909 910 assert(n->tok >= MAN_TH && n->tok <= MAN_MAX); |
|
985 if ( ! (MAN_NOTEXT & termacts[n->tok].flags)) 986 term_fontrepl(p, TERMFONT_NONE); 987 988 c = 1; 989 if (termacts[n->tok].pre) 990 c = (*termacts[n->tok].pre)(p, mt, n, meta); 991 992 if (c && n->child) --- 10 unchanged lines hidden (view full) --- 1003 * together on the same line stay together. This is a 1004 * POST-printing call, so we check the NEXT word. Since 1005 * -man doesn't have nested macros, we don't need to be 1006 * more specific than this. 1007 */ 1008 if (mt->fl & MANT_LITERAL && 1009 ! (p->flags & (TERMP_NOBREAK | TERMP_NONEWLINE)) && 1010 (n->next == NULL || n->next->flags & NODE_LINE)) { | 911 if ( ! (MAN_NOTEXT & termacts[n->tok].flags)) 912 term_fontrepl(p, TERMFONT_NONE); 913 914 c = 1; 915 if (termacts[n->tok].pre) 916 c = (*termacts[n->tok].pre)(p, mt, n, meta); 917 918 if (c && n->child) --- 10 unchanged lines hidden (view full) --- 929 * together on the same line stay together. This is a 930 * POST-printing call, so we check the NEXT word. Since 931 * -man doesn't have nested macros, we don't need to be 932 * more specific than this. 933 */ 934 if (mt->fl & MANT_LITERAL && 935 ! (p->flags & (TERMP_NOBREAK | TERMP_NONEWLINE)) && 936 (n->next == NULL || n->next->flags & NODE_LINE)) { |
1011 rm = p->rmargin; 1012 rmax = p->maxrmargin; 1013 p->rmargin = p->maxrmargin = TERM_MAXMARGIN; 1014 p->flags |= TERMP_NOSPACE; | 937 p->flags |= TERMP_BRNEVER | TERMP_NOSPACE; |
1015 if (n->string != NULL && *n->string != '\0') 1016 term_flushln(p); 1017 else 1018 term_newln(p); | 938 if (n->string != NULL && *n->string != '\0') 939 term_flushln(p); 940 else 941 term_newln(p); |
1019 if (rm < rmax && n->parent->tok == MAN_HP) { 1020 p->offset = rm; 1021 p->rmargin = rmax; 1022 } else 1023 p->rmargin = rm; 1024 p->maxrmargin = rmax; | 942 p->flags &= ~TERMP_BRNEVER; 943 if (p->tcol->rmargin < p->maxrmargin && 944 n->parent->tok == MAN_HP) { 945 p->tcol->offset = p->tcol->rmargin; 946 p->tcol->rmargin = p->maxrmargin; 947 } |
1025 } 1026 if (NODE_EOS & n->flags) 1027 p->flags |= TERMP_SENTENCE; 1028} 1029 1030 1031static void 1032print_man_nodelist(DECL_ARGS) --- 39 unchanged lines hidden (view full) --- 1072 title = mandoc_strdup(""); 1073 } 1074 datelen = term_strlen(p, meta->date); 1075 1076 /* Bottom left corner: operating system. */ 1077 1078 p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; 1079 p->trailspace = 1; | 948 } 949 if (NODE_EOS & n->flags) 950 p->flags |= TERMP_SENTENCE; 951} 952 953 954static void 955print_man_nodelist(DECL_ARGS) --- 39 unchanged lines hidden (view full) --- 995 title = mandoc_strdup(""); 996 } 997 datelen = term_strlen(p, meta->date); 998 999 /* Bottom left corner: operating system. */ 1000 1001 p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; 1002 p->trailspace = 1; |
1080 p->offset = 0; 1081 p->rmargin = p->maxrmargin > datelen ? | 1003 p->tcol->offset = 0; 1004 p->tcol->rmargin = p->maxrmargin > datelen ? |
1082 (p->maxrmargin + term_len(p, 1) - datelen) / 2 : 0; 1083 1084 if (meta->os) 1085 term_word(p, meta->os); 1086 term_flushln(p); 1087 1088 /* At the bottom in the middle: manual date. */ 1089 | 1005 (p->maxrmargin + term_len(p, 1) - datelen) / 2 : 0; 1006 1007 if (meta->os) 1008 term_word(p, meta->os); 1009 term_flushln(p); 1010 1011 /* At the bottom in the middle: manual date. */ 1012 |
1090 p->offset = p->rmargin; | 1013 p->tcol->offset = p->tcol->rmargin; |
1091 titlen = term_strlen(p, title); | 1014 titlen = term_strlen(p, title); |
1092 p->rmargin = p->maxrmargin > titlen ? p->maxrmargin - titlen : 0; | 1015 p->tcol->rmargin = p->maxrmargin > titlen ? 1016 p->maxrmargin - titlen : 0; |
1093 p->flags |= TERMP_NOSPACE; 1094 1095 term_word(p, meta->date); 1096 term_flushln(p); 1097 1098 /* Bottom right corner: manual title and section. */ 1099 1100 p->flags &= ~TERMP_NOBREAK; 1101 p->flags |= TERMP_NOSPACE; 1102 p->trailspace = 0; | 1017 p->flags |= TERMP_NOSPACE; 1018 1019 term_word(p, meta->date); 1020 term_flushln(p); 1021 1022 /* Bottom right corner: manual title and section. */ 1023 1024 p->flags &= ~TERMP_NOBREAK; 1025 p->flags |= TERMP_NOSPACE; 1026 p->trailspace = 0; |
1103 p->offset = p->rmargin; 1104 p->rmargin = p->maxrmargin; | 1027 p->tcol->offset = p->tcol->rmargin; 1028 p->tcol->rmargin = p->maxrmargin; |
1105 1106 term_word(p, title); 1107 term_flushln(p); 1108 free(title); 1109} 1110 1111static void 1112print_man_head(struct termp *p, const struct roff_meta *meta) --- 10 unchanged lines hidden (view full) --- 1123 1124 /* Top left corner: manual title and section. */ 1125 1126 mandoc_asprintf(&title, "%s(%s)", meta->title, meta->msec); 1127 titlen = term_strlen(p, title); 1128 1129 p->flags |= TERMP_NOBREAK | TERMP_NOSPACE; 1130 p->trailspace = 1; | 1029 1030 term_word(p, title); 1031 term_flushln(p); 1032 free(title); 1033} 1034 1035static void 1036print_man_head(struct termp *p, const struct roff_meta *meta) --- 10 unchanged lines hidden (view full) --- 1047 1048 /* Top left corner: manual title and section. */ 1049 1050 mandoc_asprintf(&title, "%s(%s)", meta->title, meta->msec); 1051 titlen = term_strlen(p, title); 1052 1053 p->flags |= TERMP_NOBREAK | TERMP_NOSPACE; 1054 p->trailspace = 1; |
1131 p->offset = 0; 1132 p->rmargin = 2 * (titlen+1) + vollen < p->maxrmargin ? | 1055 p->tcol->offset = 0; 1056 p->tcol->rmargin = 2 * (titlen+1) + vollen < p->maxrmargin ? |
1133 (p->maxrmargin - vollen + term_len(p, 1)) / 2 : 1134 vollen < p->maxrmargin ? p->maxrmargin - vollen : 0; 1135 1136 term_word(p, title); 1137 term_flushln(p); 1138 1139 /* At the top in the middle: manual volume. */ 1140 1141 p->flags |= TERMP_NOSPACE; | 1057 (p->maxrmargin - vollen + term_len(p, 1)) / 2 : 1058 vollen < p->maxrmargin ? p->maxrmargin - vollen : 0; 1059 1060 term_word(p, title); 1061 term_flushln(p); 1062 1063 /* At the top in the middle: manual volume. */ 1064 1065 p->flags |= TERMP_NOSPACE; |
1142 p->offset = p->rmargin; 1143 p->rmargin = p->offset + vollen + titlen < p->maxrmargin ? 1144 p->maxrmargin - titlen : p->maxrmargin; | 1066 p->tcol->offset = p->tcol->rmargin; 1067 p->tcol->rmargin = p->tcol->offset + vollen + titlen < 1068 p->maxrmargin ? p->maxrmargin - titlen : p->maxrmargin; |
1145 1146 term_word(p, volume); 1147 term_flushln(p); 1148 1149 /* Top right corner: title and section, again. */ 1150 1151 p->flags &= ~TERMP_NOBREAK; 1152 p->trailspace = 0; | 1069 1070 term_word(p, volume); 1071 term_flushln(p); 1072 1073 /* Top right corner: title and section, again. */ 1074 1075 p->flags &= ~TERMP_NOBREAK; 1076 p->trailspace = 0; |
1153 if (p->rmargin + titlen <= p->maxrmargin) { | 1077 if (p->tcol->rmargin + titlen <= p->maxrmargin) { |
1154 p->flags |= TERMP_NOSPACE; | 1078 p->flags |= TERMP_NOSPACE; |
1155 p->offset = p->rmargin; 1156 p->rmargin = p->maxrmargin; | 1079 p->tcol->offset = p->tcol->rmargin; 1080 p->tcol->rmargin = p->maxrmargin; |
1157 term_word(p, title); 1158 term_flushln(p); 1159 } 1160 1161 p->flags &= ~TERMP_NOSPACE; | 1081 term_word(p, title); 1082 term_flushln(p); 1083 } 1084 1085 p->flags &= ~TERMP_NOSPACE; |
1162 p->offset = 0; 1163 p->rmargin = p->maxrmargin; | 1086 p->tcol->offset = 0; 1087 p->tcol->rmargin = p->maxrmargin; |
1164 1165 /* 1166 * Groff prints three blank lines before the content. 1167 * Do the same, except in the temporary, undocumented 1168 * mode imitating mdoc(7) output. 1169 */ 1170 1171 term_vspace(p); 1172 if ( ! p->mdocstyle) { 1173 term_vspace(p); 1174 term_vspace(p); 1175 } 1176 free(title); 1177} | 1088 1089 /* 1090 * Groff prints three blank lines before the content. 1091 * Do the same, except in the temporary, undocumented 1092 * mode imitating mdoc(7) output. 1093 */ 1094 1095 term_vspace(p); 1096 if ( ! p->mdocstyle) { 1097 term_vspace(p); 1098 term_vspace(p); 1099 } 1100 free(title); 1101} |