\def\fileversion{v0.98}
\def\filedate{2003/12/20}
% ^^A For index and changes, run:
% ^^A makeindex -s gglo -o Menu.gls Menu.glo
% ^^A makeindex -s gind -o Menu.ind Menu.idx
%
% \CheckSum{95}
%%
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
% \DoNotIndex{\" , \-, \flqq,\frqq, \ ,\def, \begin, \end}
% \DoNotIndex{\csname,\endcsname, \expandafter, \global, \newcommand}
% \DoNotIndex{\advance, \filedate, \fileversion, \MessageBreak}
% \DoNotIndex{\newcount, \newcounter, \newif, \or}
% \DoNotIndex{\if, \else, \fi, \ifcase, \ifdefined, \ifnum, \ifx, \loop, \repeat}
% \DoNotIndex{\heartsuit}
% \DoNotIndex{\NeedsTeXFormat, \providecommand, \ProvidesPackage, \relax, \RequirePackage}
% \DoNotIndex{\par, \chapter, \section, \subsection, \subsubsection, \paragraph, }
% \DoNotIndex{\selectlanguage, \stepcounter, \ss, \space, \setcounter}
% \DoNotIndex{\value, \typeout, \long, \renewcommand}
%
% \iffalse
%<*driver>
\documentclass{ltxdoc}
\usepackage{menu}
\usepackage{makeidx}
%\IfFileExists{hyperref.sty}{\usepackage{hyperref}}{}
\IfFileExists{keystroke.sty}{
    \usepackage{keystroke}
    }{
    \newcommand{\keystroke}[1]{\fbox{##1}}
    }
\CodelineIndex
\makeindex
\OnlyDescription
\begin{document}
 \DocInput{menu.dtx}
\end{document}
%</driver>
%
%<*package>
% \fi
% \title{Menu.sty: Typesetting menus}
% \author{Knut Lickert}
% \maketitle
%
%\begin{abstract}
% Menu.sty define a command |\menu{Programm!!Menu1!Command}| and
% expand it to something like \menu{Programm!!Menu1!Command}. You
% can use it for documentations of programs.
%\end{abstract}
%
% \section{Where to use the style}
% If you write a documentation of a program you have to define
% things like "Push button \keystroke{F1} or go to the Menu to
% \menu{Help!Help} and you get help". This style help you to write
% the menu entry.
%
% \subsection{Other packages}
% I have not found a package to typeset menus (that's why this style
% was written). If you find one, please contact me
% (knut@lickert.net).
%
% \begin{description}
%    \item[keystroke]
%         A \LaTeX\ package which provides macros for the graphical
%         representation of the keys on a computer keyboard.\par
%           Example: \Ctrl, \Shift \AltGr
% \end{description}
%
%
% \section{How to use the style}
% \DescribeMacro{\menu}
% |\menu| has one parameter. The macro is used to typeset a path in a
% menu. Like |\index| different levels are separated with a "!"
% inside the parameter. Instead a "!" you can use two "!!" and so you
% can define bigger steps in the menu. I use programs, where a menu
% is starting another menu (e.g.\ in a popup). So instead of saying
% "Goto \menu{Menu1!Entry1!Menu2} and then from
% \menu{Menu2!Menu3!Entry3}" I write "Goto
% \menu{Menu1!Entry1!Menu2!!Menu3!Entry3}.
% \DescribeMacro{\menutext}
% An step of a menu is written with this macro, default is
% |\texttt|. You can change it with |\renewcommand|, e.g.\
% |\renewcommand{\menutext}[1]{\emph{#1}|
%
% \subsection{Changing the look}
% \DescribeMacro{\menumathsymbols}
% If you want to replace the symbols, you can use |\menusymbols|.
% Parameter one is the flag for "!", Parameter for "!!".
%
% \DescribeMacro{\menusymbols}
% Like |\menumathsymbols| with two differences:
% \begin{itemize}
%   \item There is no math-environment (if you need it, you can
%         guarantee it with |\ensuremath|)
%   \item There are two optional parameters, defining a start and
%         end command of a menu.
% \end{itemize}
% This command gives you a flexible possibility to change the look
% of menus.
%
% \begin{description}
%   \item[$\backslash$menusymbols] Define a style with the parameters:
%   \item[{[Start]}] How should a menu start.\par
%         A |\par| is not allowed, but you can use a |\\|. If a paragraph
%         ends before the |\menu|, you must use |~\\| instead.
%   \item[\{\}] The look/actions for a "!" in a menu.
%   \item[\{\}] The look/actions for a "!!" in a menu.
%   \item[{[End]}] How should a menu end.
% \end{description}
%
%
%
% \section{Examples}
% \newcommand{\example}[1]{\texttt{$\backslash$menu\{#1\}} & \menu{#1}\\}
%
% \subsection{Predefined look}
% \begin{tabular}{ll}
% Coding    & Result\\\hline
% \example{Menu!Menu}
% \example{Menu!!Menu}
% \example{Menu!!Next Menu!Entry}
% \end{tabular}
%
% \subsection{Changed symbols}
% \menumathsymbols{>}{\gg}
% After |\menumathsymbols{>}{\gg}| you get\par
% \begin{tabular}{ll}
% Coding    & Result\\\hline
% \example{Menu!Menu}
% \example{Menu!!Menu}
% \example{Menu!!Next Menu!Entry}
% \end{tabular}
%
% Attention: If you want to change it local, you must define a
% block.
%
% \subsection{Define your own styles}
% You can define your own "styles", |\menu{Menu!!Next Menu!Entry}|
% makes an entry like:
%
% \begin{minipage}[t]{0.5\textwidth}
%\begin{verbatim}
%\newlength{\menusep}
%\menusymbols[
%   \setlength{\menusep}{0em}~\\
% ]{
%   \\
%   \addtolength{\menusep}{1em}
%   \hspace*{\menusep}
% }{
%   $\wr$\\
%   \addtolength{\menusep}{2em}
%   \hspace*{\menusep}
% }[
% \ensuremath{\Leftarrow}
% ]
%\end{verbatim}
% \end{minipage}
% \begin{minipage}[t]{0.4\textwidth}
%% ^^A Example for a new style
%% \newlength{\menusep}
%% \menusymbols[\setlength{\menusep}{0em}~\\]{
%%    \\
%%    \addtolength{\menusep}{1em}
%%    \hspace*{\menusep}
%%  }{
%%    $\wr$\\
%%    \addtolength{\menusep}{2em}
%%    \hspace*{\menusep}
%%  }[
%%  \ensuremath{\Leftarrow}
%%  ]
% \menu{Menu!!Next Menu!Entry}
% \end{minipage}
%
%
% \section{Ideas for the future}
% \begin{itemize}
%   \item Create Index entries for menus (optional)\par
%         If I do it, it would be an additional index (style multind).
%         I think this would be wrong in the normal index.
%   \item An optional parameter: |\menu[Programm]{Menu!...}|\par
%         Does anybody need it? At the moment I think there is no need.
%         When there is the possibility of index entries, then it could be sensefull
%         (Index is sorted by Programm, Menu1, Menu2\ldots).
%   \item A command |\popup| or |\rightmouse| to define a click on the
%         right mouse button. |\click[Feld]{menu!entry}|.
%         This function could be a feature of the package keystroke.
%         %^^A use mousesymbols.tex
% \end{itemize}
%
% Any comments? Up to now I don't need this features, so I will not
% implement them. If you need it, or think you have a better idea,
% send me a mail to knut@lickert.net.
%
% If you built your own "fancy" style, or have another idea to use
% "!!" and "!", please send me your idea.
%
% \StopEventually\relax
% \part*{Implementation}
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{menu}[
    \filedate\space\fileversion\space menu-Package]
\typeout{Menu.sty: Support of typeout menus}
\RequirePackage{xspace}
%\RequirePackage{keystroke}[2003/08/15 v1.5]
%    \end{macrocode}
%
% \section{Commands}
% \begin{macro}{\menu}
% Take the parameter and send it with an endflag ("\(<\)") to |\@menu|.
%    \begin{macrocode}
\newcommand{\menu}[1]{\@menusymbolStart\@menu #1!<\@menusymbolEnd}
%    \end{macrocode}
% \end{macro}%^^A{\menu}
%
% \begin{macro}{\menutext}
% How to write one step of the menu?
%    \begin{macrocode}
\newcommand{\menutext}[1]{\texttt{#1}}
%    \end{macrocode}
% \end{macro}%^^A{\menu}
%
% \begin{macro}{\@menu}
% Get two parameters, seperated with "!".
% Parameter one can be:
%    \begin{macrocode}
\def\@menu#1!#2<{%
\def\@menuParOne{#1}%
\def\@menuParTwo{#2}%
\def\gt{!}%
\ifx\@empty\@menuParOne%
{\ifx\@menuParTwo\gt%
 \else\expandafter\@menuTo\@menuParTwo <\@menu#2<%
 \fi}%
\else%
\menutext{#1}\expandafter\@menuto\@menuParTwo <\@menu#2!<%
\fi%
}
%    \end{macrocode}
% \end{macro}%^^A{\@menu}
% \begin{macro}{\@menuto}
%    \begin{macrocode}
\def\@menuto#1#2<{\ifx!#1\else\@menusymbolOne\xspace\fi}
%    \end{macrocode}
% \end{macro}%^^A{\menuto}
% \begin{macro}{\@menuTo}
%    \begin{macrocode}
\def\@menuTo#1#2<{\ifx!#1\else\@menusymbolTwo\xspace\fi}
%    \end{macrocode}
% \end{macro}%^^A{\menuTo}
%
% \section{The different symbols}
% \begin{macro}{\@menusymbolStart}
% The symbol, printed on start of |\menu|.
%    \begin{macrocode}
\newcommand*\@menusymbolStart{}
\newcommand*\@menusymbolEnd{}
%    \end{macrocode}
% \end{macro}%^^A{\@menusymbolOne}
% \begin{macro}{\@menusymbolOne}
% The symbol, printed when a "!" occurs in |\menu|.
% The |\xspace| allows a line break after the symbol. I tried |\-|
% (no effect) and |\linebreak[3]|, but the best result was with space.
%    \begin{macrocode}
\newcommand*\@menusymbolOne{\xspace\ensuremath{\rightarrow}}
%    \end{macrocode}
% \end{macro}%^^A{\@menusymbolOne}
% \begin{macro}{\@menusymbolTwo}
% The symbol, printed when a "!!" occurs in |\menu|.
%    \begin{macrocode}
\newcommand*\@menusymbolTwo{\xspace\ensuremath{\Rightarrow}}
%    \end{macrocode}
% \end{macro}%^^A{\@menusymbolTwo}
%
% \begin{macro}{\menusymbol}
% Redefine the symbols for "!" and "!!".
%    \begin{macrocode}
\newcommand*\menusymbols[3][]{
\renewcommand*\@menusymbolStart{#1}
\renewcommand*\@menusymbolOne{#2}
\renewcommand*\@menusymbolTwo{#3}
\@menusymbols
}
%    \end{macrocode}
% \end{macro}%^^A{\@menusymbols}
%
% \begin{macro}{\@menusymbol}
% Define the End-Makro for a menu.
%    \begin{macrocode}
\newcommand*\@menusymbols[1][]{
\renewcommand*\@menusymbolEnd{#1}
}
%    \end{macrocode}
% \end{macro}%^^A{\@menusymbols}
% \begin{macro}{\menumathsymbols}
% Redefine the symbols for "!" and "!!".
%    \begin{macrocode}
\newcommand*\menumathsymbols[3][]{
\renewcommand*\@menusymbolStart{\ensuremath{#1}}
\renewcommand*\@menusymbolOne{\xspace\ensuremath{#2}}
\renewcommand*\@menusymbolTwo{\xspace\ensuremath{#3}}
}
%    \end{macrocode}
% \end{macro}%^^A{\@menumathsymbol}
%
%    \begin{macrocode}
\DeclareOption{big}{
\newlength{\menusep}
\menusymbols[
   \setlength{\menusep}{0em}~\\
 ]{
   \\
   \addtolength{\menusep}{1em}
   \hspace*{\menusep}
 }{
   $\wr$\\
   \addtolength{\menusep}{2em}
   \hspace*{\menusep}
 }[
 \ensuremath{\Leftarrow}
 ]
}
\ProcessOptions
%    \end{macrocode}
%
%
% \Finale
% \PrintIndex
% \end{document}
%</package>
