%%% ====================================================================
%%%  @LaTeX-style-file{
%%%     author          = "Mario Wolczko",
%%%     version         = "3",
%%%     date            = "21 May 1992",
%%%     time            = "21:02:11 BST",
%%%     filename        = "smalltalk.sty",
%%%     address         = "Dept of Computer Science
%%%                        The University of Manchester
%%%                        Oxford Road
%%%                        Manchester M13 9PL
%%%                        UK",
%%%     telephone       = "+44-61-275-6146",
%%%     FAX             = "+44-61-275-6236",
%%%     checksum        = "56043 161 377 5156",
%%%     email           = "mario@cs.man.ac.uk (Internet)",
%%%     codetable       = "ISO/ASCII",
%%%     keywords        = "LaTeX, Smalltalk programming language",
%%%     supported       = "yes",
%%%     docstring       = "Useful for typesetting small fragments of
%%%     the Smalltalk programming language",
%%%  }
%%% ====================================================================
%
% example:
%
% \begin{smalltalk}
% \category{Magnitudes-Numbers}
% \class{Integer}
% \superclass{Object}
% \instvars{a b c}
% \protocol{arithmetic functions}
% \begin{method}{factorial}
% | f |
% self isZero
%      ifTrue: [n _ 1]
%      ifFalse: [n _ self * (self - 1) factorial].
% ^n
% \end{method}
% \classmeths
% ...
% \end{smalltalk}
%

% warning: if you put a Smalltalk environment inside a list (e.g.,
% itemize, description, etc, then don't have a paragraph skip between
% it and the next item.  Example:
% \begin{itemize}
% \item blah blah
%  \begin{smalltalk}
%   code
%  \end{smalltalk} % don't put a blank line after this
% \item ....
%


\def\@fmtname{lplain}
\def\@psfmtname{pslplain}

\newenvironment{smalltalk}{\@beginst}{\@endst}

\def\st{\protect\@st}
\def\@st{\@setSTcatcodes\smalltalkfont} % for in-line code

\newdimen\stindent \stindent=\parindent

\def\@beginst{\everymath{}\vskip1ex \leftskip=\stindent
  \baselineskip=\stbaselineskip \parskip=0pt
% \parskip=\stbaselineskip
  \@setSTcatcodes\@vobeyspaces\obeylines\noindent\smalltalkfont}

\newdimen\stbaselineskip \stbaselineskip\baselineskip

\def\@endst{\vskip1ex
  \global\everypar={{\setbox0=\lastbox}%
			\global\everypar={}%
			\global\let\par=\@@par}
	\global\let\par=\@undonoindent}
\def\@undonoindent{\global\everypar={}\global\let\par=\@@par\@@par}

\def\class#1{\noindent\hbox to 7em{\rm class\hfil}\smalltalkfont
	 #1\par\vskip 1ex\relax}

\def\category#1{\noindent\hbox to 7em{\rm category\hfil}\smalltalkfont
	 #1\par\vskip 1ex\relax}

\def\protocol#1{\noindent\hbox to 7em{\rm protocol\hfil}\smalltalkfont
	 #1\par\vskip 1ex\relax}

\def\superclass#1{\noindent\hbox to 7em{\rm superclass\hfil}\smalltalkfont
	 #1\par\vskip 1ex\relax}

\def\instvars#1{\noindent\hbox to 9em{\rm instance variables\hfil}\smalltalkfont
	 #1\par\vskip 1ex\relax}

\def\classmeths{\noindent\rm class methods\par\vskip 1ex\relax}

\newenvironment{method}{\@beginmethod}{\@endmethod}

\ifx\fmtname\@fmtname % standard LaTeX is OK
  \ifx\selectfont\@undefined
    \def\smalltalkfont{\sf}
    \ifcase\@ptsize
      \font\smalltalkboldfont=cmssbx10
    \or
      \font\smalltalkboldfont=cmssbx10 scaled\magstep1
    \or
      \font\smalltalkboldfont=cmssbx10 scaled\magstep2
    \fi
  \else
    \def\smalltalkfont{\family{cmss}\series{m}\shape{n}\selectfont}
    \def\smalltalkboldfont{\family{cmss}\series{bx}\shape{n}\selectfont}
   \fi
\else \ifx\fmtname\@psfmtname % so is pslatex
  \ifx\selectfont\@undefined
    \def\smalltalkfont{\sf}
    \ifcase\@ptsize
      \font\smalltalkboldfont=phvb0 at 9pt
    \or
      \font\smalltalkboldfont=phvb0 at 10pt
    \or
      \font\smalltalkboldfont=phvb0 at 11pt
    \fi
  \else
    \def\smalltalkfont{\family\sfdefault\series{m}\shape{n}\selectfont}
    \def\smalltalkboldfont{\family\sfdefault\series{b}\shape{n}\selectfont}
  \fi
\else % SliTeX is different
  \font\smalltalkboldfont=cmssbx10 at 20.74pt
  \def\smalltalkfont{\rm}
\fi\fi

\def\@beginmethod#1{\vbox\bgroup\noindent{\smalltalkboldfont#1}}

\def\@st@under{$\leftarrow$}
\def\@st@uparrow{$\uparrow$}
\def\@st@bar{$\mid$}
\def\@st@lt{$\mathchar"313C$}
\def\@st@gt{$\mathchar"313E$}
%\def\@st@minus{$\mathchar"2200$}

{\catcode`\_=\active \catcode`\^=\active \catcode`\|=\active
 \catcode`\<=\active \catcode`\>=\active%\catcode`\-=\active
 \gdef\@setSTcatcodes{%
   \@makeother\#\@makeother\%\@makeother\~%
   \catcode`\_=\active \catcode`\^=\active \catcode`\|=\active
   \catcode`\<=\active \catcode`\>=\active%\catcode`\-=\active
   \let_\@st@under \let^\@st@uparrow \let|\@st@bar
   \let<\@st@lt \let>\@st@gt}} %\let-\@st@minus}}

%{\catcode`\_=\active \catcode`\^=\active \catcode`\|=\active
% \catcode`\<=\active \catcode`\>=\active%\catcode`\-=\active
% \gdef\@setSTcatcodes{%
%   \@makeother\#\@makeother\%\@makeother\~%
%   \catcode`\_=\active \catcode`\^=\active \catcode`\|=\active
%   \catcode`\<=\active \catcode`\>=\active%\catcode`\-=\active
%   \def_{$\leftarrow$}\def^{$\uparrow$}\def|{$\mid$}%
%   \def<{$\mathchar"313C$}\def>{$\mathchar"313E$}}}
%   \def-{$\mathchar"2200$}}}

\def\@endmethod{\strut\egroup}
