|
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 \lstdefinestyle{mystyle} |
|
43 {basicstyle=\ttfamily, |
|
44 keywordstyle=\color{codepurple}\bfseries, |
|
45 stringstyle=\color{codegreen}, |
|
46 commentstyle=\color{codegreen}, |
|
47 morecomment=[s][\color{codedocblue}]{/**}{*/}, |
|
48 numbers=left, |
|
49 numberstyle=\tiny\color{black}, |
|
50 stepnumber=1, |
|
51 numbersep=10pt, |
|
52 tabsize=2, |
|
53 showspaces=false, |
|
54 showstringspaces=false, |
|
55 xleftmargin=8mm, |
|
56 emphstyle=\color{codeblue}\bfseries, |
|
57 keepspaces |
|
58 } |
|
59 |
|
60 \lstset{language=Scala, |
|
61 style=mystyle} |
|
62 |
|
63 |
|
64 \newcommand{\code}[1]{{\lstinline{#1}}} |
|
65 \newcommand{\pcode}[1]{\mbox{\lstset{language={},keywordstyle=\color{black}}\lstinline!#1!}} |
|
66 \newcommand{\scode}[1]{\mbox{\lstset{language={},basicstyle=\ttfamily\color{codegreen}}\lstinline!#1!}} |
|
67 \makeatother |
|
68 |
|
69 %%\lstset{escapeinside={(*@}{@*)}} |
|
70 \lstset{escapeinside={/*@}{@*/}} |