%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Listings
%
% TODO:
%  - aufräumen
%  - besser strukturieren
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\definecolor{lightgray}{rgb}{0.95, 0.95, 0.95}
\definecolor{darkgray}{rgb}{0.4, 0.4, 0.4}
%\definecolor{purple}{rgb}{0.65, 0.12, 0.82}
\definecolor{editorGray}{rgb}{0.95, 0.95, 0.95}
\definecolor{editorOcher}{rgb}{1, 0.5, 0} % #FF7F00 -> rgb(239, 169, 0)
\definecolor{editorGreen}{rgb}{0, 0.5, 0} % #007C00 -> rgb(0, 124, 0)
\definecolor{green}{rgb}{0, 0.8, 0}
\definecolor{orange}{rgb}{1,0.45,0.13}
\definecolor{olive}{rgb}{0.17,0.59,0.20}
\definecolor{brown}{rgb}{0.69,0.31,0.31}
\definecolor{purple}{rgb}{0.38,0.18,0.81}
\definecolor{lightblue}{rgb}{0.1,0.57,0.7}
\definecolor{lightred}{rgb}{1,0.4,0.5}
\definecolor{darkblue}{rgb}{0.0,0.0,0.6}
\definecolor{cyan}{rgb}{0.0,0.6,0.6}


% Default style for listings
\lstset{literate=
	{á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1
	{Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1
	{à}{{\`a}}1 {è}{{\`e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1
	{À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1
	{ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1
	{Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1
	{â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1
	{Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1
	{œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1
	{ű}{{\H{u}}}1 {Ű}{{\H{U}}}1 {ő}{{\H{o}}}1 {Ő}{{\H{O}}}1
	{ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1
	{€}{{\euro}}1 {£}{{\pounds}}1 {«}{{\guillemotleft}}1
	{»}{{\guillemotright}}1 {ñ}{{\~n}}1 {Ñ}{{\~N}}1 {¿}{{?`}}1,
  backgroundcolor=\color{editorGray},
  basicstyle={\footnotesize\ttfamily},
  breakatwhitespace=true,
  prebreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\rhookswarrow}},
  postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}},
  breaklines=true,   % sets automatic line breaking
  captionpos=b,      % sets the caption-position to bottom
  keepspaces=true,   % keeps spaces in text, useful for keeping indentation
  					 % of code (possibly needs columns=flexible)
  showspaces=false,  % show spaces everywhere adding particular underscores;
  					 % it overrides 'showstringspaces'
  showstringspaces=false, % underline spaces within strings only
  showtabs=false,         % show tabs within strings adding particular underscores
  tabsize=2,	          % sets default tabsize to 2 spaces
  rulecolor=\color{darkgray},   % if not set, the frame-color may be changed on
  								% line-breaks within not-black text
  								% (e.g. comments (green here))
  %numberstyle=\tiny\color{black}, % the style that is used for the line-numbers
  frame=tb,
  % line-numbers
  numbersep=5pt,     % how far the line-numbers are from the code
  stepnumber=1,
  firstnumber=1,
  numberfirstline=true,
  %xleftmargin={0.75cm},
  numbers=left,      % where to put the line-numbers; possible
  					 % values are (none, left, right)
  identifierstyle=\color{black},
  keywordstyle=\color{blue},
  stringstyle=\color{editorOcher},
  commentstyle=\color{brown}
}

% XML
\lstdefinelanguage{XML}{
  morestring=[b]",
  %morestring=[s]{>}{<},
  morecomment=[s]{<?}{?>},
  morecomment=[s]{<!--}{-->},
  stringstyle=\color{black},
  identifierstyle=\color{darkblue},
  keywordstyle=\color{cyan},
  commentstyle=\color{brown},
  morekeywords={xmlns,version,type,idx,val,select,match,mode,name}% list your attributes here
}

% CSS
\lstdefinelanguage{CSS}{
	keywords={color,background-image:,margin,padding,font,weight,display,position,top,left,right,bottom,list,style,border,size,white,space,min,width, transition:, transform:, transition-property, transition-duration, transition-timing-function},
	sensitive=true,
	morecomment=[l]{//},
	morecomment=[s]{/*}{*/},
	morestring=[b]',
	morestring=[b]",
	alsoletter={:},
	alsodigit={-}
}

% JavaScript
\lstdefinelanguage{JavaScript}{
	morekeywords={typeof, new, true, false, catch, function, return, null, catch, switch, var, if, in, while, do, else, case, break},
	morecomment=[s]{/*}{*/},
	morecomment=[l]//,
	morestring=[b]",
	morestring=[b]'
}

% ABAP OO
\lstdefinelanguage{ABAPOO}{
	language=[R/3 6.10]ABAP,
	morekeywords={},
	%morecomment=[s]{/*}{*/},
	%morecomment=[l]//,
	morestring=[b]\|,
	morestring=[b]\`,
	alsoletter={=>},
}

\lstdefinelanguage{HTML5}{
	language=html,
	sensitive=true,
	alsoletter={<>=-},
	morecomment=[s]{<!--}{-->},
	tag=[s],
	otherkeywords={
		% General
		>, />,
		% Paragraphs
		</p, <p, </p>, <i, <u, <em, <tt, <b, <strong, <br/>,
		<table, <td, <tr, <th, <thead, <tfoot, <tbody,</td,</th,</table,</tr,</dl,</dd,
		<img,
		<cite, <code,
		<h1,<h2,<h6,</h1,
		<ol, </ol,</ul,<ul,<li,</li,
		<dt, <dl, <dd,
		<a,</a,
		% Standard tags
		<!DOCTYPE,
		<?xml,
		</html, <html, <head, <title, </title, <style, </style, <link, </head, <meta,
		<span,
		% body
		<body, </body,
		% Divs
		</div, <div, </div>, </span,
		% scripts
		</script, <script,
		<input,
		<address, <main, <blockquote, <figure, <pre,
		<figcaption,
		% More tags...
		<aside, <canvas, /canvas>, <svg, <rect, <animateTransform, </rect>,
		</svg>, <video, <audio, <source, <iframe, </iframe>, </video, </audio,
		<image, </image, <header,
		</header, <footer, </footer, <article, </article, <section, </section,
		<nav, </nav, <menu, </menu, </main, </strong, <hr
	},
	ndkeywords={
		% General
		=,
		% HTML attributes
		charset=, src=, id=, width=, height=, style=, type=, rel=, href=,
		% SVG attributes
		fill=, attributeName=, begin=, dur=, from=, to=, poster=, controls=, x=, y=, repeatCount=, xlink:href=,
		% properties
		margin:, padding:, background-image:, border:, top:, left:, position:, width:, height:, margin-top:, margin-bottom:, font-size:, line-height:,
		% CSS3 properties
		transform:, -moz-transform:, -webkit-transform:,
		animation:, -webkit-animation:,
		transition:,  transition-duration:, transition-property:, transition-timing-function:,color:,text-style:,
	}
}

\lstdefinestyle{htmlcssjs} {%
	% Code design
	identifierstyle=\color{black},
	keywordstyle=\color{blue}\bfseries,
	ndkeywordstyle=\color{editorGreen}\bfseries,
	stringstyle=\color{editorOcher}\ttfamily,
	commentstyle=\color{brown}\ttfamily,
	% Code
	language=HTML5,
	alsolanguage=JavaScript,
	alsodigit={.:;},
	tabsize=2,
	showtabs=false,
	showspaces=false,
	showstringspaces=false,
	extendedchars=true,
	breaklines=true,
	% German umlauts
	literate=%
	{Ö}{{\"O}}1
	{Ä}{{\"A}}1
	{Ü}{{\"U}}1
	{ß}{{\ss}}1
	{ü}{{\"u}}1
	{ä}{{\"a}}1
	{ö}{{\"o}}1
}

\lstdefinestyle{DITA} {%
	% Code design
	identifierstyle=\color{black},
	keywordstyle=\color{blue}\bfseries,
	ndkeywordstyle=\color{editorGreen}\bfseries,
	stringstyle=\color{editorOcher}\ttfamily,
	commentstyle=\color{brown}\ttfamily,
	% Code
	language=HTML5,
	alsolanguage=DITA,
	alsodigit={.:;},
	tabsize=2,
	showtabs=false,
	showspaces=false,
	showstringspaces=false,
	extendedchars=true,
	breaklines=true,
	% German umlauts
	literate=%
	{Ö}{{\"O}}1
	{Ä}{{\"A}}1
	{Ü}{{\"U}}1
	{ß}{{\ss}}1
	{ü}{{\"u}}1
	{ä}{{\"a}}1
	{ö}{{\"o}}1
}

\lstdefinestyle{simpleHtml} {%
	% Code
	language=HTML5,
	alsodigit={.:;},
	tabsize=2,
	showtabs=false,
	showspaces=false,
	showstringspaces=false,
	extendedchars=true,
	breaklines=true,
	% German umlauts
	literate=%
	{Ö}{{\"O}}1
	{Ä}{{\"A}}1
	{Ü}{{\"U}}1
	{ß}{{\ss}}1
	{ü}{{\"u}}1
	{ä}{{\"a}}1
	{ö}{{\"o}}1
}

%
\lstdefinestyle{py} {%
	language=python,
	literate=%
	*{0}{{{\color{lightred}0}}}1
	{1}{{{\color{lightred}1}}}1
	{2}{{{\color{lightred}2}}}1
	{3}{{{\color{lightred}3}}}1
	{4}{{{\color{lightred}4}}}1
	{5}{{{\color{lightred}5}}}1
	{6}{{{\color{lightred}6}}}1
	{7}{{{\color{lightred}7}}}1
	{8}{{{\color{lightred}8}}}1
	{9}{{{\color{lightred}9}}}1,
	tabsize=4,                  % Groesse von Tabs
	extendedchars=true,         %
	breaklines=true,            % Zeilen werden Umgebrochen
	keywordstyle=\color{blue}\bfseries,
	frame=b,
	commentstyle=\color{brown}\itshape,
	stringstyle=\color{editorOcher}\ttfamily, % Farbe der String
	showspaces=false,           % Leerzeichen anzeigen ?
	showtabs=false,             % Tabs anzeigen ?
	xleftmargin=17pt,
	framexleftmargin=17pt,
	framexrightmargin=5pt,
	framexbottommargin=4pt,
	%backgroundcolor=\color{lightgray},
	showstringspaces=false,      % Leerzeichen in Strings anzeigen ?
}

\lstdefinestyle{ABAP}{
	language={ABAPOO},
	% General design
	backgroundcolor=\color{editorGray},
	basicstyle={\footnotesize\ttfamily},
	frame=tb,
	% Code design
	identifierstyle=\color{black},
	keywordstyle=\color{blue}\bfseries,
	stringstyle=\color{editorOcher}\ttfamily,
	commentstyle=\color{brown}\ttfamily,
	% Code
	tabsize=2,
	showtabs=false,
	showspaces=false,
	showstringspaces=false,
	extendedchars=true,
	breaklines=true,
	%literate=%
	%		*{|}{{{\color{editorGreen}{|}}}}{1},
}

\lstdefinestyle{POST}{
	alsoletter={-},
  numbers=left,
	keywords={
		Host,
		User-Agent,
		Accept,
		Accept-Language,
		Accept-Encoding,
		Cookie,
		Connection,
		Content-Type,
		Content-Length,
		Content-Disposition
	}
}
