%% 
%% This is file `menus.sty', generated 
%% on <1994/11/10> with the docstrip utility (2.2h).
%% 
%% The original source files were:
%% 
%% menus.dtx  (with options: `2e')
%%% ====================================================================
%%%  @LaTeX-style-file{
%%%     filename        = "menus.sty",
%%%     version         = "0.9x",
%%%     date            = "1994/11/08",
%%%     time            = "13:32:59 EST",
%%%     checksum        = "38585 989 4295 33156",
%%%     keywords        = "TeX, menus",
%%%     author          = "Michael Downes",
%%%     email           = "mjd@math.ams.org (Internet)",
%%%     supported       = "yes",
%%%     abstract        = "This file provides functions for writing
%%%       messages and menus on screen, and reading user responses. It
%%%       can be used with LaTeX as a documentstyle option, or in
%%%       other forms of TeX by a standard \input statement.",
%%%     docstring       = "The checksum field above contains a CRC-16
%%%       checksum as the first value, followed by the equivalent of
%%%       the standard UNIX wc (word count) utility output of lines,
%%%       words, and characters.  This is produced by Robert Solovay's
%%%       checksum utility.",
%%%  }
%%% ====================================================================
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{menus}[1994/11/08 v0.9x]
\RequirePackage{dialog}
\localcatcodes{\@{11}%
  \~{13}\"{12}\#{6}\^{7}\`{12}\${3}\:{12}}
\storexmesj\menuprefix{
======================================================================
}
\let\menusuffix=\menuprefix
\storemesj\inmenuA{
}
\storemesj\inmenuB{
}
\storemesj\menuline{  }
\def\menutopline{}
\def\menubotline{}
\storemesj\endmenuline{
}%
\def\menunumber#1{[#1] }
\def\menuprompt{\promptmesj{Your choice? }}
\newtoks\menufirstpart
\newtoks\menuchoices
\newtoks\menulastpart
\def\fmenu#1#2#{\mesjsetup
  \catcode`\#=6 % for parameters
  \toks@{\fxmenub{\gdef}{\begingroup}{}#1{#2}}%
  \def\@tempa##1##{%
    \def\@tempa####1####{%
      \def\@tempa{\the\toks@}%
      \afterassignment\@tempa \menulastpart}%
    \afterassignment\@tempa \menuchoices}%
  \afterassignment\@tempa \menufirstpart
}
\begingroup % localize \lccode change
\lccode`\~=`\^^M
\lowercase{%
\long\gdef\stripM#1$~#2#3\stripM#4{%
  \ifx$#2%
    \stripMa#1\stripMa#4%
  \else
    \stripMb#2#3\stripMb#4%
  \fi
}
}% end lowercase
\lowercase{%
\long\gdef\stripMa $#1\stripMa#2{%
  \stripMb#1$~$$\stripMb#2}
}% end lowercase
\lowercase{%
\long\gdef\stripMb#1~$#2#3\stripMb#4{%
  \ifx$#2%
    \stripMc#1\stripMc#4%
  \else
    \stripMd#1\stripMd#4%
  \fi
}
}% end lowercase
\long\gdef\stripMc#1$#2\stripMc#3{%
  \stripMd#1\stripMd#3}
\long\gdef\stripMd#1\stripMd#2{#2{#1}}
\endgroup
\begingroup \lccode`\~=`\^^M
\lowercase{%
\gdef\stripcontrolMs#1{\xp@\stripM
  \xp@$\the#1$~$$\stripM#1}
}% end lowercase
\lowercase{%
\gdef\addmenulines#1#2#3{%
  \def ~##1~##2{%
    #1\xp@{\the#1#2##1#3}%
    \ifx\end##2\xp@\@gobbletwo\fi~##2}%
  \edef\@tempa{\nx@~\the#1\nx@~}#1{}%
  \@tempa\end}
}% end lowercase
\endgroup % restore lccode of ~
\def\fxmenub#1#2#3#4#5{%
  \stripcontrolMs\menufirstpart
  \stripcontrolMs\menulastpart
  \stripcontrolMs\menuchoices
  \addmenulines\menuchoices\menuline\endmenuline
  \actively\let\^^M\relax % needed for \xdef
  \toks@{\long#1#4#5}% e.g. \xdef\foo##1##2
  \edef\@tempa{\the\menufirstpart}%
  \ifx\@tempa\@empty
    \let\nxa@\@gobble
  \else
    \addmenulines\menufirstpart
      \menutopline\endmenuline
    \let\nxa@\nx@
  \fi
 \edef\@tempa{\the\menulastpart}%
  \ifx\@tempa\@empty
    \let\nxb@\@gobble
  \else
    \addmenulines\menulastpart
      \menubotline\endmenuline
    \let\nxb@\nx@
  \fi
\edef\@tempa{{#3\nx@#3#2%
    \def#3\nx@#3\mesjtext{%
      #3\nx@#3\menuprefix
      \the\menufirstpart #3\nxa@#3\inmenuA
      \the\menuchoices #3\nxb@#3\inmenuB
      \the\menulastpart #3\nx@#3\menusuffix}%
    #3\nx@#3\sendmesj
    #3\nx@#3\menuprompt}}%
  \toks2 \xp@{\@tempa}%
  \edef\@tempa{\the\toks@\the\toks2 }%
  \let\menutopline\relax \let\menuline\relax
  \let\menubotline\relax \let\endmenuline\relax
  \let\menunumber\relax
  \@tempa % finally, execute the \gdef or \xdef
  \endgroup % matches \mesjsetup done by \fxmenu
}% end \fxmenub
\def\fxmenu#1#2#{\xmesjsetup
  \toks@{\fxmenub{\xdef}{\xmesjsetup}\nx@#1{#2}}%
  \def\@tempa##1##{%
    \def\@tempa####1####{%
      \def\@tempa{\the\toks@}%
      \afterassignment\@tempa \menulastpart}%
    \afterassignment\@tempa \menuchoices}%
  \afterassignment\@tempa \menufirstpart
}
\def\notyet#1{%
  \errmessage{Not yet implemented:  \string#1}}
\long\def\nmenu#1#2#3#4#5{\notyet\nmenu}
\long\def\nxmenu#1#2#3#4#5{\notyet\nxmenu}
\newtoks\optionstack
\let\curmenu\@empty
\let\estart\relax
\let\eend\relax
\def\pushoptions#1{%
  \edef\pushtemp{\estart
    \def\nx@\curmenu{\curmenu}%
    \eend
    \the\optionstack}%
  \global\optionstack\xp@{\pushtemp}%
  \edef\curmenu{\curmenu#1}%
}
\def\popoptions{%
  \edef\@tempa{\the\optionstack}%
  \ifx\@empty\@tempa
    \errmessage{Can't pop empty stack
      (\string\optionstack)}%
  \else
    \def\estart##1\eend##2\@nil{%
      \global\optionstack{##2}%
      \let\estart\relax##1}%
    \the\optionstack\@nil
  \fi
}
\fmesj\moptionX{Exiting . . .}
\def\repeatoption{%
  \csname moption\curmenu\endcsname}
\def\moptionQ{\popoptions \repeatoption}
\fxmesj\badoptionmesj#1{%
?---I don't understand "#1".}
\def\optionexec#1{%
  \if ?#1\relax \let\@tempa\moptionhelp
  \else \if Q#1\relax
    \ifx\curmenu\@empty \let\@tempa\moptionX
    \else \let\@tempa\moptionQ \fi
  \else \if X#1\relax \let\@tempa\moptionX
  \else
    \xp@\let\xp@\@tempa
      \csname moption\curmenu#1\endcsname
    \ifx\@tempa\relax
      \badoptionmesj{#1}\let\@tempa\repeatoption
    \else
      \pushoptions{#1}%
    \fi
  \fi\fi\fi
  \@tempa
}
\def\optionfileexec#1{\notyet\optionfileexec}
\def\xoptiontest#1{TT\fi
  \begingroup \def\0{?}\def\1{Q}%
  \def\2{q}\def\3{x}\def\4{X}%
    \aftergroup\if\aftergroup T%
    \ifx\0#1\aftergroup T%
    \else\ifx\1#1\aftergroup T%
    \else\ifx\2#1\aftergroup T%
    \else\ifx\3#1\aftergroup T%
    \else\ifx\4#1\aftergroup T%
    \else \aftergroup F%
    \fi\fi\fi\fi\fi
  \endgroup
}
\fxmesj\menuhelpmesj{&\menuprefix%
A response of Q will usually send you back to %
the previous menu.
A response of X will get you entirely out of %
the menu system.
&\menusuffix%
Press the <Return> key ( Enter ) to continue:
}
\def\moptionhelp{%
  \menuhelpmesj \readline{}\reply \repeatoption}
\def\moptionhelp{%
  \menuhelpmesj \readline{}\reply \repeatoption}
\xp@\def\csname moption?\endcsname{%
  \moptionhelp}
\def\specialhelp#1#2{%
  \let\specialhelpreply=#1\def#1{?}\begingroup
  \def\menuhelpmesj{\let#1\specialhelpreply
    \promptxmesj{#2\
Press <return> to continue:}\endgroup}%
}
\def\specialhelpreply{}
\def\lettermenu#1{%
  \csname menu#1\endcsname
  \readChar{Q}\reply \optionexec\reply
}
\restorecatcodes
\endinput
%% 
%% End of file `menus.sty'.
