\RequirePackage{xcolor}
\RequirePackage{listings}

\lstdefinelanguage{pseudocode}
{morekeywords={procedure,function,end,loop,return,to,local,Value,fail,if,then,do,for,else,elif,foreach,in,true,false,
 inputs,returns,persistent,repeat,until,while},
  morecomment=[s]{(*}{*)},
  morecomment=[s]{/*}{*/},   % preferred over (* ... *)
  morecomment=[s][\sl]{<}{>}
}

\lstdefinelanguage[sTeX]{TeX}[LaTeX]{TeX}%
  {moretexcs={[2]defin,twindef,atwindef,definalt,twindefalt,atwindefalt,definiendum,
      importmodule,usemodule,importmhmodule,usemhmodule,gimport,guse,
      symdef,symvariant,symtest,
      defi,defii,defiii,adefi,adefii,adefiii,defis,defiis,defiiis,
      trefi,trefii,trefiii,atrefi,atrefii,atrefiii,mtrefi,mtrefii,mtrefiii,
      trefis,trefiis,trefiiis,atrefis,atrefiis,atrefiiis,
      symi,symii,symiii,
      termref,sref},
   morekeywords={module,definition,axiom,assertion,omtext,
     mhmodule,mhmodsig,mhmodnl,modsig,modnl,
     inputref,
     sproof,spfstep,spfcases,spfcase,justification,premise}}

\definecolor{backcolor}{gray}{.96}

\lstset{columns=fullflexible,basicstyle=\ttfamily}
\lstset{frame=none,numbers=none,lineskip=-.7ex}%,aboveskip=-1em,belowskip=-2em}
\lstset{keywordstyle=[2]\color{red},keywordstyle=[3]\color{blue}}
\lstset{keywordstyle=[4]\color{green},keywordstyle=[5]\color{magenta}}
\lstset{emphstyle=[2]\color{red},emphstyle=[3]\color{blue}}
\lstset{emphstyle=[4]\color{green},emphstyle=[5]\color{magenta}}
\lstset{commentstyle=\color{brown}}
\lstset{backgroundcolor=\color{backcolor}}
\newcommand{\lstkeycolor}[2]{\ifcase#1\textbf{#1}\or\red{#2}\or\blue{#2}\or\green{#2}\or\magenta{#2}\fi}
\define@key{stexlisting}{id}{\def\sref@id{#1}}
\define@key{stexlisting}{id}{\def\stexlst@id{#1}}

% LocalWords:  lstdefinelanguage morekeywords morecomment moretexcs defin sref
% LocalWords:  twindef atwindef definalt twindefalt atwindefalt termref lstset
% LocalWords:  basicstyle scriptsize fullflexible lineskip aboveskip belowskip
% LocalWords:  keywordstyle keywordstyle newcommand lstkeycolor ifcase textbf
% LocalWords:  stexlisting stexlst sproof spfstep symdef spfcases spfcase tt
% LocalWords:  texcsstyle emphstyle emphstyle ttfamily
