4 .\" The contents of this file are subject to the terms of the
5 .\" Common Development and Distribution License, Version 1.0 only
6 .\" (the "License"). You may not use this file except in compliance
9 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 .\" or http://www.opensolaris.org/os/licensing.
11 .\" See the License for the specific language governing permissions
12 .\" and limitations under the License.
14 .\" When distributing Covered Code, include this CDDL HEADER in each
15 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 .\" If applicable, add the following below this CDDL HEADER, with the
17 .\" fields enclosed by brackets "[]" replaced with your own identifying
18 .\" information: Portions Copyright [yyyy] [name of copyright owner]
22 .\" ident "%Z%%M% %I% %E% SMI"
24 This version of tmac.vgrind is intended to interface more
25 gracefully to other macro packages than the previous version.
26 Rather than defining things irrevocably, with no way to alter
27 the definitions, this version encapsulates definitions and
28 changes in the operating environment into macros whose
29 definitions can be overriden as needed.
31 Guide to strings that vfontedpr generates code to define:
33 =H operand of vfontedpr's -h flag
34 =M time and date info for current file
36 Guide to number registers that vfontedpr generates code to define:
37 vP point size (in points) to use for main text. Pre-defined
38 only if the -s option was supplied to vfontedpr.
39 N.B.: does not affect headers or margin entries.
42 =f ellipsis string for current function
43 =G local copy of =F used to keep header and footer consistent
45 +K string used to start keyword; value depends on whether
46 or not a comment is active
47 -K string used to end keyword; value depends on whether
48 or not a comment is active
50 Internal number registers
51 v nonzero prevents cut marks (in theory, at least)
52 vC nonzero when in comment
54 To do: convert hard-wired point sizes, etc. to parameterized values.
56 XXX: vfontedpr has font 2 wired into it for comments; change to use
59 *** This version is also augmented with support for two column output.
61 N.B.: I haven't thought at all about how to make this work in
62 filter mode. Things will have to be redefined, as I rely on adding
63 hooks to the header and footer macros to flip from one column to
66 Additional register that vfontedpr defines:
67 =2 if nonzero, generate two column output.
69 Additional internal number registers.
70 v2 corrent column number: 0 == left, 1 == right
71 vH saved vertical position of top of left column; calculated
72 in vH when switching to left column and used in vF when
73 switching to the right column.
74 vO page offset in effect for left column (the original offset).
75 vR page offset in effect for right column.
76 vL saved line length in effect at beginning of new page.
77 vK line length in effect for each column.
82 sI: Initialize configurable strings
83 XXX: need better name for this macro.
84 This macro is called from the vI macro at initialization time.
85 It must define the following:
86 _ string representation for underscore
87 - string representation for minus
88 / string representation for slash, shifted horizontally so
89 that C-style comments will line up
90 /* string representation for /*, shifted horizontally so
91 that C-style comments will line up.
93 tC string comment font in .ft form (e.g., `BI')
94 fC string comment font in \f form (e.g., `(BI')
95 tK string keyword font in .ft form
96 fK string keyword font in \f form
97 tP string program font in .ft form
98 fP string program font in \f form
100 By redefining this macro, one can alter the appearance of vgrind's
106 'ds / \\h'\\w' 'u-\\w'/'u'/
107 'ds /* \\h'\\w' 'u-\\w'/'u'/*
121 This macro does nothing. It's defined as a place-holder to
122 '\" immediately precede \} constructs, to make editing easier.
128 vI: Initial definitions.
129 This macro is called once only, before any .vS -- .vE program
130 inclusions are processed (or before all input files, if they consist
131 solely of program text).
133 XXX: We assume that 2-column mode imples landscape output. Ideally, there
134 should be a separate -T<device> entry for the landscape version of the
135 output device, but that hasn't happened. Instead, all there is is a
136 "-L" flag to troff that does nothing more than rotate the resulting
137 PostScript 90 degrees. In particular, page lengths and widths are
138 unaffected. Thus, we hack altered values into place here. This is
142 '\" Deal with page length and width -- see above.
153 '\" If point size values haven't already been established, set them
154 '\" to suitable default values. The defaults are smaller for two column
164 '\" Force comment state indicators into the correct
165 '\" initial state. Convert the comment start macro
166 '\" to its final form.
177 vS: Start program text
178 This macro must be called at the start of a chunk of interpolated
179 program text. The version given here is a default version suitable
180 for standalone use -- that is, not in conjunction with some other
181 macro package. It should be redefined as necessary to coexist
182 gracefully with the macro package of your choice. Of course, the
183 redefined version should do the same things this version does.
185 It may be necessary to move the emboldening commands to the vI
186 macro, or remove them altogether. If they remain here, they will
187 probably have to be supplemented with copies of themselves that
188 are protected with the transparent throughput indicator.
192 '\" Set text point size and vertical spacing.
193 '\" XXX: All point size stuff should be parameterized, not just the
194 '\" primary text sizes.
198 '\" If in two column mode, reduce page offset to first column a bit
199 '\" and bump line length correspondingly.
200 '\" XXX: Aargh! More hard-wiring!
212 'nf \" When not run standalone, the host macro package
213 ' \" may well do this for us.
214 'nr vC 0 \" We're not in a comment.
215 'nr v2 0 \" start in left column
216 'nr vO \\n(.ou \" save page offset
217 'nr vL \\n(.lu \" save line length
218 'nr vR \\n(.ou+(\\n(.lu/2u)+(0.25i)u \" get right column offset
219 'ie \\n(=2 'nr vK (\\n(.lu/2u)-(0.25i)u \" get column width
225 This macro closes the chunk of program text started by vS. The
226 same comments apply to it that do for vS.
238 Only invoked when not in filter mode.
240 N.B.: This macro hard-wires the inter-column gap to 0.25i.
243 'v< \" Put out the header itself.
245 '\" In two column mode: we've trapped because we've moved to a new
246 '\" page. Save position information for later use. Squash down line
248 ' nr v2 0 1 \" reset column counter
249 ' mk vH \" save vertical position for later restoration
252 'v. \" Put out the column header
256 v<: Output page header
261 'if t 'if !\nv 'tl '\-\-''\-\-'
262 '\" Emit page header (file name at right and left page margins).
265 'tl '\s14\f3\\*(=F\fP\s0'\\*(=H'\f3\s14\\*(=F\fP\s0'
266 '\"'\" Emit the ellipsis string for the current function.
269 '\"\f2\s12\h'\\n(.lu-\w'\\*(=f'u'\\*(=f\fP\s0\h'|0u'
272 '\" Save current file name for use in footer.
277 v.: Output function ellipsis string as part of column header.
284 \f2\s12\h'\\n(vKu-\w'\\*(=f'u'\\*(=f\fP\s0\h'|0u'
287 'ns \" Suppress additional spacing.
292 Only invoked when not in filter mode.
294 If in two column mode, handles switching between columns.
296 N.B.: This macro hard-wires the inter-column gap to 0.25i.
300 '\" in two column mode
302 '\" Transition from left column to right.
303 '\" Construct a vertical line running down the center of the
306 ' nr vX (\\n(vLu/2u-(0.125i))u \" Horiz off to gutter center
310 '\" Move back to top of column and bump page offset to move
314 '\" Put out the current function ellipsis string.
319 '\" Transition from right column to left of next page: restore
320 '\" saved values and then output the footer.
330 v>: Output page footer
331 Called from vF when in single column mode or when it hits the
332 bottom of the left column.
337 'ie '\\*(=G'' 'tl '\f2\\*(=M''Page %\fP'
338 'el 'tl '\f2\\*(=M''Page % of \\*(=G\fP'
342 'if \\n(vC=1 'ft \\*(tC
347 Only invoked when not in filter mode. Called between input files,
348 to reset page numbering for each.
375 FN: function definition
376 Issues marginal notation giving function's name.
377 Issues the primary index entry for it.
378 Sets the =f string to record a continuation entry for it
379 (e.g., " ...func-name").
382 \f2\s14\h'\\n(vKu-\w'\\$1'u'\\$1\fP\s0\h'|0u'\c
383 .if \\nx .tm \\$1 \\*(=F \\n%
388 FC: function continuation
389 Issues index entry for where the function definition picks up again.
390 Sets the =f string to record a continuation entry for it
391 (e.g., " ...func-name").
394 .if \\nx .tm \\$1 \\*(=F \\n%
400 Removes definition of =f string so that the marginal entry for
401 function continuation will no longer appear.