% Copyright The Numerical Algorithms Group Limited 1992-1994.
% All rights reserved

% ----------------------------------------------------------------------
% This file contains macros for the FriCAS HyperDoc hypertext facility.
% Most of the macros for the system are here though there may be some in
% individual .ht files that are of a local nature.
% ----------------------------------------------------------------------

% ----------------------------------------------------------------------
% 1. Names of software and facilities.
% ----------------------------------------------------------------------

\newcommand{\Browse}{Browse}
\newcommand{\Language}{FriCAS}
\newcommand{\HyperName}{HyperDoc}
\newcommand{\aldor}{Aldor}
\newcommand{\Clef}{Clef}
\newcommand{\Lisp}{Common LISP}

% ----------------------------------------------------------------------
% 2. Special pages used by HyperDoc.
% ----------------------------------------------------------------------

\newcommand{\GoBackToWork}{\vspace{2}\newline{Click on \  \UpButton{} \  to go back to what you were doing.}}

\begin{page}{SpadNotConnectedPage}{Not Connected to FriCAS}
\beginscroll
\HyperName{} isn't connected to \Language{}, therefore cannot execute
the button you pressed.
%
\GoBackToWork{}
\endscroll
\end{page}

\begin{page}{ProtectedQuitPage}{Do You Really Want to Exit?}
\beginscroll
{Click again on \  \ExitButton{QuitPage} \  to terminate \HyperName{}.}
\vspace{1}\newline
\centerline{OR}
\GoBackToWork{}
\endscroll
\autobuttons
\end{page}

\begin{page}{UnknownPage}{Missing Page}
\beginscroll
\pp
The page you requested was not found in the \HyperName{} database.
\GoBackToWork{}
\endscroll
\end{page}

\begin{page}{ErrorPage}{Something is Wrong}
\beginscroll
{For some reason the page you tried to link to cannot be formatted.}
\GoBackToWork{}
\endscroll
\autobuttons
\end{page}

\begin{page}{Unlinked}{Sorry!}
\beginscroll
{This link is not implemented yet.}
\GoBackToWork{}
\endscroll
\autobuttons
\end{page}

% ----------------------------------------------------------------------
% 3. Special hooks to Unix.
% ----------------------------------------------------------------------

% All unix commands should be done as macros defined here so we don't
% have to go hunting when moving between Unix versions.

\newcommand{\searchwindow}[2]{\unixwindow{#1}{\$FRICAS/lib/htsearch "#2"}}
\newcommand{\unixwindow}[2]{\unixlink{#1}{#2}}
\newcommand{\menuunixlink}[2]{\item\unixlink{\menuitemstyle{#1}}{#2}}
\newcommand{\menuunixcommand}[2]{\item\unixcommand{\menuitemstyle{#1}}{#2}}
\newcommand{\menuunixwindow}[2]{\item\unixwindow{\menuitemstyle{#1}}{#2}}

% ----------------------------------------------------------------------
% 4. HyperDoc menu macros.
% ----------------------------------------------------------------------

% Example:
%
% \beginmenu
% \menulink{Thing One}{PageOne} la da di da da ...
% \menulink{Thin Two}{PageTwo}  do da day ...
% \item \ACmdMacro{\menuitemstyle{Thing Three}} la di da ...
% \endmenu

% The menu environment

\newcommand{\beginmenu}          {\beginitems[\MenuDotBitmap]}
\newcommand{\endmenu}            {\enditems}

% This is the usual format for a menu item.

\newcommand{\menuitemstyle}[1]   {{\MenuDotBitmap}#1}

% Often-used menu item forms

%   These two simply do links
\newcommand{\menudownlink}[2]    {\item\downlink{\menuitemstyle{#1}}{#2}}
\newcommand{\menulink}[2]        {\menudownlink{#1}{#2}}

%   This will cause lower level links to have a HOME button
\newcommand{\menumemolink}[2]    {\item\memolink{\menuitemstyle{#1}}{#2}}

%   This opens a new window for the linked page.
\newcommand{\menuwindowlink}[2]    {\item\windowlink{\menuitemstyle{#1}}{#2}}

%   These execute lisp commands in various flavors
\newcommand{\menulispcommand}[2] {\item\lispcommand{\menuitemstyle{#1}}{#2}}
\newcommand{\menulispdownlink}[2]{\item\lispdownlink{\menuitemstyle{#1}}{#2}}
\newcommand{\menulispmemolink}[2]{\item\lispmemolink{\menuitemstyle{#1}}{#2}}
\newcommand{\menulispwindowlink}[2]{\item\lispwindowlink{\menuitemstyle{#1}}{#2}}

%   This executes a unix command
\newcommand{\menuunixcmd}[2]     {\item\unixcommand{\menuitemstyle{#1}}{#2}}
\newcommand{\searchresultentry}[3]{\tab{3}\item#3\tab{8}\downlink{\menuitemstyle{#1}}{#2}\newline}
\newcommand{\newsearchresultentry}[3]{\tab{3}\item#1\tab{8}\downlink{\menuitemstyle{#2}}{#3}\newline}

% ----------------------------------------------------------------------
% 5. Bitmaps and bitmap manipulation macros.
% ----------------------------------------------------------------------

\newcommand{\htbmdir}{\env{FRICAS}/share/hypertex/bitmaps}
\newcommand{\htbmfile}[1]{\htbmdir /#1.bitmap}
\newcommand{\htbitmap}[1]{\inputbitmap{\htbmfile{#1}}}
\newcommand{\ControlBitmap}[1]{\controlbitmap{\htbmfile{#1}}}

% next group of bitmaps frequently appear in the titlebar
\newcommand{\ContinueBitmap} {\ControlBitmap{Continue}}
\newcommand{\DoItBitmap}     {\ControlBitmap{DoIt}}
\newcommand{\ExitBitmap}     {\ControlBitmap{exit3d}}
\newcommand{\HelpBitmap}     {\ControlBitmap{help3d}}
\newcommand{\ReturnBitmap}   {\ControlBitmap{home3d}}
\newcommand{\NoopBitmap}       {\ControlBitmap{noop3d}}
\newcommand{\UpBitmap}       {\ControlBitmap{up3d}}

\newcommand{\MenuDotBitmap}{\htbitmap{menudot}}

% Including control panel pixmaps for help pages:

\newcommand{\helpbit}[1]{\centerline{\inputpixmap{\env{FRICAS}/share/hypertex/pixmaps/{#1}}}}

% ----------------------------------------------------------------------
% 6. HyperDoc button objects.
% ----------------------------------------------------------------------

\newcommand{\ContinueButton}[1]{\downlink{Click here}{#1} to continue.}
\newcommand{\ExitButton}[1]{\memolink{\ExitBitmap}{#1}}
\newcommand{\HelpButton}[1]{\memolink{\HelpBitmap}{#1}}
\newcommand{\StdHelpButton}{\HelpButton{ugHyperPage}}
\newcommand{\StdExitButton}{\ExitButton{ProtectedQuitPage}}
\newcommand{\UpButton}{\upbutton{\UpBitmap}{UpPage}}
\newcommand{\ReturnButton}{\returnbutton{\ReturnBitmap}{ReturnPage}}
\newcommand{\on}[1]{{\inputbox[1]{#1}{\htbmfile{pick}}
             {\htbmfile{unpick}}}}
\newcommand{\off}[1]{{\inputbox[0]{#1}{\htbmfile{pick}}
             {\htbmfile{unpick}}}}

% ----------------------------------------------------------------------
% 6. Standard HyperDoc button configurations.
% ----------------------------------------------------------------------

\newcommand{\autobutt}[1]{\helppage{#1}}
\newcommand{\autobuttons}{}
\newcommand{\exitbuttons}{}

\newcommand{\autobuttLayout}[1]{\centerline{#1}}}
\newcommand{\autobuttMaker}[1]{\autobuttLayout{\HelpButton{#1}}}
\newcommand{\riddlebuttons}[1]{\autobuttLayout{\link{\HelpBitmap}{#1}}}

% Macro for downward compatibility (?).

\newcommand{\simplebox}[2]{\inputbox[#1]{#2}{\htbitmap{Xbox}}{\htbitmap{Xopenbox}}}

% ----------------------------------------------------------------------
% 7. HyperDoc graphics macros.
% ----------------------------------------------------------------------

% Including viewport bitmaps within \HyperName pages:

\newcommand{\viewport}[1]{\inputimage{{#1}.VIEW/image}}
\newcommand{\spadviewport}[1]{\inputimage{\env{FRICAS}/share/viewports/{#1}.VIEW/image}}

% Creating a real live viewport:

\newcommand{\viewportbutton}[2]{\unixcommand{#1}{\$FRICAS/bin/viewAlone #2}}
\newcommand{\spadviewportbutton}[2]{\unixcommand{#1}{\$FRICAS/bin/viewAlone \$FRICAS/share/viewports/{#2}}}

% Making active viewport buttons:

\newcommand{\viewportasbutton}[1]{\unixcommand{\inputimage{{#1}.VIEW/image}}{\$FRICAS/bin/viewAlone {#1}}}
\newcommand{\spadviewportasbutton}[1]{\unixcommand{\inputimage{\env{FRICAS}/share/viewports/{#1}.VIEW/image}}{\$FRICAS/bin/viewAlone \$FRICAS/share/viewports/{#1}}}

% ----------------------------------------------------------------------
% 8. TeX and LaTeX compatibility macros.
% ----------------------------------------------------------------------

\newcommand{\LARGE}{}
\newcommand{\LaTeX}{LaTeX}
\newcommand{\Large}{}
\newcommand{\TeX}{TeX}
\newcommand{\allowbreak}{}
\newcommand{\aleph}{\inputbitmap{\htbmdir{}/aleph.bitmap}}
\newcommand{\alpha}{\inputbitmap{\htbmdir{}/alpha.bitmap}}
\newcommand{\angle}{\inputbitmap{\htbmdir{}/angle.bitmap}}
\newcommand{\backslash}{\inputbitmap{\htbmdir{}/backslash.bitmap}}
\newcommand{\beta}{\inputbitmap{\htbmdir{}/beta.bitmap}}
\newcommand{\bigbreak}{\newline\newline}
\newcommand{\bot}{\inputbitmap{\htbmdir{}/bot.bitmap}}
\newcommand{\bullet}{\inputbitmap{\htbmdir{}/bullet.bitmap}}
\newcommand{\caption}[1]{\newline\centerline{#1}\newline}
\newcommand{\chi}{\inputbitmap{\htbmdir{}/chi.bitmap}}
\newcommand{\cite}[1]{bibliography entry for {\it #1}}
\newcommand{\cleardoublepage}{}
\newcommand{\coprod}{\inputbitmap{\htbmdir{}/coprod.bitmap}}
\newcommand{\del}{\inputbitmap{\htbmdir{}/del.bitmap}}
\newcommand{\delta}{\inputbitmap{\htbmdir{}/delta.bitmap}}
\newcommand{\Delta}{\inputbitmap{\htbmdir{}/delta-cap.bitmap}}
\newcommand{\div}{\inputbitmap{\htbmdir{}/div.bitmap}}
\newcommand{\dot}{\inputbitmap{\htbmdir{}/dot.bitmap}}
\newcommand{\ell}{\inputbitmap{\htbmdir{}/ell.bitmap}}
\newcommand{\emptyset}{\inputbitmap{\htbmdir{}/emptyset.bitmap}}
\newcommand{\epsilon}{\inputbitmap{\htbmdir{}/epsilon.bitmap}}
\newcommand{\eta}{\inputbitmap{\htbmdir{}/eta.bitmap}}
\newcommand{\exists}{\inputbitmap{\htbmdir{}/exists.bitmap}}
\newcommand{\forall}{\inputbitmap{\htbmdir{}/forall.bitmap}}
\newcommand{\footnote}[1]{ {(#1)}}
\newcommand{\frenchspacing}{}
\newcommand{\gamma}{\inputbitmap{\htbmdir{}/gamma.bitmap}}
\newcommand{\Gamma}{\inputbitmap{\htbmdir{}/gamma-cap.bitmap}}
\newcommand{\hbar}{\inputbitmap{\htbmdir{}/hbar.bitmap}}
\newcommand{\hbox}[1]{{#1}}
\newcommand{\hfill}{}
\newcommand{\huge}{}
\newcommand{\Im}{\inputbitmap{\htbmdir{}/Im.bitmap}}
\newcommand{\imath}{\inputbitmap{\htbmdir{}/imath.bitmap}}
\newcommand{\includehyperdoc}[2]{}
\newcommand{\infty}{\inputbitmap{\htbmdir{}/infty.bitmap}}
\newcommand{\int}{\inputbitmap{\htbmdir{}/int.bitmap}}
\newcommand{\iota}{\inputbitmap{\htbmdir{}/iota.bitmap}}
\newcommand{\index}[1]{}
\newcommand{\jmath}{\inputbitmap{\htbmdir{}/jmath.bitmap}}
\newcommand{\kappa}{\inputbitmap{\htbmdir{}/kappa.bitmap}}
\newcommand{\label}[1]{}
\newcommand{\lambda}{\inputbitmap{\htbmdir{}/lambda.bitmap}}
\newcommand{\Lambda}{\inputbitmap{\htbmdir{}/lambda-cap.bitmap}}
\newcommand{\large}{}
\newcommand{\ldots}{...}
\newcommand{\le}{<=}
\newcommand{\marginpar}[1]{}
\newcommand{\mu}{\inputbitmap{\htbmdir{}/mu.bitmap}}
\newcommand{\neg}{\inputbitmap{\htbmdir{}/neg.bitmap}}
\newcommand{\newpage}{}
\newcommand{\noindent}{\indent{0}}
\newcommand{\nonfrenchspacing}{}
\newcommand{\nabla}{\inputbitmap{\htbmdir{}/nabla.bitmap}}
\newcommand{\nu}{\inputbitmap{\htbmdir{}/nu.bitmap}}
\newcommand{\omega}{\inputbitmap{\htbmdir{}/omega.bitmap}}
\newcommand{\Omega}{\inputbitmap{\htbmdir{}/omega-cap.bitmap}}
\newcommand{\pageref}[1]{???}
\newcommand{\parallel}{\inputbitmap{\htbmdir{}/parallel.bitmap}}
\newcommand{\partial}{\inputbitmap{\htbmdir{}/partial.bitmap}}
\newcommand{\phi}{\inputbitmap{\htbmdir{}/phi.bitmap}}
\newcommand{\Phi}{\inputbitmap{\htbmdir{}/phi-cap.bitmap}}
\newcommand{\pi}{\inputbitmap{\htbmdir{}/pi.bitmap}}
\newcommand{\Pi}{\inputbitmap{\htbmdir{}/pi-cap.bitmap}}
\newcommand{\prime}{\inputbitmap{\htbmdir{}/prime.bitmap}}
\newcommand{\prod}{\inputbitmap{\htbmdir{}/prod.bitmap}}
\newcommand{\protect}{}
\newcommand{\psi}{\inputbitmap{\htbmdir{}/psi.bitmap}}
\newcommand{\Psi}{\inputbitmap{\htbmdir{}/psi-cap.bitmap}}
\newcommand{\quad}{\inputbitmap{\htbmdir{}/quad.bitmap}}
\newcommand{\Re}{\inputbitmap{\htbmdir{}/Re.bitmap}}
\newcommand{\rho}{\inputbitmap{\htbmdir{}/rho.bitmap}}
\newcommand{\sc}{\rm}
\newcommand{\sf}{\bf}
\newcommand{\sigma}{\inputbitmap{\htbmdir{}/sigma.bitmap}}
\newcommand{\Sigma}{\inputbitmap{\htbmdir{}/sigma-cap.bitmap}}
\newcommand{\small}{}
\newcommand{\sum}{\inputbitmap{\htbmdir{}/sum.bitmap}}
\newcommand{\surd}{\inputbitmap{\htbmdir{}/surd.bitmap}}
\newcommand{\tau}{\inputbitmap{\htbmdir{}/tau.bitmap}}
\newcommand{\theta}{\inputbitmap{\htbmdir{}/theta.bitmap}}
\newcommand{\Theta}{\inputbitmap{\htbmdir{}/theta-cap.bitmap}}
% Missing bitmap
% \newcommand{\times}{\inputbitmap{\htbmdir{}/times.bitmap}}
\newcommand{\times}{x}
\newcommand{\top}{\inputbitmap{\htbmdir{}/top.bitmap}}
\newcommand{\triangle}{\inputbitmap{\htbmdir{}/triangle.bitmap}}
\newcommand{\upsilon}{\inputbitmap{\htbmdir{}/upsilon.bitmap}}
\newcommand{\Upsilon}{\inputbitmap{\htbmdir{}/upsilon-cap.bitmap}}
\newcommand{\url}[1]{{#1}}
\newcommand{\vbox}[1]{{#1}}
\newcommand{\wp}{\inputbitmap{\htbmdir{}/wp.bitmap}}
\newcommand{\xi}{\inputbitmap{\htbmdir{}/xi.bitmap}}
\newcommand{\Xi}{\inputbitmap{\htbmdir{}/xi-cap.bitmap}}
\newcommand{\zeta}{\inputbitmap{\htbmdir{}/zeta.bitmap}}
\newcommand{\bs}{\\}

% ----------------------------------------------------------------------
% 9. Book and .ht page macros.
% ----------------------------------------------------------------------

\newcommand{\beginImportant}{\horizontalline}
\newcommand{\endImportant}{\horizontalline}
%
% following handles things like "i-th" but uses "-th"
\newcommand{\eth}[1]{\spad{#1}-th}}
%
\newcommand{\texnewline}{}
\newcommand{\texbreak}{}
\newcommand{\Gallery}{{FriCAS Images}}
\newcommand{\exptypeindex}[1]{}
\newcommand{\gotoevenpage}{}
\newcommand{\ignore}[1]{}
\newcommand{\ind}{\newline\tab{3}}
\newcommand{\menuspadref}[2]{\menudownlink{#1}{#2Page}}
\newcommand{\menuxmpref}[1]{\menudownlink{`#1'}{#1XmpPage}}
\newcommand{\noOutputXtc}[2]{\xtc{#1}{#2}}  % comment and then \spadcommand or spadsrc
\newcommand{\not=}{\inputbitmap{\htbmdir{}/not=.bitmap}}
\newcommand{\notequal}{\inputbitmap{\htbmdir{}/notequal.bitmap}}
\newcommand{\nullXtc}[2]{\xtc{#1}{#2}}      % comment and then \spadcommand or spadsrc
\newcommand{\pp}{\newline}              % Use this instead of \par for now.
\newcommand{\psXtc}[3]{\xtc{#1}{#2}}        % comment and then \spadcommand or spadsrc
\newcommand{\ref}[1]{(see the graph)}
\newcommand{\showBlurb}[1]{Issue the system command \spadsys{)show #1} to display the full list of operations defined by \spadtype{#1}.}
\newcommand{\smath}[1]{\spad{#1}}
\newcommand{\spadFileExt}{.spad}
\newcommand{\spadkey}[1]{}
\newcommand{\spadref} [1]{{\it #1}}
\newcommand{\subscriptIt}[2]{{\it {#1}\_{#2}}}
\newcommand{\subscriptText}[2]{{\it {#1}\_{\it #2}}}
\newcommand{\subsubsection}[1]{\newline\indent{0}{\bf #1}\newline\newline}
\newcommand{\syscmdindex}[1]{}              % system command index macro
\newcommand{\threedim}{three-dimensional}
\newcommand{\twodim}{two-dimensional}
\newcommand{\unind}{\newline}
\newcommand{\void}{the unique value of \spadtype{Void}}
\newcommand{\xdefault}[1]{The default value is {\tt "#1"}.}
\newcommand{\xmpLine}[2]{{\tt #1}\newline}   % have to improve someday
\newcommand{\xmpref}[1]{\downlink{`#1'}{#1XmpPage}}
\newcommand{\xtc}[2]{#1 #2}                 % comment and then \spadcommand or spadsrc

% glossary terms
\newcommand{\spadgloss}[1]{\lispdownlink{#1}{(|htGloss| "#1")}}
\newcommand{\spadglossSee}[2]{\lispdownlink{#1}{(|htGloss| "#2")}}

% use this for syntax punctuation: \spadSyntax{::}
\newcommand{\spadSyntax}[1]{``{\tt #1}''}

% constructors
\newcommand{\spadtype}[1]{\lispdownlink{#1}{(|spadType| "#1")}}
\newcommand{\pspadtype}[1]{{\it #1}}       % things that browse can't handle

\newcommand{\spad}   [1]{{\tt #1}}              % note font
\newcommand{\spadvar} [1]{\spad{#1}}            % exists in ++ comments; to be removed
\newcommand{\s}       [1]{\spad{#1}}

\newcommand{\texht}[2]{#2}

% Function names:
%
% The X versions below are used because FriCAS function names that end
% in ``!'' cause problems for makeindex for had-copy.
%
% Example: \spadfunFromX{reverse}{List} prints as   reverse!
%
% In the "From" versions, the first arg is function name, second is constructor
% where exported.
%
% Use the "op" flavors of "-", "+", "*" etc, otherwise the "fun" flavors

\newcommand{\userfun} [1]{{\bf #1}}              % example, non-library function names

\newcommand{\pspadfun}[1]{{\bf #1}}          % not really a library function

\newcommand{\spadfun} [1]{\lispdownlink{#1}{(|oPage| "#1")}}
\newcommand{\spadfunX}[1]{\spadfun{#1!}}

\newcommand{\spadfunFrom}[2]{\lispdownlink{#1}{(|oPageFrom| "#1" "#2")}}
\newcommand{\spadfunFromX}[2]{\spadfunFrom{#1!}{#2}}

\newcommand{\spadop}[1]{\lispdownlink{#1}{(|oPage| "#1")}}

\newcommand{\spadopFrom}[2]{\lispdownlink{#1}{(|oPageFrom| "#1" "#2")}}

% defns for system commands
\newcommand{\spadsys}[1]{{\tt #1}}

\newcommand{\cs}[1]{\\#1}

% ----------------------------------------------------------------------
% 10. Browse macros.
% ----------------------------------------------------------------------

\newcommand{\undocumented}[0]{is not documented yet}
\newcommand{\aliascon}[2]{\lispdownlink{#1}{(|conPage| '|#2|)}}
\newcommand{\aliasdom}[2]{\lispdownlink{#1}{(|conPage| '|#2|)}}
\newcommand{\andexample}[1]{\indent{5}\spadcommand{#1}\indent{0}\newline}
\newcommand{\blankline}{\vspace{1}\newline }
\newcommand{\con}[1]{\lispdownlink{#1}{(|conPage| '|#1|)}}

\newcommand{\conf}[2]{\lispdownlink{#1}{(|conPage| '{#2})}}
% generalizes "con" to allow arbitrary title and form

\newcommand{\dlink}[2]{\downlink{#2}{#1}}
\newcommand{\dom}[1]{\lispdownlink{#1}{(|conPage| '|#1|)}}
\newcommand{\example}[1]{\newline\indent{5}\spadcommand{#1}\indent{0}\newline}
\newcommand{\lisp}[2]{\lispdownlink{#2}{#1}}
\newcommand{\indented}[2]{\indentrel{#1}\newline #2\indentrel{-#1}\newline}
\newcommand{\spadignore}[1]{#1}

% ----------------------------------------------------------------------
% 11. Support for output and graph paste-ins.
% ----------------------------------------------------------------------

\newcommand{\showpaste}{\htbitmap{sdown3d}}
\newcommand{\hidepaste}{\htbitmap{sup3d}}
\newcommand{\spadpaste}[1]{
  \newline
  \begin{paste}{\pagename Empty \examplenumber}{\pagename Patch \examplenumber}
  \pastebutton{\pagename Empty \examplenumber}{\showpaste}
  \tab{5}\spadcommand{#1}
  \end{paste}
}

\newcommand{\graphpaste}[1]{
  \newline
  \begin{paste}{\pagename Empty \examplenumber}{\pagename Patch \examplenumber}
  \pastebutton{\pagename Empty \examplenumber}{\showpaste}
  \tab{5}\spadgraph{#1}
  \end{paste}
}

% ----------------------------------------------------------------------
% 12. Hook for including a local menu item on the rootpage.
% ----------------------------------------------------------------------

\newcommand{\localinfo}{}

% For chapter 6 (User-Defined Functions, Macros and Rules)
\newcommand{\pred}[1]{\subscriptIt{pred}{#1}}
\newcommand{\expr}[1]{\subscriptIt{expression}{#1}}

% For chapter 7 (Graphics)
\newcommand{\optArg}[1]{{{\tt [}{#1}{\tt ]}}}
\newcommand{\argDef}[1]{{\tt ({#1})}}
\newcommand{\funArgs}[1]{{\tt ({\small\it {#1}})}\newline}

% For chapter 16 (\Language{} System Commands)
\newcommand{\lanb}{{\tt [}}
\newcommand{\ranb}{{\tt ]}}
