3 %%% Styles and other hacking for the Sod manual
5 %%% (c) 2015 Straylight/Edgeware
8 %%%----- Licensing notice ---------------------------------------------------
10 %%% This file is part of the Sensible Object Design, an object system for C.
12 %%% SOD is free software; you can redistribute it and/or modify
13 %%% it under the terms of the GNU General Public License as published by
14 %%% the Free Software Foundation; either version 2 of the License, or
15 %%% (at your option) any later version.
17 %%% SOD is distributed in the hope that it will be useful,
18 %%% but WITHOUT ANY WARRANTY; without even the implied warranty of
19 %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 %%% GNU General Public License for more details.
22 %%% You should have received a copy of the GNU General Public License
23 %%% along with SOD; if not, write to the Free Software Foundation,
24 %%% Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 %% More reference types.
31 %% Other languages with special typesetting.
32 \def\Cplusplus{C\kern-\p@++}
35 %% Special maths notation.
36 \def\chain#1#2{\mathsf{ch}_{#1}(#2)}
37 \def\chainhead#1#2{\mathsf{hd}_{#1}(#2)}
38 \def\chaintail#1#2{\mathsf{tl}_{#1}(#2)}
40 %% Other mathematical tweaks.
41 \let\implies\Rightarrow
42 \let\epsilon\varepsilon
44 %% A table heading cell. Clone and hack \multicolumn.
45 \def\thd{\omit\@ifnextchar[\thd@{\thd@[l]}}
48 \tab@multicol \tab@initread \let\tab@looped\tab@err@multi
49 \tab@preamble{}\def\tab@midtext{\bfseries#2}\tab@readpreamble{#1}%
51 \endgroup \ignorespaces
54 %% Unix manpage references.
55 \def\man#1#2{\textbf{#1}(#2)}
57 %% Listings don't need to be small.
58 \let\listingsize\relax
61 \def\fixme#1{\leavevmode\marginpar{FIXME}[FIXME: #1]}
63 %% Metavariables are italics without decoration.
64 \def\syntleft{\normalfont\itshape}
67 %% Literal code is in sans face.
68 \def\codeface{\upshape\sffamily}
69 \DeclareRobustCommand\code[1]{%
70 \ifmmode\hbox\else\leavevmode\fi%
71 {\normalfont\codeface\/#1\/}%
73 \def\ulitleft{\normalfont\codeface}
75 \def\lit@i#1#2#3{\ifmmode\leavevmode\hbox\fi{#1{#3\/}#2}}
77 %% Conditionally enter maths mode. Can't use \ensuremath here because we
78 %% aren't necessarily sure where the maths will actually end.
79 \let\m@maybe@end\relax
80 \def\m@maybe{\ifmmode\else$\let\m@maybe@end$\fi}
82 %% Standard syntax shortcuts.
83 \atdef <#1>{\synt{#1}\@scripts}
84 \atdef "#1"{\lit*{#1}\@scripts}
85 \atdef `#1'{\lit{#1}\@scripts}
86 \atdef |#1|{\lit*{#1}\@scripts}
88 %% A handy abbreviation; `\\' itself is too good to steal.
89 \atdef \\{\textbackslash}
91 %% Intercept grammar typesetting and replace the vertical bar with the
92 %% maths-font version.
93 \let\@@grammar\grammar
94 \def\grammar{\def\textbar{\hbox{$|$}}\@@grammar}
96 %% Collect super- and subscripts. (Note that underscores are active for the
97 %% most part.) When we're done, end maths mode if we entered it
99 \def\@scripts{\futurelet\@ch\@scripts@i}
100 \begingroup\lccode`\~=`\_\lowercase{\endgroup
101 \def\@scripts@i{\if1\ifx\@ch~1\else\ifx\@ch^1\else0\fi\fi%
102 \expandafter\@scripts@ii\else\expandafter\m@maybe@end\fi}}
103 \def\@scripts@ii#1#2{\m@maybe#1{#2}\@scripts}
105 %% Doubling characters, maybe. Either way, chain onto \@scripts.
106 \def\dbl@maybe#1{\let\@tempa#1\futurelet\@ch\dbl@maybe@i}
107 \def\dbl@maybe@i{\m@maybe\ifx\@ch\@tempa\@tempa\!\@tempa%
108 \expandafter\@firstoftwo\expandafter\@scripts%
109 \else\@tempa\expandafter\@scripts\fi}
111 %% Extra syntax for Lisp templates. These produce the maths-font versions of
112 %% characters, which should contrast well against the sans face used for
114 \atdef [{\dbl@maybe[}
115 \atdef ]{\dbl@maybe]}
116 \atdef {{\m@maybe\{\@scripts}
117 \atdef }{\m@maybe\}\@scripts}
118 \atdef ({\m@maybe(\@scripts}
119 \atdef ){\m@maybe)\@scripts}
120 \atdef !{\m@maybe|\@scripts}
121 \def\returns{\m@maybe\longrightarrow\m@maybe@end\hspace{0.5em}\ignorespaces}
122 \atdef >{\leavevmode\unskip\hspace{0.5em}\returns}
123 \atdef -#1{\if>#1\hbox{--\raisebox{.4pt}{>}}\penalty200\relax\fi}
126 \def\comment#1{\mbox{\normalfont\itshape\/#1\/}}
127 \atdef /*#1*/{/*\comment{#1}*/}
128 \def\@semis{\@ifnextchar;{;\@semis}\@semicomment}
129 \def\@semicomment#1\\{\comment{#1}\\}
130 \atdef ;#1\\{;\@semis}
132 %% Environment for setting programs. Newlines are explicit, because
133 %% otherwise I need comments in weird places to make the vertical spacing
134 %% come out properly. You can write `\obeylines' if you really want to.
135 \def\@prog{\let\prog@@cr\@tabcr\let\@tabcr\@progcr\codeface\tabbing}
136 \def\prog{\quote\@prog}
137 \def\endprog{\endtabbing\endquote}
139 \let\endnprog\endtabbing
140 \def\ind{\quad\=\+\kill}
141 \def\@progcr{\futurelet\@tempa\@progcr@i}
142 {\def\:{\gdef\@progcr@sp}\: {\@progcr}}
143 \atdef~{\textasciitilde}
145 \ifx\@tempa\@sptoken\let\next@\@progcr@sp\else
146 \if1\ifx\@tempa[1\else
149 \let\next@\prog@@cr\else
150 \if1\ifx\@tempa+1\else
153 \let\next@\@progcr@ii\else
154 \let\next@\@progcr@a\fi\fi\fi
156 \def\@progcr@a{\prog@@cr*{}\ignorespaces}
157 \def\@progcr@ii#1{\csname @progcr@#1\endcsname\ignorespaces}
158 \@namedef{@progcr@+}{\prog@@cr[\medskipamount]}
159 \@namedef{@progcr@-}{\prog@@cr*[\jot]}
160 \def\macsl{\`\textbackslash\hskip\leftmargin}
162 %% Put a chunk of text in a box.
163 \newenvironment{boxy}[1][\q@]{%
165 \dimen@\linewidth\advance\dimen@-1.2pt\advance\dimen@-2ex%
167 \vbox\bgroup\hrule\hbox\bgroup\vrule%
168 \vbox\bgroup\vskip1ex\hbox\bgroup\hskip1ex\minipage\dimen@%
169 \def\@temp{#1}\ifx\@temp\q@\else\leavevmode{\headfam\bfseries#1\quad}\fi%
171 \endminipage\hskip1ex\egroup\vskip1ex\egroup%
172 \vrule\egroup\hrule\egroup%
177 %% Lisp documentation machinery.
178 \def\definedescribecategory#1#2{\@namedef{cat!#1}{#2}}
179 \def\describecategoryname#1{%
180 \expandafter\let\expandafter\@tempa\csname cat!#1\endcsname%
181 \ifx\@tempa\relax#1\else\@tempa\fi}
182 \definedescribecategory{sym}{symbol}
183 \definedescribecategory{fun}{function}
184 \definedescribecategory{gf}{generic function}
185 \definedescribecategory{msg}{message}
186 \definedescribecategory{var}{variable}
187 \definedescribecategory{modvar}{module variable}
188 \definedescribecategory{const}{constant}
189 \definedescribecategory{meth}{primary method}
190 \definedescribecategory{ar-meth}{around method}
191 \definedescribecategory{be-meth}{before method}
192 \definedescribecategory{af-meth}{after method}
193 \definedescribecategory{cls}{class}
194 \definedescribecategory{rst}{restart}
195 \definedescribecategory{ty}{type}
196 \definedescribecategory{type}{type}
197 \definedescribecategory{mac}{macro}
198 \definedescribecategory{lmac}{local macro}
199 \definedescribecategory{parse}{parser spec}
200 \definedescribecategory{parseform}{parser form}
201 \definedescribecategory{opt}{option handler}
202 \definedescribecategory{optmac}{option macro}
203 \definedescribecategory{plug}{pluggable parser}
204 \def\nlret{\\\hspace{4em}\returns}
207 \def\parse@dhd#1{\@ifnextchar[{\parse@dhd@a{#1}}{\parse@dhd@c{#1}}}
208 \def\parse@dhd@a#1[#2]{#1{#2}}
209 \def\parse@dhd@c#1#2#3{\parse@dhd@cc{#1}{#2}{#3}#3 \q@}
210 \def\parse@dhd@cc#1#2#3#4 #5\q@{#1{#4}{#2}{#3}}
213 \def\dhead{\parse@dhd\dhead@}
215 \if@dheadfirst\global\@dheadfirstfalse\else\relax\\[\smallskipamount]\fi%
216 {\let\protect\@empty\def\@uscore{_\@gobble}\message{#2:#1}%
217 \def\@uscore{-\@gobble}\edef\@tempa{\noexpand\label{#2:#1}}\@tempa}%
218 {\begingroup\lccode`\~=`\_\lowercase{\endgroup\def~{_}}%
219 \protected@edef\@tempa##1{%
221 #1@{\noexpand\code{#1}}!%
222 \csname cat!#2\endcsname%
227 \toks@\expandafter{\after@desc}%
228 \toks\tw@\expandafter{\@tempa{|)}}%
229 \xdef\after@desc{\the\toks@\the\toks\tw@}}%
230 \rlap{\hb@xt@\linewidth{\hfil\normalfont\bfseries
231 [\describecategoryname{#2}]}}%
236 \let\saved@after@desc\after@desc%
239 \if@nobreak\else\par\goodbreak\fi%
240 \global\@dheadfirsttrue%
242 \let\@endparenv\relax%
243 \clubpenalty\@M \widowpenalty\@M \interlinepenalty50%
246 \penalty\@M\@afterheading%
247 \list{}{\rightmargin\z@\topsep\z@}\item%
249 \def\desc@end{\endlist\after@desc\global\let\after@desc\saved@after@desc}
251 \@namedef{describe*}#1{\desc@begin{#1}}
252 \expandafter\let\csname enddescribe*\endcsname\desc@end
253 \def\describe{\parse@dhd\desc@}
254 \def\desc@#1#2#3{\desc@begin{\dhead@{#1}{#2}{#3}}}
255 \let\enddescribe\desc@end
257 \def\descref#1{\@ifnextchar[{\descref@i{#1}}{\descref@ii{#1}{}}}
258 \def\descref@i#1[#2]{\descref@ii{#1}{ #2}}
259 \def\descref@ii#1#2#3{%
261 {\let\protect\@empty%
262 \def\@uscore{-\@gobble}\edef\@tempa{\noexpand\pageref{#3:#1}}\@tempa}%
266 %%%----- That's all, folks --------------------------------------------------