Initial import from FreeBSD RELENG_4:
[games.git] / contrib / awk / doc / macros
1 .\" SSC Reference card macros
2 .\"
3 .\" Copyright (C) 1996, Specialized System Consultants Inc. (SSC)
4 .\" 
5 .\" These macros are free software; you can redistribute them and/or modify
6 .\" them under the terms of the GNU General Public License as published by
7 .\" the Free Software Foundation; either version 2 of the License, or
8 .\" (at your option) any later version.
9 .\" 
10 .\" These macros are distributed in the hope that it will be useful,
11 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
12 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 .\" GNU General Public License for more details.
14 .\" 
15 .\" You should have received a copy of the GNU General Public License
16 .\" along with this program; if not, write to the Free Software
17 .\" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
18 .\"
19 .\"     Generic SSC "card" macros
20 .\"     based on lots of other macros
21 .\"     Last update: 4-25-91 ph
22 .\"     attempting to get margins in the boxes Aug  3 09:43:48 PDT 1994
23 .ll 3i          \" length of text line
24 .lt 3.2i        \" length of title line 
25 .de BT  \" bottom of page trap
26 .sp |8.2i               \" go to where we put footer
27 .ie \\n(CL=1 \{\
28 .       nr CL 2
29 .tl ''\\*(CD\\n+(PN''   \" footer is just page number
30 .       po 4i           \" go to second column
31 .TP                     \" print header if any
32 \}
33 .el \{\
34 .       nr CL 1
35 .tl ''\\*(CD\\n+(PN''   \" footer is just page number
36 .       po .5i          \" go to first column
37 .       bp              \" force a new page (which will force header)
38 .       TP
39 \}
40 ..
41 .de TP  \" top of page
42 .\" .sp |.2i
43 .sp |0
44 .\" put page header stuff here 
45 .\" for example: .tl ''WOW!''
46 .\".sp
47 ..
48 .\" .wh 8.1i BT                 \" set bottom of column trap
49 .nf                     \" don't fill lines
50 .nh                     \" no hyphenation
51 .nr CL 1                \" start with column = 1
52 .po .5i                 \" offset for first column
53 .vs 9                   \" line spacing
54 .ps 8                   \" point size
55 .de ST  \" set tabs to normal places
56 .ta .2i .78i 1.2i 1.7i  \" set tabs 
57 ..
58 .ig
59     From: bryang@chinet.chi.il.us (Bryan Glennon)
60     Box macro.  Do a .mk z where the box is to start, and a .eb
61     where it is to end.  Optional argument is a title to be centered
62     within the top box line.
63    
64     Usage:
65    
66      .mk z
67      Text, etc to be boxed...
68      .eb "Optional title goes here"
69     
70      ~or~
71    
72      .mk z
73      Text, etc to be boxed...
74      .eb 
75    
76    
77     Some explanation:
78      The macro name is eb <.de eb>.  First thing we do is to go up on line
79      <.sp -1> and turn off fill mode <.nf>.  Now it gets interesting: the
80     .ie is the if/else construct.  We check the number of arguments provided
81     to the macro <\\n(.$> and if it is greater than 0 (meaning we have a title),
82     we do the rest of the .ie line, as follows:
83    
84                          \h'-.5n'     - move left one-half of an n
85                          \L'|\\nzu-1' - draw a vertical line <\L> to the 
86                                         absolute position (|) given by \\nzu-1,
87                                         which is the position set with the .mk 
88                                         command into register z <\\nz> in base 
89                                         units <u> minus 1.
90     \l'(\\n(.lu+1n-\w'\\$1'u/2u)\(ul' - Draw a horizontal line <\l> with length
91                                         equal to the current line length 
92                                         <\\n(.l> in base units <u> plus the 
93                                         space required for an 'n' <1n>, minus 
94                                         the width <\w> of the title string 
95                                         <\\$1> in base units <u> divided by 2 
96                                         <in base units <u>>.  Draw the line 
97                                         using the underline character, <\(ul>.
98              \v'.3m'\|\\$1\|\v'-.3m' -  Move down the page 3/10 of an m,
99                                         <\v'.3m'>, output a 1/6 of an m space
100                                         <\|>, output the title <\\$1>, another
101                                         1/6 of an m space <\|>, and then move
102                                         up the page 3/10 of an m <\v'-.3m'>.
103                          \l'...\(ul' -  Draw the second part of the line, just
104                                         like the corresponding left half done
105                                         before.
106                        \L'-|\\nzu+1' -  Draw a verticle line <\L> going down
107                                         the absolute distance <-|> from where 
108                                         the macro was given to where the start 
109                                         point was marked <\\nz> in base units
110                                         <u> plus one line <+1>
111                      \l'|0u-.5n\(ul' -  Draw a horizontal line to the absolute
112                                         position (|0) when the macro was 
113                                         invoked, minus half an n <-.5n> using
114                                         the underline character <\(ul>.
115    
116        The .el beings the else part, which is identical to the above, except
117        the string dosen't get printed.  This makes the printing of the top
118        line much easier: just draw a line <\l> with width equal to the
119        current line plus the witdh of an n <\\n(.l+1n> using the underline
120        character <.\(ul>.
121 ..
122 .de ES  \" start "text in a box"
123 .mk z
124 .in +.5n
125 .ll -.5n
126 .sp 1.3
127 ..
128 .de EB  \" end "text in a box" -- optional box title as argument
129 .sp -.6
130 .nf
131 .in -.5n
132 .ll +.5n
133 .ie \\n(.$\
134 \L'|\\nzu'\
135 \l'(\\n(.lu-\w'\\$1'u)/2u-.33m\(ul'\
136 \v'.3m'\|\\$1\|\v'-.3m'\
137 \l'(\\n(.lu-\w'\\$1'u)/2u\(ul'\
138 \L'-|\\nzu'\
139 \l'|0u\(ul'
140 .el \h'-.5n'\L'|\\nzu-1'\l'\\n(.lu+1n\(ul'\L'-|\\nzu+1'\l'|0u-.5n\(ul'
141 .in 0
142 ..
143 .de SL  \" draw single line (works in non-fill mode only)
144 .sp -.8
145 .ti 0
146 \l'\\n(.lu\(ul'
147 ..
148 .de Hl \" draw horizontal line
149 .br
150 .ti 0
151 \l'\\n(.lu-\\n(.iu'
152 .br
153 ..
154 .de DL  \" draw double line (works in non-fill mode only)
155 .sp -.8
156 .ti 0
157 \l'\\n(.lu\(ul'
158 .sp -.8
159 .ti 0
160 \l'\\n(.lu\(ul'
161 ..
162 .ST
163 .nr PN 0 1      \" sets starting page number and auto-increment
164 .\" must define page header (if any) before here
165 .TP
166 .ds 3) \|\v'3p'\s+5\z\(sq\s0\v'-3p'\h'1.25p'\v'-.5p'3\v'.5p'\h'2p'
167 .\" old one .ds 2) \h'-1.5p'\v'1p'\s+4\z\(ci\s0\v'-1p'\h'3.25p'2
168 .ds 2) \|\v'-2.4p'\D'c.095id'\h'-5.15p'\v'2.4p'2\h'1.9p'
169 .ds dC \v'1p'\s+5\(bu\s0\v'-1p'\" for development commands
170 .ds tC \s+2\(dm\s0\" (for DWB) should be a triangle
171 .ds tP \s+2\(dm\s0\" (for other text processing) should be a triangle
172 .\" various trademark symbols
173 .ds Tm \v'-0.5m'\s8TM\s0\v'0.5m'
174 .ds Ts \v'-0.5m'\s4TM\s0\v'0.5m'
175 .ig ++
176 .\" mount Serifa fonts
177 .fp 5 SR
178 .fp 6 SB
179 .fp 4 Si
180 .++
181 .\" other assorted junk
182 .lg 0
183 .\" Fl requires extended version of troff
184 .de Fl \" draw fat horizontal line
185 .br
186 .ti 0
187 .ruw 1.5p
188 \l'\\n(.lu-\\n(.iu'
189 .br
190 .ruw
191 ..
192 .de Bx \" box for keys in text
193 \\$3\&\|\&\c
194 \s-3\(br\|\fH\v'.18n'\\$1\v'-.18n\fP\|\(br\l'|0\(rn'\l'|0\(ul'\&\s0\|\\$2
195 ..
196 .de Fn  \" function name - left justified, gray background
197 .\" bold with gray for function name
198 .ns
199 .br
200
201 .ns
202 .br
203 \!! gsave ( ) stringwidth neg 0 rmoveto
204 \!! /Serifa-Bold findfont 8 scalefont setfont
205 \!! (\\$1) dup stringwidth pop 6 gsave dup 0 exch rlineto neg exch 0 rlineto
206 \!! 0 exch rlineto closepath .9 setgray fill grestore show
207 \!! grestore
208 .nf
209 .rs
210 ..
211 .rs