
\lingmkletter @
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% various strategies for typesetting \tt material

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

\catcode`\|=\active
\catcode`\�=\active   % for | in \tt territory
\catcode`\�=\active   % escape inside | ... |
\catcode`\�=\active   % resume
{\obeylines %
\gdef\begintt{\ttverbatim %
   \let^^M=\ \let|=\endgroup}%
}
\let|\begintt
\def�{\char"7C\relax}
\def�{\endgroup \kern1.2pt\bgroup\sl}
\def�{\egroup\kern.4pt\begintt}

{\catcode`\^^M=\active
\gdef\CL{%  (codelines)
   \par \begingroup \allnormal \tt %
   \catcode`^^M=\active \let^^M=\par %
   \catcode`\|=0 \obeyspaces \@gobble}%
\gdef\CLboxed{%
   \leavevmode\vtop \bgroup \begingroup \allnormal \tt
   \catcode`^^M=\active \let^^M=\cr %
   \catcode`\|=0 %
   \obeyspaces\halign\bgroup ##}%
\gdef\@CLnumbered{%
   \catcode`\^^M=\active \let^^M=\specialpar %
   \catcode`\|=0 }%
}
\def\endCL{\endgroup}%
\def\endCLboxed{\egroup \endgroup\egroup}%
\newcount\linecount
\def\specialpar{%
   \par\leavevmode
   \llap{\hbox{\tenrm \hfil\the\linecount
      \hskip2ex
      \global\advance\linecount by 1}}%
}
\def\CLnumbered{\linecount=1 \morecode}
\def\morecode{%
   \smallskip \begingroup
   \allnormal\obeyspaces\@CLnumbered\tt
}
\def\endCLnumbered{\endgroup\smallskip}
%
\def\@#1{$^{\>#1}$} % |@ for footnotes inside \CL
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\CLframed{%
   \medskip
   \line\bgroup
      \vrule\hss
         \vbox\bgroup\leftskip=1em
            \hrule
            \medskip
            \CL\relax}
\def\endCLframed{%
            \endCL
            \medskip
            \hrule
         \egroup
      \hss\vrule
   \egroup
   \medskip
}
\lingrestore @

