]>
git.cameronkatri.com Git - mandoc.git/blob - man_term.c
1 /* $Id: man_term.c,v 1.200 2017/05/09 14:10:01 schwarze Exp $ */
3 * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2010-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
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.
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
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 #include <sys/types.h>
29 #include "mandoc_aux.h"
37 #define MAXMARGINS 64 /* maximum number of indented scopes */
41 #define MANT_LITERAL (1 << 0)
42 int lmargin
[MAXMARGINS
]; /* margins (incl. vis. page) */
43 int lmargincur
; /* index of current margin */
44 int lmarginsz
; /* actual number of nested margins */
45 size_t offset
; /* default offset to visible page */
46 int pardist
; /* vert. space before par., unit: [v] */
49 #define DECL_ARGS struct termp *p, \
51 struct roff_node *n, \
52 const struct roff_meta *meta
55 int (*pre
)(DECL_ARGS
);
56 void (*post
)(DECL_ARGS
);
58 #define MAN_NOTEXT (1 << 0) /* Never has text children. */
61 static void print_man_nodelist(DECL_ARGS
);
62 static void print_man_node(DECL_ARGS
);
63 static void print_man_head(struct termp
*,
64 const struct roff_meta
*);
65 static void print_man_foot(struct termp
*,
66 const struct roff_meta
*);
67 static void print_bvspace(struct termp
*,
68 const struct roff_node
*, int);
70 static int pre_B(DECL_ARGS
);
71 static int pre_DT(DECL_ARGS
);
72 static int pre_HP(DECL_ARGS
);
73 static int pre_I(DECL_ARGS
);
74 static int pre_IP(DECL_ARGS
);
75 static int pre_OP(DECL_ARGS
);
76 static int pre_PD(DECL_ARGS
);
77 static int pre_PP(DECL_ARGS
);
78 static int pre_RS(DECL_ARGS
);
79 static int pre_SH(DECL_ARGS
);
80 static int pre_SS(DECL_ARGS
);
81 static int pre_TP(DECL_ARGS
);
82 static int pre_UR(DECL_ARGS
);
83 static int pre_alternate(DECL_ARGS
);
84 static int pre_ign(DECL_ARGS
);
85 static int pre_in(DECL_ARGS
);
86 static int pre_literal(DECL_ARGS
);
88 static void post_IP(DECL_ARGS
);
89 static void post_HP(DECL_ARGS
);
90 static void post_RS(DECL_ARGS
);
91 static void post_SH(DECL_ARGS
);
92 static void post_SS(DECL_ARGS
);
93 static void post_TP(DECL_ARGS
);
94 static void post_UR(DECL_ARGS
);
96 static const struct termact __termacts
[MAN_MAX
- MAN_TH
] = {
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 */
105 { pre_HP
, post_HP
, 0 }, /* HP */
106 { NULL
, NULL
, 0 }, /* SM */
107 { pre_B
, NULL
, 0 }, /* SB */
108 { pre_alternate
, NULL
, 0 }, /* BI */
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 */
117 { pre_literal
, NULL
, 0 }, /* nf */
118 { pre_literal
, NULL
, 0 }, /* fi */
119 { NULL
, NULL
, 0 }, /* RE */
120 { pre_RS
, post_RS
, 0 }, /* RS */
121 { pre_DT
, NULL
, 0 }, /* DT */
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 */
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 */
132 static const struct termact
*termacts
= __termacts
- MAN_TH
;
136 terminal_man(void *arg
, const struct roff_man
*man
)
141 size_t save_defindent
;
143 p
= (struct termp
*)arg
;
145 p
->rmargin
= p
->maxrmargin
= p
->defrmargin
;
146 term_tab_set(p
, NULL
);
147 term_tab_set(p
, "T");
148 term_tab_set(p
, ".5i");
150 memset(&mt
, 0, sizeof(struct mtermp
));
151 mt
.lmargin
[mt
.lmargincur
] = term_len(p
, p
->defindent
);
152 mt
.offset
= term_len(p
, p
->defindent
);
155 n
= man
->first
->child
;
156 if (p
->synopsisonly
) {
158 if (n
->tok
== MAN_SH
&&
159 n
->child
->child
->type
== ROFFT_TEXT
&&
160 !strcmp(n
->child
->child
->string
, "SYNOPSIS")) {
161 if (n
->child
->next
->child
!= NULL
)
162 print_man_nodelist(p
, &mt
,
163 n
->child
->next
->child
,
171 save_defindent
= p
->defindent
;
172 if (p
->defindent
== 0)
174 term_begin(p
, print_man_head
, print_man_foot
, &man
->meta
);
175 p
->flags
|= TERMP_NOSPACE
;
177 print_man_nodelist(p
, &mt
, n
, &man
->meta
);
179 p
->defindent
= save_defindent
;
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
192 print_bvspace(struct termp
*p
, const struct roff_node
*n
, int pardist
)
198 if (n
->body
&& n
->body
->child
)
199 if (n
->body
->child
->type
== ROFFT_TBL
)
202 if (n
->parent
->type
== ROFFT_ROOT
|| n
->parent
->tok
!= MAN_RS
)
206 for (i
= 0; i
< pardist
; i
++)
222 term_fontrepl(p
, TERMFONT_UNDER
);
227 pre_literal(DECL_ARGS
)
232 if (MAN_nf
== n
->tok
|| MAN_EX
== n
->tok
)
233 mt
->fl
|= MANT_LITERAL
;
235 mt
->fl
&= ~MANT_LITERAL
;
238 * Unlike .IP and .TP, .HP does not have a HEAD.
239 * So in case a second call to term_flushln() is needed,
240 * indentation has to be set up explicitly.
242 if (MAN_HP
== n
->parent
->tok
&& p
->rmargin
< p
->maxrmargin
) {
243 p
->offset
= p
->rmargin
;
244 p
->rmargin
= p
->maxrmargin
;
246 p
->flags
&= ~(TERMP_NOBREAK
| TERMP_BRIND
);
247 p
->flags
|= TERMP_NOSPACE
;
263 assert(n
->type
== ROFFT_TEXT
);
264 if (a2roffsu(n
->string
, &su
, SCALE_VS
))
265 mt
->pardist
= term_vspan(p
, &su
);
270 pre_alternate(DECL_ARGS
)
272 enum termfont font
[2];
273 struct roff_node
*nn
;
278 font
[0] = TERMFONT_NONE
;
279 font
[1] = TERMFONT_BOLD
;
282 font
[0] = TERMFONT_NONE
;
283 font
[1] = TERMFONT_UNDER
;
286 font
[0] = TERMFONT_BOLD
;
287 font
[1] = TERMFONT_NONE
;
290 font
[0] = TERMFONT_BOLD
;
291 font
[1] = TERMFONT_UNDER
;
294 font
[0] = TERMFONT_UNDER
;
295 font
[1] = TERMFONT_NONE
;
298 font
[0] = TERMFONT_UNDER
;
299 font
[1] = TERMFONT_BOLD
;
305 savelit
= MANT_LITERAL
& mt
->fl
;
306 mt
->fl
&= ~MANT_LITERAL
;
308 for (i
= 0, nn
= n
->child
; nn
; nn
= nn
->next
, i
= 1 - i
) {
309 term_fontrepl(p
, font
[i
]);
310 if (savelit
&& NULL
== nn
->next
)
311 mt
->fl
|= MANT_LITERAL
;
312 assert(nn
->type
== ROFFT_TEXT
);
313 term_word(p
, nn
->string
);
314 if (nn
->flags
& NODE_EOS
)
315 p
->flags
|= TERMP_SENTENCE
;
317 p
->flags
|= TERMP_NOSPACE
;
327 term_fontrepl(p
, TERMFONT_BOLD
);
336 p
->flags
|= TERMP_NOSPACE
;
338 if (NULL
!= (n
= n
->child
)) {
339 term_fontrepl(p
, TERMFONT_BOLD
);
340 term_word(p
, n
->string
);
342 if (NULL
!= n
&& NULL
!= n
->next
) {
343 term_fontrepl(p
, TERMFONT_UNDER
);
344 term_word(p
, n
->next
->string
);
347 term_fontrepl(p
, TERMFONT_NONE
);
348 p
->flags
|= TERMP_NOSPACE
;
363 if (NULL
== n
->child
) {
364 p
->offset
= mt
->offset
;
368 cp
= n
->child
->string
;
378 if ( ! a2roffsu(++cp
, &su
, SCALE_EN
))
381 v
= (term_hspan(p
, &su
) + 11) / 24;
384 p
->offset
-= p
->offset
> v
? v
: p
->offset
;
389 if (p
->offset
> SHRT_MAX
)
390 p
->offset
= term_len(p
, p
->defindent
);
398 term_tab_set(p
, NULL
);
399 term_tab_set(p
, "T");
400 term_tab_set(p
, ".5i");
408 const struct roff_node
*nn
;
413 print_bvspace(p
, n
, mt
->pardist
);
421 if ( ! (MANT_LITERAL
& mt
->fl
)) {
422 p
->flags
|= TERMP_NOBREAK
| TERMP_BRIND
;
426 /* Calculate offset. */
428 if ((nn
= n
->parent
->head
->child
) != NULL
&&
429 a2roffsu(nn
->string
, &su
, SCALE_EN
)) {
430 len
= term_hspan(p
, &su
) / 24;
431 if (len
< 0 && (size_t)(-len
) > mt
->offset
)
433 else if (len
> SHRT_MAX
)
434 len
= term_len(p
, p
->defindent
);
435 mt
->lmargin
[mt
->lmargincur
] = len
;
437 len
= mt
->lmargin
[mt
->lmargincur
];
439 p
->offset
= mt
->offset
;
440 p
->rmargin
= mt
->offset
+ len
;
453 * Compatibility with a groff bug.
454 * The .HP macro uses the undocumented .tag request
455 * which causes a line break and cancels no-space
456 * mode even if there isn't any output.
459 if (n
->child
== NULL
)
462 p
->flags
&= ~(TERMP_NOBREAK
| TERMP_BRIND
);
464 p
->offset
= mt
->offset
;
465 p
->rmargin
= p
->maxrmargin
;
478 mt
->lmargin
[mt
->lmargincur
] = term_len(p
, p
->defindent
);
479 print_bvspace(p
, n
, mt
->pardist
);
482 p
->offset
= mt
->offset
;
486 return n
->type
!= ROFFT_HEAD
;
493 const struct roff_node
*nn
;
498 p
->flags
|= TERMP_NOSPACE
;
501 p
->flags
|= TERMP_NOBREAK
;
505 print_bvspace(p
, n
, mt
->pardist
);
511 /* Calculate the offset from the optional second argument. */
512 if ((nn
= n
->parent
->head
->child
) != NULL
&&
513 (nn
= nn
->next
) != NULL
&&
514 a2roffsu(nn
->string
, &su
, SCALE_EN
)) {
515 len
= term_hspan(p
, &su
) / 24;
516 if (len
< 0 && (size_t)(-len
) > mt
->offset
)
518 else if (len
> SHRT_MAX
)
519 len
= term_len(p
, p
->defindent
);
520 mt
->lmargin
[mt
->lmargincur
] = len
;
522 len
= mt
->lmargin
[mt
->lmargincur
];
526 p
->offset
= mt
->offset
;
527 p
->rmargin
= mt
->offset
+ len
;
529 savelit
= MANT_LITERAL
& mt
->fl
;
530 mt
->fl
&= ~MANT_LITERAL
;
533 print_man_node(p
, mt
, n
->child
, meta
);
536 mt
->fl
|= MANT_LITERAL
;
540 p
->offset
= mt
->offset
+ len
;
541 p
->rmargin
= p
->maxrmargin
;
557 p
->flags
&= ~TERMP_NOBREAK
;
559 p
->rmargin
= p
->maxrmargin
;
563 p
->offset
= mt
->offset
;
574 struct roff_node
*nn
;
579 p
->flags
|= TERMP_NOBREAK
| TERMP_BRTRSP
;
583 p
->flags
|= TERMP_NOSPACE
;
586 print_bvspace(p
, n
, mt
->pardist
);
592 /* Calculate offset. */
594 if ((nn
= n
->parent
->head
->child
) != NULL
&&
595 nn
->string
!= NULL
&& ! (NODE_LINE
& nn
->flags
) &&
596 a2roffsu(nn
->string
, &su
, SCALE_EN
)) {
597 len
= term_hspan(p
, &su
) / 24;
598 if (len
< 0 && (size_t)(-len
) > mt
->offset
)
600 else if (len
> SHRT_MAX
)
601 len
= term_len(p
, p
->defindent
);
602 mt
->lmargin
[mt
->lmargincur
] = len
;
604 len
= mt
->lmargin
[mt
->lmargincur
];
608 p
->offset
= mt
->offset
;
609 p
->rmargin
= mt
->offset
+ len
;
611 savelit
= MANT_LITERAL
& mt
->fl
;
612 mt
->fl
&= ~MANT_LITERAL
;
614 /* Don't print same-line elements. */
616 while (NULL
!= nn
&& 0 == (NODE_LINE
& nn
->flags
))
620 print_man_node(p
, mt
, nn
, meta
);
625 mt
->fl
|= MANT_LITERAL
;
628 p
->offset
= mt
->offset
+ len
;
629 p
->rmargin
= p
->maxrmargin
;
631 p
->flags
&= ~(TERMP_NOBREAK
| TERMP_BRTRSP
);
650 p
->offset
= mt
->offset
;
664 mt
->fl
&= ~MANT_LITERAL
;
665 mt
->lmargin
[mt
->lmargincur
] = term_len(p
, p
->defindent
);
666 mt
->offset
= term_len(p
, p
->defindent
);
669 * No vertical space before the first subsection
670 * and after an empty subsection.
675 } while (n
!= NULL
&& n
->tok
!= TOKEN_NONE
&&
676 termacts
[n
->tok
].flags
& MAN_NOTEXT
);
677 if (n
== NULL
|| (n
->tok
== MAN_SS
&& n
->body
->child
== NULL
))
680 for (i
= 0; i
< mt
->pardist
; i
++)
684 term_fontrepl(p
, TERMFONT_BOLD
);
685 p
->offset
= term_len(p
, 3);
686 p
->rmargin
= mt
->offset
;
687 p
->trailspace
= mt
->offset
;
688 p
->flags
|= TERMP_NOBREAK
| TERMP_BRIND
;
691 p
->offset
= mt
->offset
;
692 p
->rmargin
= p
->maxrmargin
;
694 p
->flags
&= ~(TERMP_NOBREAK
| TERMP_BRIND
);
726 mt
->fl
&= ~MANT_LITERAL
;
727 mt
->lmargin
[mt
->lmargincur
] = term_len(p
, p
->defindent
);
728 mt
->offset
= term_len(p
, p
->defindent
);
731 * No vertical space before the first section
732 * and after an empty section.
737 } while (n
!= NULL
&& n
->tok
!= TOKEN_NONE
&&
738 termacts
[n
->tok
].flags
& MAN_NOTEXT
);
739 if (n
== NULL
|| (n
->tok
== MAN_SH
&& n
->body
->child
== NULL
))
742 for (i
= 0; i
< mt
->pardist
; i
++)
746 term_fontrepl(p
, TERMFONT_BOLD
);
748 p
->rmargin
= mt
->offset
;
749 p
->trailspace
= mt
->offset
;
750 p
->flags
|= TERMP_NOBREAK
| TERMP_BRIND
;
753 p
->offset
= mt
->offset
;
754 p
->rmargin
= p
->maxrmargin
;
756 p
->flags
&= ~(TERMP_NOBREAK
| TERMP_BRIND
);
797 n
->aux
= SHRT_MAX
+ 1;
798 if (n
->child
== NULL
)
799 n
->aux
= mt
->lmargin
[mt
->lmargincur
];
800 else if (a2roffsu(n
->child
->string
, &su
, SCALE_EN
))
801 n
->aux
= term_hspan(p
, &su
) / 24;
802 if (n
->aux
< 0 && (size_t)(-n
->aux
) > mt
->offset
)
803 n
->aux
= -mt
->offset
;
804 else if (n
->aux
> SHRT_MAX
)
805 n
->aux
= term_len(p
, p
->defindent
);
807 mt
->offset
+= n
->aux
;
808 p
->offset
= mt
->offset
;
809 p
->rmargin
= p
->maxrmargin
;
811 if (++mt
->lmarginsz
< MAXMARGINS
)
812 mt
->lmargincur
= mt
->lmarginsz
;
814 mt
->lmargin
[mt
->lmargincur
] = term_len(p
, p
->defindent
);
832 mt
->offset
-= n
->parent
->head
->aux
;
833 p
->offset
= mt
->offset
;
835 if (--mt
->lmarginsz
< MAXMARGINS
)
836 mt
->lmargincur
= mt
->lmarginsz
;
843 return n
->type
!= ROFFT_HEAD
;
850 if (n
->type
!= ROFFT_BLOCK
)
854 p
->flags
|= TERMP_NOSPACE
;
856 if (NULL
!= n
->child
->child
)
857 print_man_node(p
, mt
, n
->child
->child
, meta
);
859 p
->flags
|= TERMP_NOSPACE
;
864 print_man_node(DECL_ARGS
)
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.
876 if (*n
->string
== '\0') {
879 } else if (*n
->string
== ' ' && n
->flags
& NODE_LINE
&&
880 (p
->flags
& TERMP_NONEWLINE
) == 0)
883 term_word(p
, n
->string
);
887 if ( ! (n
->flags
& NODE_LINE
))
888 p
->flags
|= TERMP_NOSPACE
;
890 if (n
->next
!= NULL
&& ! (n
->next
->flags
& NODE_LINE
))
891 p
->flags
|= TERMP_NOSPACE
;
894 if (p
->tbl
.cols
== NULL
)
896 term_tbl(p
, n
->span
);
902 if (n
->tok
< ROFF_MAX
) {
907 assert(n
->tok
>= MAN_TH
&& n
->tok
<= MAN_MAX
);
908 if ( ! (MAN_NOTEXT
& termacts
[n
->tok
].flags
))
909 term_fontrepl(p
, TERMFONT_NONE
);
912 if (termacts
[n
->tok
].pre
)
913 c
= (*termacts
[n
->tok
].pre
)(p
, mt
, n
, meta
);
916 print_man_nodelist(p
, mt
, n
->child
, meta
);
918 if (termacts
[n
->tok
].post
)
919 (*termacts
[n
->tok
].post
)(p
, mt
, n
, meta
);
920 if ( ! (MAN_NOTEXT
& termacts
[n
->tok
].flags
))
921 term_fontrepl(p
, TERMFONT_NONE
);
925 * If we're in a literal context, make sure that words
926 * together on the same line stay together. This is a
927 * POST-printing call, so we check the NEXT word. Since
928 * -man doesn't have nested macros, we don't need to be
929 * more specific than this.
931 if (mt
->fl
& MANT_LITERAL
&&
932 ! (p
->flags
& (TERMP_NOBREAK
| TERMP_NONEWLINE
)) &&
933 (n
->next
== NULL
|| n
->next
->flags
& NODE_LINE
)) {
935 rmax
= p
->maxrmargin
;
936 p
->rmargin
= p
->maxrmargin
= TERM_MAXMARGIN
;
937 p
->flags
|= TERMP_NOSPACE
;
938 if (n
->string
!= NULL
&& *n
->string
!= '\0')
942 if (rm
< rmax
&& n
->parent
->tok
== MAN_HP
) {
947 p
->maxrmargin
= rmax
;
949 if (NODE_EOS
& n
->flags
)
950 p
->flags
|= TERMP_SENTENCE
;
955 print_man_nodelist(DECL_ARGS
)
959 print_man_node(p
, mt
, n
, meta
);
965 print_man_foot(struct termp
*p
, const struct roff_meta
*meta
)
968 size_t datelen
, titlen
;
974 term_fontrepl(p
, TERMFONT_NONE
);
980 * Temporary, undocumented option to imitate mdoc(7) output.
981 * In the bottom right corner, use the operating system
982 * instead of the title.
985 if ( ! p
->mdocstyle
) {
990 mandoc_asprintf(&title
, "%s(%s)",
991 meta
->title
, meta
->msec
);
992 } else if (meta
->os
) {
993 title
= mandoc_strdup(meta
->os
);
995 title
= mandoc_strdup("");
997 datelen
= term_strlen(p
, meta
->date
);
999 /* Bottom left corner: operating system. */
1001 p
->flags
|= TERMP_NOSPACE
| TERMP_NOBREAK
;
1004 p
->rmargin
= p
->maxrmargin
> datelen
?
1005 (p
->maxrmargin
+ term_len(p
, 1) - datelen
) / 2 : 0;
1008 term_word(p
, meta
->os
);
1011 /* At the bottom in the middle: manual date. */
1013 p
->offset
= p
->rmargin
;
1014 titlen
= term_strlen(p
, title
);
1015 p
->rmargin
= p
->maxrmargin
> titlen
? p
->maxrmargin
- titlen
: 0;
1016 p
->flags
|= TERMP_NOSPACE
;
1018 term_word(p
, meta
->date
);
1021 /* Bottom right corner: manual title and section. */
1023 p
->flags
&= ~TERMP_NOBREAK
;
1024 p
->flags
|= TERMP_NOSPACE
;
1026 p
->offset
= p
->rmargin
;
1027 p
->rmargin
= p
->maxrmargin
;
1029 term_word(p
, title
);
1035 print_man_head(struct termp
*p
, const struct roff_meta
*meta
)
1039 size_t vollen
, titlen
;
1041 assert(meta
->title
);
1044 volume
= NULL
== meta
->vol
? "" : meta
->vol
;
1045 vollen
= term_strlen(p
, volume
);
1047 /* Top left corner: manual title and section. */
1049 mandoc_asprintf(&title
, "%s(%s)", meta
->title
, meta
->msec
);
1050 titlen
= term_strlen(p
, title
);
1052 p
->flags
|= TERMP_NOBREAK
| TERMP_NOSPACE
;
1055 p
->rmargin
= 2 * (titlen
+1) + vollen
< p
->maxrmargin
?
1056 (p
->maxrmargin
- vollen
+ term_len(p
, 1)) / 2 :
1057 vollen
< p
->maxrmargin
? p
->maxrmargin
- vollen
: 0;
1059 term_word(p
, title
);
1062 /* At the top in the middle: manual volume. */
1064 p
->flags
|= TERMP_NOSPACE
;
1065 p
->offset
= p
->rmargin
;
1066 p
->rmargin
= p
->offset
+ vollen
+ titlen
< p
->maxrmargin
?
1067 p
->maxrmargin
- titlen
: p
->maxrmargin
;
1069 term_word(p
, volume
);
1072 /* Top right corner: title and section, again. */
1074 p
->flags
&= ~TERMP_NOBREAK
;
1076 if (p
->rmargin
+ titlen
<= p
->maxrmargin
) {
1077 p
->flags
|= TERMP_NOSPACE
;
1078 p
->offset
= p
->rmargin
;
1079 p
->rmargin
= p
->maxrmargin
;
1080 term_word(p
, title
);
1084 p
->flags
&= ~TERMP_NOSPACE
;
1086 p
->rmargin
= p
->maxrmargin
;
1089 * Groff prints three blank lines before the content.
1090 * Do the same, except in the temporary, undocumented
1091 * mode imitating mdoc(7) output.
1095 if ( ! p
->mdocstyle
) {