]>
git.cameronkatri.com Git - mandoc.git/blob - man_term.c
1 /* $Id: man_term.c,v 1.165 2014/12/24 18:04:10 schwarze Exp $ */
3 * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2010-2014 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 AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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>
30 #include "mandoc_aux.h"
36 #define MAXMARGINS 64 /* maximum number of indented scopes */
40 #define MANT_LITERAL (1 << 0)
41 int lmargin
[MAXMARGINS
]; /* margins (incl. vis. page) */
42 int lmargincur
; /* index of current margin */
43 int lmarginsz
; /* actual number of nested margins */
44 size_t offset
; /* default offset to visible page */
45 int pardist
; /* vert. space before par., unit: [v] */
48 #define DECL_ARGS struct termp *p, \
51 const struct man_meta *meta
54 int (*pre
)(DECL_ARGS
);
55 void (*post
)(DECL_ARGS
);
57 #define MAN_NOTEXT (1 << 0) /* Never has text children. */
60 static void print_man_nodelist(DECL_ARGS
);
61 static void print_man_node(DECL_ARGS
);
62 static void print_man_head(struct termp
*, const void *);
63 static void print_man_foot(struct termp
*, const void *);
64 static void print_bvspace(struct termp
*,
65 const struct man_node
*, int);
67 static int pre_B(DECL_ARGS
);
68 static int pre_HP(DECL_ARGS
);
69 static int pre_I(DECL_ARGS
);
70 static int pre_IP(DECL_ARGS
);
71 static int pre_OP(DECL_ARGS
);
72 static int pre_PD(DECL_ARGS
);
73 static int pre_PP(DECL_ARGS
);
74 static int pre_RS(DECL_ARGS
);
75 static int pre_SH(DECL_ARGS
);
76 static int pre_SS(DECL_ARGS
);
77 static int pre_TP(DECL_ARGS
);
78 static int pre_UR(DECL_ARGS
);
79 static int pre_alternate(DECL_ARGS
);
80 static int pre_ft(DECL_ARGS
);
81 static int pre_ign(DECL_ARGS
);
82 static int pre_in(DECL_ARGS
);
83 static int pre_literal(DECL_ARGS
);
84 static int pre_ll(DECL_ARGS
);
85 static int pre_sp(DECL_ARGS
);
87 static void post_IP(DECL_ARGS
);
88 static void post_HP(DECL_ARGS
);
89 static void post_RS(DECL_ARGS
);
90 static void post_SH(DECL_ARGS
);
91 static void post_SS(DECL_ARGS
);
92 static void post_TP(DECL_ARGS
);
93 static void post_UR(DECL_ARGS
);
95 static const struct termact termacts
[MAN_MAX
] = {
96 { pre_sp
, NULL
, MAN_NOTEXT
}, /* br */
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_ign
, NULL
, MAN_NOTEXT
}, /* na */
118 { pre_sp
, NULL
, MAN_NOTEXT
}, /* sp */
119 { pre_literal
, NULL
, 0 }, /* nf */
120 { pre_literal
, NULL
, 0 }, /* fi */
121 { NULL
, NULL
, 0 }, /* RE */
122 { pre_RS
, post_RS
, 0 }, /* RS */
123 { pre_ign
, NULL
, 0 }, /* DT */
124 { pre_ign
, NULL
, MAN_NOTEXT
}, /* UC */
125 { pre_PD
, NULL
, MAN_NOTEXT
}, /* PD */
126 { pre_ign
, NULL
, 0 }, /* AT */
127 { pre_in
, NULL
, MAN_NOTEXT
}, /* in */
128 { pre_ft
, NULL
, MAN_NOTEXT
}, /* ft */
129 { pre_OP
, NULL
, 0 }, /* OP */
130 { pre_literal
, NULL
, 0 }, /* EX */
131 { pre_literal
, NULL
, 0 }, /* EE */
132 { pre_UR
, post_UR
, 0 }, /* UR */
133 { NULL
, NULL
, 0 }, /* UE */
134 { pre_ll
, NULL
, MAN_NOTEXT
}, /* ll */
139 terminal_man(void *arg
, const struct man
*man
)
142 const struct man_meta
*meta
;
146 p
= (struct termp
*)arg
;
149 p
->rmargin
= p
->maxrmargin
= p
->defrmargin
;
150 p
->tabwidth
= term_len(p
, 5);
152 n
= man_node(man
)->child
;
153 meta
= man_meta(man
);
155 memset(&mt
, 0, sizeof(struct mtermp
));
157 mt
.lmargin
[mt
.lmargincur
] = term_len(p
, p
->defindent
);
158 mt
.offset
= term_len(p
, p
->defindent
);
161 if (p
->synopsisonly
) {
163 if (n
->tok
== MAN_SH
&&
164 n
->child
->child
->type
== MAN_TEXT
&&
165 !strcmp(n
->child
->child
->string
, "SYNOPSIS")) {
166 if (n
->child
->next
->child
!= NULL
)
167 print_man_nodelist(p
, &mt
,
168 n
->child
->next
->child
, meta
);
175 if (p
->defindent
== 0)
177 term_begin(p
, print_man_head
, print_man_foot
, meta
);
178 p
->flags
|= TERMP_NOSPACE
;
180 print_man_nodelist(p
, &mt
, n
, meta
);
186 * Printing leading vertical space before a block.
187 * This is used for the paragraph macros.
188 * The rules are pretty simple, since there's very little nesting going
189 * on here. Basically, if we're the first within another block (SS/SH),
190 * then don't emit vertical space. If we are (RS), then do. If not the
194 print_bvspace(struct termp
*p
, const struct man_node
*n
, int pardist
)
200 if (n
->body
&& n
->body
->child
)
201 if (MAN_TBL
== n
->body
->child
->type
)
204 if (MAN_ROOT
== n
->parent
->type
|| MAN_RS
!= n
->parent
->tok
)
208 for (i
= 0; i
< pardist
; i
++)
224 term_setwidth(p
, n
->nchild
? n
->child
->string
: NULL
);
232 term_fontrepl(p
, TERMFONT_UNDER
);
237 pre_literal(DECL_ARGS
)
242 if (MAN_nf
== n
->tok
|| MAN_EX
== n
->tok
)
243 mt
->fl
|= MANT_LITERAL
;
245 mt
->fl
&= ~MANT_LITERAL
;
248 * Unlike .IP and .TP, .HP does not have a HEAD.
249 * So in case a second call to term_flushln() is needed,
250 * indentation has to be set up explicitly.
252 if (MAN_HP
== n
->parent
->tok
&& p
->rmargin
< p
->maxrmargin
) {
253 p
->offset
= p
->rmargin
;
254 p
->rmargin
= p
->maxrmargin
;
256 p
->flags
&= ~(TERMP_NOBREAK
| TERMP_BRIND
);
257 p
->flags
|= TERMP_NOSPACE
;
273 assert(MAN_TEXT
== n
->type
);
274 if (a2roffsu(n
->string
, &su
, SCALE_VS
))
275 mt
->pardist
= term_vspan(p
, &su
);
280 pre_alternate(DECL_ARGS
)
282 enum termfont font
[2];
288 font
[0] = TERMFONT_NONE
;
289 font
[1] = TERMFONT_BOLD
;
292 font
[0] = TERMFONT_NONE
;
293 font
[1] = TERMFONT_UNDER
;
296 font
[0] = TERMFONT_BOLD
;
297 font
[1] = TERMFONT_NONE
;
300 font
[0] = TERMFONT_BOLD
;
301 font
[1] = TERMFONT_UNDER
;
304 font
[0] = TERMFONT_UNDER
;
305 font
[1] = TERMFONT_NONE
;
308 font
[0] = TERMFONT_UNDER
;
309 font
[1] = TERMFONT_BOLD
;
315 savelit
= MANT_LITERAL
& mt
->fl
;
316 mt
->fl
&= ~MANT_LITERAL
;
318 for (i
= 0, nn
= n
->child
; nn
; nn
= nn
->next
, i
= 1 - i
) {
319 term_fontrepl(p
, font
[i
]);
320 if (savelit
&& NULL
== nn
->next
)
321 mt
->fl
|= MANT_LITERAL
;
322 print_man_node(p
, mt
, nn
, meta
);
324 p
->flags
|= TERMP_NOSPACE
;
334 term_fontrepl(p
, TERMFONT_BOLD
);
343 p
->flags
|= TERMP_NOSPACE
;
345 if (NULL
!= (n
= n
->child
)) {
346 term_fontrepl(p
, TERMFONT_BOLD
);
347 term_word(p
, n
->string
);
349 if (NULL
!= n
&& NULL
!= n
->next
) {
350 term_fontrepl(p
, TERMFONT_UNDER
);
351 term_word(p
, n
->next
->string
);
354 term_fontrepl(p
, TERMFONT_NONE
);
355 p
->flags
|= TERMP_NOSPACE
;
365 if (NULL
== n
->child
) {
370 cp
= n
->child
->string
;
377 term_fontrepl(p
, TERMFONT_BOLD
);
382 term_fontrepl(p
, TERMFONT_UNDER
);
392 term_fontrepl(p
, TERMFONT_NONE
);
410 if (NULL
== n
->child
) {
411 p
->offset
= mt
->offset
;
415 cp
= n
->child
->string
;
425 if ( ! a2roffsu(++cp
, &su
, SCALE_EN
))
428 v
= term_hspan(p
, &su
);
431 p
->offset
-= p
->offset
> v
? v
: p
->offset
;
436 if (p
->offset
> SHRT_MAX
)
437 p
->offset
= term_len(p
, p
->defindent
);
448 if ((NULL
== n
->prev
&& n
->parent
)) {
449 switch (n
->parent
->tok
) {
466 if (n
->tok
== MAN_br
)
468 else if (n
->child
== NULL
)
471 if ( ! a2roffsu(n
->child
->string
, &su
, SCALE_VS
))
473 len
= term_vspan(p
, &su
);
481 for (i
= 0; i
< len
; i
++)
491 const struct man_node
*nn
;
496 print_bvspace(p
, n
, mt
->pardist
);
504 if ( ! (MANT_LITERAL
& mt
->fl
)) {
505 p
->flags
|= TERMP_NOBREAK
| TERMP_BRIND
;
509 /* Calculate offset. */
511 if ((nn
= n
->parent
->head
->child
) != NULL
&&
512 a2roffsu(nn
->string
, &su
, SCALE_EN
)) {
513 len
= term_hspan(p
, &su
);
514 if (len
< 0 && (size_t)(-len
) > mt
->offset
)
516 else if (len
> SHRT_MAX
)
517 len
= term_len(p
, p
->defindent
);
518 mt
->lmargin
[mt
->lmargincur
] = len
;
520 len
= mt
->lmargin
[mt
->lmargincur
];
522 p
->offset
= mt
->offset
;
523 p
->rmargin
= mt
->offset
+ len
;
534 p
->flags
&= ~(TERMP_NOBREAK
| TERMP_BRIND
);
536 p
->offset
= mt
->offset
;
537 p
->rmargin
= p
->maxrmargin
;
550 mt
->lmargin
[mt
->lmargincur
] = term_len(p
, p
->defindent
);
551 print_bvspace(p
, n
, mt
->pardist
);
554 p
->offset
= mt
->offset
;
558 return(MAN_HEAD
!= n
->type
);
565 const struct man_node
*nn
;
570 p
->flags
|= TERMP_NOSPACE
;
573 p
->flags
|= TERMP_NOBREAK
;
577 print_bvspace(p
, n
, mt
->pardist
);
583 /* Calculate the offset from the optional second argument. */
584 if ((nn
= n
->parent
->head
->child
) != NULL
&&
585 (nn
= nn
->next
) != NULL
&&
586 a2roffsu(nn
->string
, &su
, SCALE_EN
)) {
587 len
= term_hspan(p
, &su
);
588 if (len
< 0 && (size_t)(-len
) > mt
->offset
)
590 else if (len
> SHRT_MAX
)
591 len
= term_len(p
, p
->defindent
);
592 mt
->lmargin
[mt
->lmargincur
] = len
;
594 len
= mt
->lmargin
[mt
->lmargincur
];
598 p
->offset
= mt
->offset
;
599 p
->rmargin
= mt
->offset
+ len
;
601 savelit
= MANT_LITERAL
& mt
->fl
;
602 mt
->fl
&= ~MANT_LITERAL
;
605 print_man_node(p
, mt
, n
->child
, meta
);
608 mt
->fl
|= MANT_LITERAL
;
612 p
->offset
= mt
->offset
+ len
;
613 p
->rmargin
= p
->maxrmargin
;
629 p
->flags
&= ~TERMP_NOBREAK
;
631 p
->rmargin
= p
->maxrmargin
;
635 p
->offset
= mt
->offset
;
651 p
->flags
|= TERMP_NOBREAK
;
655 p
->flags
|= TERMP_NOSPACE
;
658 print_bvspace(p
, n
, mt
->pardist
);
664 /* Calculate offset. */
666 if ((nn
= n
->parent
->head
->child
) != NULL
&&
667 nn
->string
!= NULL
&& ! (MAN_LINE
& nn
->flags
) &&
668 a2roffsu(nn
->string
, &su
, SCALE_EN
)) {
669 len
= term_hspan(p
, &su
);
670 if (len
< 0 && (size_t)(-len
) > mt
->offset
)
672 else if (len
> SHRT_MAX
)
673 len
= term_len(p
, p
->defindent
);
674 mt
->lmargin
[mt
->lmargincur
] = len
;
676 len
= mt
->lmargin
[mt
->lmargincur
];
680 p
->offset
= mt
->offset
;
681 p
->rmargin
= mt
->offset
+ len
;
683 savelit
= MANT_LITERAL
& mt
->fl
;
684 mt
->fl
&= ~MANT_LITERAL
;
686 /* Don't print same-line elements. */
688 while (NULL
!= nn
&& 0 == (MAN_LINE
& nn
->flags
))
692 print_man_node(p
, mt
, nn
, meta
);
697 mt
->fl
|= MANT_LITERAL
;
700 p
->offset
= mt
->offset
+ len
;
701 p
->rmargin
= p
->maxrmargin
;
703 p
->flags
&= ~TERMP_NOBREAK
;
722 p
->offset
= mt
->offset
;
736 mt
->fl
&= ~MANT_LITERAL
;
737 mt
->lmargin
[mt
->lmargincur
] = term_len(p
, p
->defindent
);
738 mt
->offset
= term_len(p
, p
->defindent
);
741 * No vertical space before the first subsection
742 * and after an empty subsection.
747 } while (n
!= NULL
&& termacts
[n
->tok
].flags
& MAN_NOTEXT
);
748 if (n
== NULL
|| (n
->tok
== MAN_SS
&& n
->body
->child
== NULL
))
751 for (i
= 0; i
< mt
->pardist
; i
++)
755 term_fontrepl(p
, TERMFONT_BOLD
);
756 p
->offset
= term_len(p
, 3);
759 p
->offset
= mt
->offset
;
791 mt
->fl
&= ~MANT_LITERAL
;
792 mt
->lmargin
[mt
->lmargincur
] = term_len(p
, p
->defindent
);
793 mt
->offset
= term_len(p
, p
->defindent
);
796 * No vertical space before the first section
797 * and after an empty section.
802 } while (n
!= NULL
&& termacts
[n
->tok
].flags
& MAN_NOTEXT
);
803 if (n
== NULL
|| (n
->tok
== MAN_SH
&& n
->body
->child
== NULL
))
806 for (i
= 0; i
< mt
->pardist
; i
++)
810 term_fontrepl(p
, TERMFONT_BOLD
);
814 p
->offset
= mt
->offset
;
855 n
->aux
= SHRT_MAX
+ 1;
856 if (n
->child
!= NULL
&& a2roffsu(n
->child
->string
, &su
, SCALE_EN
))
857 n
->aux
= term_hspan(p
, &su
);
858 if (n
->aux
< 0 && (size_t)(-n
->aux
) > mt
->offset
)
859 n
->aux
= -mt
->offset
;
860 else if (n
->aux
> SHRT_MAX
)
861 n
->aux
= term_len(p
, p
->defindent
);
863 mt
->offset
+= n
->aux
;
864 p
->offset
= mt
->offset
;
865 p
->rmargin
= p
->maxrmargin
;
867 if (++mt
->lmarginsz
< MAXMARGINS
)
868 mt
->lmargincur
= mt
->lmarginsz
;
870 mt
->lmargin
[mt
->lmargincur
] = mt
->lmargin
[mt
->lmargincur
- 1];
888 mt
->offset
-= n
->parent
->head
->aux
;
889 p
->offset
= mt
->offset
;
891 if (--mt
->lmarginsz
< MAXMARGINS
)
892 mt
->lmargincur
= mt
->lmarginsz
;
899 return (MAN_HEAD
!= n
->type
);
906 if (MAN_BLOCK
!= n
->type
)
910 p
->flags
|= TERMP_NOSPACE
;
912 if (NULL
!= n
->child
->child
)
913 print_man_node(p
, mt
, n
->child
->child
, meta
);
915 p
->flags
|= TERMP_NOSPACE
;
920 print_man_node(DECL_ARGS
)
928 * If we have a blank line, output a vertical space.
929 * If we have a space as the first character, break
930 * before printing the line's data.
932 if ('\0' == *n
->string
) {
935 } else if (' ' == *n
->string
&& MAN_LINE
& n
->flags
)
938 term_word(p
, n
->string
);
942 if ( ! (n
->flags
& MAN_LINE
))
943 p
->flags
|= TERMP_NOSPACE
;
945 if (n
->next
!= NULL
&& ! (n
->next
->flags
& MAN_LINE
))
946 p
->flags
|= TERMP_NOSPACE
;
950 * Tables are preceded by a newline. Then process a
951 * table line, which will cause line termination,
953 if (TBL_SPAN_FIRST
& n
->span
->flags
)
955 term_tbl(p
, n
->span
);
961 if ( ! (MAN_NOTEXT
& termacts
[n
->tok
].flags
))
962 term_fontrepl(p
, TERMFONT_NONE
);
965 if (termacts
[n
->tok
].pre
)
966 c
= (*termacts
[n
->tok
].pre
)(p
, mt
, n
, meta
);
969 print_man_nodelist(p
, mt
, n
->child
, meta
);
971 if (termacts
[n
->tok
].post
)
972 (*termacts
[n
->tok
].post
)(p
, mt
, n
, meta
);
973 if ( ! (MAN_NOTEXT
& termacts
[n
->tok
].flags
))
974 term_fontrepl(p
, TERMFONT_NONE
);
978 * If we're in a literal context, make sure that words
979 * together on the same line stay together. This is a
980 * POST-printing call, so we check the NEXT word. Since
981 * -man doesn't have nested macros, we don't need to be
982 * more specific than this.
984 if (mt
->fl
& MANT_LITERAL
&&
985 ! (p
->flags
& (TERMP_NOBREAK
| TERMP_NONEWLINE
)) &&
986 (n
->next
== NULL
|| n
->next
->flags
& MAN_LINE
)) {
988 rmax
= p
->maxrmargin
;
989 p
->rmargin
= p
->maxrmargin
= TERM_MAXMARGIN
;
990 p
->flags
|= TERMP_NOSPACE
;
991 if (n
->string
!= NULL
&& *n
->string
!= '\0')
995 if (rm
< rmax
&& n
->parent
->tok
== MAN_HP
) {
1000 p
->maxrmargin
= rmax
;
1002 if (MAN_EOS
& n
->flags
)
1003 p
->flags
|= TERMP_SENTENCE
;
1008 print_man_nodelist(DECL_ARGS
)
1011 print_man_node(p
, mt
, n
, meta
);
1014 print_man_nodelist(p
, mt
, n
->next
, meta
);
1018 print_man_foot(struct termp
*p
, const void *arg
)
1020 const struct man_meta
*meta
;
1022 size_t datelen
, titlen
;
1024 meta
= (const struct man_meta
*)arg
;
1025 assert(meta
->title
);
1029 term_fontrepl(p
, TERMFONT_NONE
);
1035 * Temporary, undocumented option to imitate mdoc(7) output.
1036 * In the bottom right corner, use the source instead of
1040 if ( ! p
->mdocstyle
) {
1041 if (meta
->hasbody
) {
1045 mandoc_asprintf(&title
, "%s(%s)",
1046 meta
->title
, meta
->msec
);
1047 } else if (meta
->source
) {
1048 title
= mandoc_strdup(meta
->source
);
1050 title
= mandoc_strdup("");
1052 datelen
= term_strlen(p
, meta
->date
);
1054 /* Bottom left corner: manual source. */
1056 p
->flags
|= TERMP_NOSPACE
| TERMP_NOBREAK
;
1059 p
->rmargin
= p
->maxrmargin
> datelen
?
1060 (p
->maxrmargin
+ term_len(p
, 1) - datelen
) / 2 : 0;
1063 term_word(p
, meta
->source
);
1066 /* At the bottom in the middle: manual date. */
1068 p
->offset
= p
->rmargin
;
1069 titlen
= term_strlen(p
, title
);
1070 p
->rmargin
= p
->maxrmargin
> titlen
? p
->maxrmargin
- titlen
: 0;
1071 p
->flags
|= TERMP_NOSPACE
;
1073 term_word(p
, meta
->date
);
1076 /* Bottom right corner: manual title and section. */
1078 p
->flags
&= ~TERMP_NOBREAK
;
1079 p
->flags
|= TERMP_NOSPACE
;
1081 p
->offset
= p
->rmargin
;
1082 p
->rmargin
= p
->maxrmargin
;
1084 term_word(p
, title
);
1090 print_man_head(struct termp
*p
, const void *arg
)
1092 const struct man_meta
*meta
;
1095 size_t vollen
, titlen
;
1097 meta
= (const struct man_meta
*)arg
;
1098 assert(meta
->title
);
1101 volume
= NULL
== meta
->vol
? "" : meta
->vol
;
1102 vollen
= term_strlen(p
, volume
);
1104 /* Top left corner: manual title and section. */
1106 mandoc_asprintf(&title
, "%s(%s)", meta
->title
, meta
->msec
);
1107 titlen
= term_strlen(p
, title
);
1109 p
->flags
|= TERMP_NOBREAK
| TERMP_NOSPACE
;
1112 p
->rmargin
= 2 * (titlen
+1) + vollen
< p
->maxrmargin
?
1113 (p
->maxrmargin
- vollen
+ term_len(p
, 1)) / 2 :
1114 vollen
< p
->maxrmargin
? p
->maxrmargin
- vollen
: 0;
1116 term_word(p
, title
);
1119 /* At the top in the middle: manual volume. */
1121 p
->flags
|= TERMP_NOSPACE
;
1122 p
->offset
= p
->rmargin
;
1123 p
->rmargin
= p
->offset
+ vollen
+ titlen
< p
->maxrmargin
?
1124 p
->maxrmargin
- titlen
: p
->maxrmargin
;
1126 term_word(p
, volume
);
1129 /* Top right corner: title and section, again. */
1131 p
->flags
&= ~TERMP_NOBREAK
;
1133 if (p
->rmargin
+ titlen
<= p
->maxrmargin
) {
1134 p
->flags
|= TERMP_NOSPACE
;
1135 p
->offset
= p
->rmargin
;
1136 p
->rmargin
= p
->maxrmargin
;
1137 term_word(p
, title
);
1141 p
->flags
&= ~TERMP_NOSPACE
;
1143 p
->rmargin
= p
->maxrmargin
;
1146 * Groff prints three blank lines before the content.
1147 * Do the same, except in the temporary, undocumented
1148 * mode imitating mdoc(7) output.
1152 if ( ! p
->mdocstyle
) {