|
1 \usepackage{listings} |
|
2 \usepackage{etoolbox} |
|
3 \setmonofont[Scale=.95]{Consolas} |
|
4 \newfontfamily{\consolas}{Consolas} |
|
5 |
|
6 \definecolor{codered}{rgb}{0.6,0,0} % for strings |
|
7 \definecolor{codegreen}{rgb}{0.25,0.5,0.35} % comments |
|
8 \definecolor{codepurple}{rgb}{0.5,0,0.35} % keywords |
|
9 \definecolor{codedocblue}{rgb}{0.25,0.35,0.75} % doc |
|
10 \definecolor{codeblue}{rgb}{0.25,0.35,0.75} % types |
|
11 |
|
12 \BeforeBeginEnvironment{lstlisting}{\par\noindent\begin{minipage}{\linewidth}} |
|
13 \AfterEndEnvironment{lstlisting}{\end{minipage}\par} |
|
14 |
|
15 \lstdefinelanguage{Scala}{ |
|
16 morekeywords={abstract,case,catch,class,def,% |
|
17 do,else,extends,false,final,finally,% |
|
18 for,if,implicit,import,match,mixin,% |
|
19 new,null,object,override,package,% |
|
20 private,protected,requires,return,sealed,% |
|
21 super,this,throw,trait,true,try,% |
|
22 type,val,var,while,with,yield,write,read},% |
|
23 otherkeywords={=>,<-,<\%,<:,>:,\#},% |
|
24 sensitive=true,% |
|
25 %directives={Int,Char,Rexp,String,Boolean,BigInt,Unit,List,Set},% |
|
26 %moredelim=*[directive]:,% |
|
27 morecomment=[l]{//},% |
|
28 morecomment=[n]{/*}{*/}, |
|
29 morestring=[s]{"""}{"""}, |
|
30 morestring=[b]", |
|
31 morestring=[b]', |
|
32 }[keywords,comments,strings] |
|
33 |
|
34 \lstdefinelanguage{While}{ |
|
35 morekeywords={if,then,else,while,do,true,false,write,upto,read,for,skip}, |
|
36 morecomment=[l]{//}, |
|
37 morecomment=[n]{/*}{*/}, |
|
38 morestring=[b]", |
|
39 otherkeywords={=,!=,:=,<,>,\%;*,/}, |
|
40 }[keywords,comments,strings] |
|
41 |
|
42 |
|
43 \newcommand{\code}[1]{{\lstinline{#1}}} |
|
44 \newcommand{\pcode}[1]{\mbox{\lstset{language={},keywordstyle=\color{black}}\lstinline!#1!}} |
|
45 \newcommand{\scode}[1]{\mbox{\lstset{language={},basicstyle=\ttfamily\color{codegreen}}\lstinline!#1!}} |
|
46 \makeatother |
|
47 |
|
48 %%\lstset{escapeinside={(*@}{@*)}} |
|
49 \lstset{escapeinside={/*@}{@*/}} |
|
50 |
|
51 %% stripy code |
|
52 \usepackage{lstlinebgrd} |
|
53 \definecolor{capri}{rgb}{0.0, 0.75, 1.0} |
|
54 |
|
55 |
|
56 \lstdefinestyle{mystyle} |
|
57 {basicstyle=\ttfamily, |
|
58 keywordstyle=\color{codepurple}\bfseries, |
|
59 stringstyle=\color{codegreen}, |
|
60 commentstyle=\color{codegreen}, |
|
61 morecomment=[s][\color{codedocblue}]{/**}{*/}, |
|
62 numbers=none, |
|
63 numberstyle=\tiny\color{black}, |
|
64 stepnumber=1, |
|
65 numbersep=10pt, |
|
66 tabsize=2, |
|
67 showspaces=false, |
|
68 showstringspaces=false, |
|
69 xleftmargin=8mm, |
|
70 emphstyle=\color{codeblue}\bfseries, |
|
71 keepspaces, |
|
72 linebackgroundcolor={\ifodd\value{lstnumber}\color{capri!3}\fi} |
|
73 } |
|
74 |
|
75 \lstset{language=Scala, |
|
76 style=mystyle} |