% wbuildmac.tex -- macros for TeX documents generated by wbuild
% Bert Bos <bert@let.rug.nl>
% Alfa-informatica, Rijksuniversiteit Groningen, Netherlands
% 3 June 1992

\ifx\wbuildloaded\relax \endinput \else \let\wbuildloaded=\relax \fi

% Set the next macro to \internalfalse when generating user docs

\newif\ifinternal \internaltrue

% The following macros are put into the TeX file by wbuild

\def\Class#1{\chapter{#1}}
\def\Super#1{\bigskip \leftline{\bf Superclass: #1}}
\def\Publicvars{\section{Public variables}}
\def\Privatevars{\section{Private variables}}
\def\Actions{\section{Action functions}}
\def\Translations{\section{Default translations}}
\def\Exports{\section{Exports}}
\def\Methods{\section{Methods}}
\def\Imports{\section{Imports}}
\def\Utilities{\section{Local functions and variables}}
\def\Classvars{\section{Class variables}}
\def\Section{\bigbreak \needindentfalse}
\def\Code{\setupcode \beginCode}
\def\Macro{\setupcode {\bf def }\beginMacro}
\def\Publicvar#1{%\noindent {\it #1}\enspace
  \ignorespaces}
\def\Action#1{\subsection{#1}}
\def\HCode{\ifinternal \let\next=\relax \else \let\next=\skipHCode \fi \next}
\def\Table#1{\restable{#1}}
\def\endTable{\endrestable}
\def\underline{{\tt\char"5F}}
\def\backslash{{\tt\char"5C}}
\def\tilde{{\tt\char"7E}}
\def\hashmark{\#}
\def\dollar{\char`\$}
\def\percent{\%}
\def\caret{{\tt\char"5E}}
\def\ampersand{\&}
\def\lbrace{{\tt\char`\{}}
\def\rbrace{{\tt\char`\}}}
\def\bar{{\tt\char"7C}}
\def\langle{$\<$}
\def\rangle{$\>$}
\def\type{{\bf type}}
\def\incl{{\bf include}}

% End of macros generated by wbuild

\font\chapterfont=cmssq8 scaled\magstep5
\font\sectionfont=cmbx12
\font\subsectionfont=cmti10
\font\tablefont=cmtt8
\font\codefont=cmtt9

\hsize=13.5cm
\vsize=24cm

\tolerance=2000

\newif\ifNeedIndent % as a rule
\newif\ifneedindent % special cases

\everypar{\ControlledIndentation}

\def\RemoveIndentation{{\setbox0=\lastbox}}
\def\ControlledIndentation
  {\ifNeedIndent
    \ifneedindent \else \RemoveIndentation \needindenttrue \fi
  \else
    \ifneedindent \needindentfalse \else \RemoveIndentation \fi
  \fi}

\NeedIndenttrue % default is with indentation

% \em is used instead of \it. It adds the italic correction
% automatically

\def\em{\it \aftergroup\/}

\def\chapter#1%
  {\vfil\eject
  \leftline{\chapterfont#1}\bigskip \needindentfalse}
\def\section#1%
  {\vskip 0pt plus.2\vsize \penalty-250 \vskip 0pt plus-.2\vsize
  \bigskip \bigskip \vskip\parskip
  \leftline{\sectionfont#1}\needindentfalse \nobreak}
\def\subsection#1%
  {\bigbreak
  \leftline{\subsectionfont $\bullet$ #1}\nobreak\smallskip \needindentfalse}
\def\item#1%
  {\medskip
  \hang \noindent #1\unskip\ \ignorespaces}

{\catcode`\^^M=13 %
  \gdef\strongobeylines{\catcode`\^^M=13 \def\^^M{\par\leavevmode}}%
}
%\def\obeyspaces{\catcode`\ =\active}
{\obeyspaces\global\let =\ }
%\def\space{\leavevmode{}\ }
\def\makeother#1{\catcode`#1=12 }
\def\uncatcodespecials{\let\do=\makeother \dospecials}
\def\setupcode
  {\medbreak
  \begingroup \leftskip=\parindent \strongobeylines \obeyspaces
  \codefont \parindent=0pt \parskip=0pt \rightskip=0pt plus 4em
  \let\langle=< \let\rangle=> \hyphenchar\font=-1
  \everypar{\vadjust{\hbox{%\kern-\leftskip
        \special{ps:gsave 0.8 setgray}%
        \vbox to 0pt{\vss
          \hrule width5pt height1.1\baselineskip depth.1\baselineskip}%
        \special{ps:grestore}}}}
  \multiply\tolerance by 4}

{\strongobeylines%
  \gdef\beginCode^^M#1\endCode{#1\endgraf\endgroup\medskip}%
  \gdef\beginMacro^^M#1\endMacro{#1\endgraf\endgroup\medskip}%
  \gdef\skipHCode^^M#1\endHCode{}%
}
\let\endHCode=\relax

% Tabulating of resources:

\def\highstrut{\raise2pt\copy\strutbox}
\def\deepstrut{\lower2pt\copy\strutbox}
\def\restable#1%
  {\bigbreak
  \vbox\bgroup \tablefont \halign\bgroup
        \strut\enspace##\enspace\hfil\vrule&
	  \enspace##\enspace\hfil\vrule&
	  \enspace##\enspace\hfil\vrule&
	  \enspace##\enspace\hfil\cr
        %\noalign{\hrule}
        \multispan4{\highstrut\deepstrut\it #1\hfil}\cr
        \noalign{\hrule}
        \highstrut\deepstrut \bf Name& \bf Class& \bf Type& \bf Default\cr
        \noalign{\hrule}
        \highstrut \ignorespaces}
\def\endrestable{\egroup\egroup\bigskip}

