% this is customisation of 'listings' packag
% TODO: cleanup

% xcolor must be included before (not done here, because different options may be desired).

\definecolor{darkviolet}{rgb}{0.5,0,0.4} %
\definecolor{darkgreen}{rgb}{0,0.4,0.2} %
\definecolor{darkblue}{rgb}{0.1,0.1,0.9}%
\definecolor{darkgrey}{rgb}{0.5,0.5,0.5} %
\definecolor{lightblue}{rgb}{0.4,0.4,1} %
\definecolor{lightblue1}{rgb}{0 0.25 1}
\definecolor{darkpink}{rgb}{1 0 0.75}
\definecolor{dred}{rgb}{0.8,0,0}
\definecolor{lightlightgrey}{rgb}{0.95 0.95 0.95} %


%\definecolor{oneblue}{rgb}{0,0,0.75}
\definecolor{dockerblue}{rgb}{0.11,0.56,0.98} %
%\definecolor{MyDarkBlue1}{rgb}{0.1,0,0.55}
%\definecolor{lightgrey}{rgb}{0.9,0.9,0.9}

\lstdefinelanguage{pseudo}{
  keywords={procedure,end,return,integer,real,foreach,for,each,
  do,if,then,else,while,until,true,false,algorithm},
  comment=[l]{//}
}

\lstdefinelanguage{oaw}{
  morekeywords={import, this, create, let, then, Void, extension, JAVA,
  IMPORT, DEFINE, ENDDEFINE, LET, ENDLET, FOR, FILE, ENDFILE, ITERATOR, FOREACH,
  AS, IF, ENDFOREACH, ENDIF, EXPAND, INSTANCEOF, USING, SEPARATOR, CSTART, CEND,
  PROTECT, ENDPROTECT, ID, EXTENSION,
  context, ERROR, WARNING, INFO, enum},
  morecomment=[l]{//},
  morecomment=[s]{/*}{*/},
  % FIXME: listings does not see guillemets, so any regions with them wont work
  morecomment=[s]{«REM»}{«ENDREM»},
  morecomment=[s]{«REM}{»},
  morestring=[s]{'}{'},
  morestring=[s]{"}{"},
  escapechar={@},
  % required for use with UTF-8
  literate={«}{\guillemotleft}{1}
           {»}{\guillemotright}{1}
}

% extension, if, then, else, switch, Void, Boolean, Integer, Real, String, let

\lstdefinelanguage{shell}
{alsodigit={>},
  morekeywords={linux>},
  backgroundcolor=\color{lstbackgroundshellcolor}
}

\lstdefinelanguage{csimul}
{alsodigit={>},
  alsodigit={\%},
  morekeywords={CONDITIONER>, COUNTER>, \%},
  backgroundcolor=\color{lstbackgroundshellcolor},
  morecomment=[l]{\#}
}

\newcommand{\lstfontfamily}{\ttfamily}
%\newcommand{\lstfontfamily}{\sffamily} % Adapt to schneider
\newcommand{\textlst}[1]{\texttt{#1}}
\newcommand{\mathlst}[1]{\mathtt{#1}}
\lstdefinestyle{tiny}{basicstyle=\tiny\lstfontfamily}
\lstdefinestyle{scriptsize}{basicstyle=\scriptsize\lstfontfamily}
\lstdefinestyle{footnotesize}{basicstyle=\footnotesize\lstfontfamily}
\lstdefinestyle{small}{basicstyle=\small\lstfontfamily}
\lstdefinestyle{normalsize}{basicstyle=\normalsize\lstfontfamily}
\lstdefinestyle{large}{basicstyle=\lstfontfamily}

\lstdefinestyle{monitor}{morekeywords={monitor, export}}
\lstdefinestyle{ConcPascal}{language=Pascal,style=monitor}

% To make this accessible to Emacs/AUCTeX (C-c C-f C-o),
% add something like this to TeX-mode-hook:
%  (setq LaTeX-font-list
%       (append '((?{\^O} "\\codefont{" "}"))
%               LaTeX-font-list))
%\newcommand{\codefont}[1]{{\renewcommand{\textnormal}[1]{\textlst{#1}}\lstfontfamily #1}}
\newcommand{\mathcodefont}[1]{\mathtt{#1}}
\newcommand{\codefont}[1]{{\lstfontfamily #1}}
\newlength{\lstframexleftmargin}
\setlength{\lstframexleftmargin}{1mm}

% rulesepcolor and backgroundcolor are set in beamercustom{presentation|handout}.sty
\lstdefinestyle{mydefault}{
  style=scriptsize,
  emphstyle=\color{red},
  framexleftmargin=\lstframexleftmargin,
  frame=shadowbox,
  keywordstyle=\structure,
  commentstyle=\itshape,
  columns=flexible,            % Columns not rigid - gives nicer spacing
  gobble=4,                    % Gobble first 4 characters of each line
  escapeinside=`',
  escapechar=@,
  lineskip=+0.2ex,
  rulesepcolor=\color{lstrulesepcolor},
  % WARNING: For some reason, the settin of backgroundcolor must take
  % place at the very end!!!
  backgroundcolor=\color{lstbackgroundprogcolor}
}

\lstdefinestyle{eclipse}{
    basicstyle=\small\lstfontfamily,
    emphstyle=\color{red}\bfseries,
    keywordstyle=\color{darkviolet}\bfseries,
    commentstyle=\color{darkgreen},
    stringstyle=\color{darkblue},
    numberstyle=\color{darkgrey}\lstfontfamily,
    emph={Simulation,MaterialManager,MultiLayer,Layer,Particle,ParticleDecoration},
    emphstyle=\color{dockerblue},
    % get also javadoc style comments
    morecomment=[s][\color{lightblue}]{/**}{*/},
   %columns=fullflexible, %spaceflexible, %flexible, fullflexible
%  escapeinside=`',
%  escapechar=@,
  showstringspaces=false,
  numbers=left,
escapeinside={@}{@}, %reference to line number in text
breaklines = true
}

\lstdefinestyle{black}{
  basicstyle=\small\lstfontfamily,
  numbers=left,
  columns=fullflexible,
  breaklines=true,
  mathescape=true,
  escapechar=\#,
  tabsize=4,
  frame=lines,
  showstringspaces=false
}




\lstdefinestyle{eclipseboxed}{
moredelim=[is][\color{red}\itshape]{|}{|},
   escapeinside={@}{@},
    basicstyle=\small\lstfontfamily,
    emphstyle=\color{red}\bfseries,
    keywordstyle=\color{darkviolet}\bfseries,
    commentstyle=\color{darkgreen},
    stringstyle=\color{darkblue},
    numberstyle=\color{darkgrey}\lstfontfamily,
    emph={Simulation,MaterialManager,MultiLayer,Layer,Particle,ParticleDecoration},
    emphstyle=\color{dockerblue},
    backgroundcolor=\color{lightlightgrey},
    morecomment=[s][\color{lightblue}]{/**}{*/},
  showstringspaces=false,
  numbers=left,
 emphstyle={[2]\color{blue}},
 frame=single,
firstnumber=auto,
 rulesepcolor=\color{darkgrey},
rulecolor=\color{darkgrey},
breaklines = true
%showspaces=true,
%showtabs=true,
%tabsize=1
}

% use proper tt font that supports bold printing, e.g. by
% \usepackage{courier}
\lstdefinestyle{seminar}{
  basicstyle=\small\ttfamily,
  numbers=left,
  breaklines=true,
  mathescape=true,
  escapechar=\#,
  tabsize=4,
  showstringspaces=false
}


\lstdefinestyle{commandline}{
   escapeinside={@}{@},
    basicstyle=\small\lstfontfamily,
    emphstyle=\color{red}\bfseries,
    keywordstyle=\color{darkviolet}\bfseries,
    commentstyle=\color{darkgreen},
    stringstyle=\color{darkblue},
    numberstyle=\color{darkgrey}\lstfontfamily,
    emphstyle=\color{red},
    backgroundcolor=\color{lightlightgrey},
    morecomment=[s][\color{lightblue}]{/**}{*/},
  showstringspaces=false,
 emphstyle={[2]\color{blue}},
 frame=single,
firstnumber=auto,
 rulesepcolor=\color{darkgrey},
rulecolor=\color{darkgrey},
breaklines = true,
numbers=none,
%showspaces=true,
%showtabs=true,
%tabsize=1
}


% Another example of customisation (to Study)

% \documentclass[a4paper,12pt]{article}
% \usepackage[utf8]{inputenc}
%
% % Default fixed font does not support bold face
% \DeclareFixedFont{\ttb}{T1}{txtt}{bx}{n}{12} % for bold
% \DeclareFixedFont{\ttm}{T1}{txtt}{m}{n}{12}  % for normal
%
% % Custom colors
% \usepackage{color}
% \definecolor{deepblue}{rgb}{0,0,0.5}
% \definecolor{deepred}{rgb}{0.6,0,0}
% \definecolor{deepgreen}{rgb}{0,0.5,0}
%
% \usepackage{listings}
%
% % Python style for highlighting
% \newcommand\pythonstyle{\lstset{
% language=Python,
% basicstyle=\ttm,
% otherkeywords={self},             % Add keywords here
% keywordstyle=\ttb\color{deepblue},
% emph={MyClass,__init__},          % Custom highlighting
% emphstyle=\ttb\color{deepred},    % Custom highlighting style
% stringstyle=\color{deepgreen},
% frame=tb,                         % Any extra options here
% showstringspaces=false            %
% }}
%
%
% % Python environment
% \lstnewenvironment{python}[1][]
% {
% \pythonstyle
% \lstset{#1}
% }
% {}
%
% % Python for external files
% \newcommand\pythonexternal[1]{{
% \pythonstyle
% \lstinputlisting{#1}}}
%
% % Python for inline
% \newcommand\pythoninline[1]{{\pythonstyle\lstinline!#1!}}
%
% \begin{document}
%
% \section{``In-text'' listing highlighting}
%
% \begin{python}
% class MyClass(Yourclass):
%     def __init__(self, my, yours):
%         bla = '5 1 2 3 4'
%         print bla
% \end{python}
%
% \section{External listing highlighting}
%
% \pythonexternal{demo.py}
%
% \section{Inline highlighting}
%
% Definition \pythoninline{class MyClass} means \dots
%
% \end{document}
%
