% 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}


% \catcode`\@=11
%
% % Columns (basically, this is from eplain.tex)
%
% % Double column output.
% %
% % \doublecolumns begins double column output.  It can be called
% % in the midst of a page.  \singlecolumn restores single column
% % output.  (It would be wrong to require \enddoublecolumns, because
% % often one wants double column mode to continue to the end of
% % the document.)
% %
% % The basic approach is that of Appendix E of the TeXbook, p.417.
% %
% % The glue here (the default is intended to be one linespace) is inserted
% % before double columns start, and after they end.
% %
% \newskip\abovedoublecolumnskip \abovedoublecolumnskip = \bigskipamount
% \newskip\belowdoublecolumnskip \belowdoublecolumnskip = \bigskipamount
% %
% %
% % The gutter is the space between the columns. It can be changed
% % as desired.
% %
% \newdimen\gutter \gutter = 2pc
% \newdimen\doublecolumnhsize
% \newif\ifInDoubleColumns
% %
% %
% % These registers are needed for dealing with switching back and forth.
% %
% \newbox\@partialpage \newdimen\singlecolumnhsize \newdimen\singlecolumnvsize
% \newtoks\previousoutput
% %
% %
% \def\doublecolumns{%
%  \ifInDoubleColumns \else \InDoubleColumnstrue
%    \doublecolumnhsize = \hsize   % If \hsize changed, get the new value.
%    \par   % Shouldn't start in horizontal mode.
%    \previousoutput = \expandafter{\the\output}%
%    %
%    % Figure out how wide the columns should be.
%    %
%    \advance\doublecolumnhsize by -\gutter
%    \divide\doublecolumnhsize by 2
%    %
%    % Begin by setting up to grab the page so far and save it in \@partialpage.
%    %
%    \output = {%
%       \global\setbox\@partialpage =
%          \vbox{\unvbox255\vskip\abovedoublecolumnskip}%
%    }%
%    % \pagegoal is the size that TeX will make \box255.  We want a box
%    % exactly the size of the current height of the page, i.e., \pagetotal.
%    %
%    \pagegoal = \pagetotal
%    \break % Now expand the \output just above.
%    %
%    % Now reset \output to prepare for the first real page break.
%    %
%    \output = {\doublecolumnoutput}%
%    \singlecolumnhsize = \hsize
%    \singlecolumnvsize = \vsize
%    \hsize = \doublecolumnhsize
%    \vsize = 2\vsize
%  \fi % \ifInDoubleColumns
% }%
% %
% %
% % When this starts, \box255 is the double-column material.
% % \@partialpage is the single-column material preceding it.
% %
% \def\@doublecolumnsplit{%
%    \splittopskip = \topskip
%    \splitmaxdepth = \maxdepth
%    %
%    % \dimen0 will be the height that the double-column material on this
%    % page should have, i.e., the height of the page (\singlecolumvsize)
%    % minus single-column material, which includes insertions.  (If you
%    % want your insertions to respect the columns, you will have to
%    % change the output routine.)  If you add more insertions, they
%    % should be taken into account both here and in \singlecolumn.
%    %
%    % Unfortunately, we lose on flexible glue because we must
%    % \vsplit to a <dimen>.
%    %
%    \dimen0 = \singlecolumnvsize
%       \advance\dimen0 by -\ht\@partialpage
%       \advance\dimen0 by -\ht\footins
%       \ifvoid\footins\else \advance\dimen0 by -\skip\footins \fi
%       \advance\dimen0 by -\ht\topins
%       \ifvoid\topins\else \advance\dimen0 by -\skip\topins \fi
%    %
%    \begingroup
%       % We do not want to see underfull \vbox messages unless the final
%       % page is underfull.
%       \vbadness = 10000
%       %
%       % \box1 will be the left column.
%       \global\setbox1 = \vsplit255 to \dimen0
%       \wd1 = \hsize
%       %
%       % \box3 will be the right column.
%       \global\setbox3 = \vsplit255 to \dimen0
%       \wd3 = \hsize
%    \endgroup
%    %
%    % \box4 will be what is left over.
%    \global\setbox4 = \vbox{\unvbox255 \penalty\outputpenalty}%
%    %
%    % Set up \box255 with the real output page, as the previous output
%    % routine expects.
%    \global\setbox255
%      = \vbox{%
%          \unvbox\@partialpage
%          \hbox to \singlecolumnhsize{\box1\hfil\box3}%
%        }%
% }%
% %
% \def\doublecolumnoutput{%
%    \@doublecolumnsplit
%    %
%    \hsize = \singlecolumnhsize % Local to the \output group.
%    \vsize = \singlecolumnvsize
%    \the\previousoutput
%    %
%    % Put the remainder back on the page.
%    \unvbox4
% }%
% %
% %
% % Go back to single-column typesetting.  I assume \doublecolumns has
% % been called.
% %
% \def\singlecolumn{%
%  \ifInDoubleColumns \InDoubleColumnsfalse
%    \par % Shouldn't start in horizontal mode.
%    %
%    \output = {\global\setbox1 = \box255}%
%    \pagegoal = \pagetotal
%    \break             % Exercise the page builder, i.e., \output.
%    \setbox255 = \box1 % Retrieve what the fake \output set.
%    %
%    % \box255 now has the double-column material.  On the page where we
%    % switch back to one column, the double-column material might not
%    % fill up the page.  We want to split whatever is there.
%    \begingroup
%       \singlecolumnvsize = \ht\@partialpage
%       \advance\singlecolumnvsize by \ht\footins
%       \ifvoid\footins\else \advance\singlecolumnvsize by \skip\footins\fi
%       \advance\singlecolumnvsize by \ht\topins
%       \ifvoid\topins\else \advance\singlecolumnvsize by \skip\topins\fi
%       \dimen0 = \ht255 \divide\dimen0 by 2
%       \advance\singlecolumnvsize by \dimen0
%       %
%       % This compensates (I hope) for the vagaries of \vsplit.  Without
%       % this, the last line can sometimes get chopped off.
%       \advance\singlecolumnvsize by .5\baselineskip
%       %
%       % We should never have anything left over from this splitting, since
%       % we computed \singlecolumnvsize to be large enough.
%       \@doublecolumnsplit
%    \endgroup
%    %
%    \hsize = \singlecolumnhsize
%    \vsize = \singlecolumnvsize
%    \output = \expandafter{\the\previousoutput}%
%    \unvbox255
%    \vskip\belowdoublecolumnskip
%    \nointerlineskip
%  \fi % \ifInDoubleColumns
% }%
%
% \catcode`\@=12
%
