% guidemacs.tex - 14:31 GMT +10:00 Sun 23 May 1993 - modifier Geoffrey Tobin.
% I don't have the original Andrew Trevorrow guidemacs.
% This will have to do. -- Ian Dall

\def \dvgt {{dvgt 3.5}}
\font\bigbf=cmbx12
\font\Bigbf=cmbx12 scaled \magstep1
\font\title=cmbx10 scaled \magstep5
\font\smallrm=cmr8
\def \subhead #1{\bigskip\leftline{\Bigbf #1}\medskip}
\let \;=\unskip
\def \finishline{}
\parskip=10pt


% Macros for verbatim TeX (from MANMAC.TEX):
% After \inputing this file you can use the following macros:
%
% 1. |<verbatim horizontal mode text in \tt>|
%
% 2. \begintt <optional stuff here>
%    <boxed lines of verbatim text in \tt; | is temporary escape character>
%    \endtt
%
% 3. \begindisplay
%    <off-centred display of aligned columns; typical row follows:>
%    |text in \tt|& |text in \tt|& text in current font\cr
%    \enddisplay
%
% 4. \listing{foo}
%    foo.tex will be \input and set verbatim in \tt; \parskip must be non-zero
%    if you want to see any empty lines

\catcode`@=11   % borrow some PLAIN macros which use @ as a letter

\newskip\ttglue
\ttglue=0.5em plus.25em minus.15em

\chardef\other=12
\def\ttverbatim{\begingroup
  \catcode`\\=\other
  \catcode`\{=\other
  \catcode`\}=\other
  \catcode`\$=\other
  \catcode`\&=\other
  \catcode`\#=\other
  \catcode`\%=\other
  \catcode`\~=\other
  \catcode`\_=\other
  \catcode`\^=\other
  \obeyspaces \obeylines \tt}
{\obeyspaces\gdef {\ }}           % active space = \ , not \space

\outer\def\begintt{$$\let\par=\endgraf \ttverbatim \parskip=\z@
  \catcode`\|=\other
  \rightskip-5pc \ttfinish}
{\catcode`\|=0 |catcode`|\=\other % | is temporary escape character
  |obeylines % end of line is active
  |gdef|ttfinish#1^^M#2\endtt{#1|dimen0=|hsize|advance|dimen0 by -|hangindent%
                              |hsize=|dimen0|vbox{#2}|endgroup$$}}
% \begintt ... \endtt will now work in a paragraph with \hangindent, such
% as an \item

\catcode`\|=\active
{\obeylines \gdef|{\ttverbatim \spaceskip\ttglue \let^^M=\ \let|=\endgroup}}

\catcode`@=12    % return @ its normal category of "other"

% Macros for non-centered displays:
% Note that we turn \ttglue off so |stuff| spaces will all be equal.
\outer\def\begindisplay{\obeylines\startdisplay}
{\obeylines\gdef\startdisplay#1
  {\catcode`\^^M=5$$\ttglue=0em#1\halign to\hsize%
\bgroup\indent##\hfil\tabskip 0pt plus 1000pt&&\qquad##\hfil\cr}}
\outer\def\enddisplay{\crcr\egroup$$}

% MACROS FOR VERBATIM LISTINGS (ADAPTED FROM TEXBOOK APPENDIX D, P380)

\def\uncatcodespecials{\def\do##1{\catcode`##1=12 }\dospecials}


\def\setupverbatim{\tt % \lineno=0
  \def\par{\leavevmode\egroup\box0\endgraf}
  \obeylines \uncatcodespecials \obeyspaces
  \catcode`\`=\active \catcode`\^^I=\active
  \everypar{ % \advance  \lineno by1 \llap{\sevenrm\the\lineno\ \ }
  \startbox}}
\newdimen\w \setbox0=\hbox{\tt\space} \w=8\wd0 % tab amount
% \newcount\lineno
\def\startbox{\setbox0=\hbox\bgroup}
{\catcode`\^^I=\active
  \gdef^^I{\leavevmode\egroup
    \dimen0=\wd0 % the width so far, or since the previous tab
    \divide\dimen0 by\w
    \multiply\dimen0 by\w % compute previous multiple of \w
    \advance\dimen0 by\w  % advance to next multiple of \w
    \wd0=\dimen0 \box0 \startbox}}

\def\listing#1{\par\begingroup\parindent0pt \parskip0pt
               \vskip\baselineskip
               \setupverbatim
               \catcode`\|=\other  % allow | in listing file
               \input#1
               \vskip\baselineskip\endgroup}

