langs.sty
changeset 234 bf7eecc9cefe
parent 230 0fd668d7b619
child 235 bc460179148c
equal deleted inserted replaced
233:acddd4808117 234:bf7eecc9cefe
     1 \usepackage{listings}
     1 \usepackage{listings}
     2 \usepackage{xcolor}
     2 \setmonofont[Scale=.95]{Consolas}
     3 \usepackage{fontspec}
       
     4 \setmonofont[Scale=.88]{Consolas}
       
     5 \newfontfamily{\consolas}{Consolas}
     3 \newfontfamily{\consolas}{Consolas}
     6 
     4 
     7 \definecolor{javared}{rgb}{0.6,0,0} % for strings
     5 \definecolor{codered}{rgb}{0.6,0,0}            % for strings
     8 \definecolor{javagreen}{rgb}{0.25,0.5,0.35} % comments
     6 \definecolor{codegreen}{rgb}{0.25,0.5,0.35}    % comments
     9 \definecolor{javapurple}{rgb}{0.5,0,0.35} % keywords
     7 \definecolor{codepurple}{rgb}{0.5,0,0.35}      % keywords
    10 \definecolor{javadocblue}{rgb}{0.25,0.35,0.75} % javadoc
     8 \definecolor{codedocblue}{rgb}{0.25,0.35,0.75} % doc
       
     9 \definecolor{codeblue}{rgb}{0.25,0.35,0.75}    % types
    11 
    10 
    12 \lstset{language=Java,
    11 
    13 	basicstyle=\ttfamily,
    12 
    14 	keywordstyle=\color{javapurple}\bfseries,
    13 \lstdefinelanguage{Scala}{
    15 	stringstyle=\color{javagreen},
    14   keywords={abstract,case,catch,class,def,%
    16 	commentstyle=\color{javagreen},
    15     do,else,extends,false,final,finally,%
    17 	morecomment=[s][\color{javadocblue}]{/**}{*/},
    16     for,if,implicit,import,match,mixin,%
       
    17     new,null,object,override,package,%
       
    18     private,protected,requires,return,sealed,%
       
    19     super,this,throw,trait,true,try,%
       
    20     type,val,var,while,with,yield},%
       
    21   otherkeywords={=>,<-,<\%,<:,>:,\#,@},%
       
    22   sensitive=true,%
       
    23   directives={Int,Char,Rexp,String,Boolean,BigInt,Unit,List,Set},%
       
    24   moredelim=*[directive]:,%
       
    25   morecomment=[l]{//},%
       
    26   morecomment=[n]{/*}{*/},
       
    27   morestring=[b]",
       
    28   morestring=[b]',
       
    29   morestring=[b]"""
       
    30 }[keywords,directives,comments,strings]
       
    31 
       
    32 \lstdefinelanguage{While}{
       
    33   morekeywords={if,then,else,while,do,true,false,write,upto,for,skip},
       
    34   otherkeywords={=,!=,:=,<,>,;},
       
    35   sensitive=true,
       
    36   morecomment=[n]{/*}{*/},
       
    37 }
       
    38 
       
    39 \lstdefinestyle{mystyle}
       
    40        {basicstyle=\ttfamily,
       
    41 	keywordstyle=\color{codepurple}\bfseries,
       
    42         directivestyle=\color{codeblue}\bfseries,
       
    43 	stringstyle=\color{codegreen},
       
    44 	commentstyle=\color{codegreen},
       
    45 	morecomment=[s][\color{codedocblue}]{/**}{*/},
    18 	numbers=left,
    46 	numbers=left,
    19 	numberstyle=\tiny\color{black},
    47 	numberstyle=\tiny\color{black},
    20 	stepnumber=1,
    48 	stepnumber=1,
    21 	numbersep=10pt,
    49 	numbersep=10pt,
    22 	tabsize=2,
    50 	tabsize=2,
    23 	showspaces=false,
    51 	showspaces=false,
    24 	showstringspaces=false}
    52 	showstringspaces=false,
       
    53         xleftmargin=8mm,
       
    54         emphstyle=\color{codeblue}\bfseries}
    25 
    55 
    26 \lstdefinelanguage{scala}{
    56 \lstset{language=Scala,
    27   morekeywords={abstract,case,catch,class,def,%
    57         style=mystyle}
    28     do,else,extends,false,final,finally,%
       
    29     for,if,implicit,import,match,mixin,%
       
    30     new,null,object,override,package,%
       
    31     private,protected,requires,return,sealed,%
       
    32     super,this,throw,trait,true,try,%
       
    33     type,val,var,while,with,yield},
       
    34   otherkeywords={=>,<-,<\%,<:,>:,\#,@},
       
    35   sensitive=true,
       
    36   morecomment=[l]{//},
       
    37   morecomment=[n]{/*}{*/},
       
    38   morestring=[b]",
       
    39   morestring=[b]',
       
    40   morestring=[b]"""
       
    41 }
       
    42 
    58 
    43 
    59 
    44 \lstset{language=Scala,
    60 \newcommand{\code}[1]{{\lstinline!#1!}}
    45 	basicstyle=\ttfamily,
       
    46 	keywordstyle=\color{javapurple}\bfseries,
       
    47 	stringstyle=\color{javagreen},
       
    48 	commentstyle=\color{javagreen},
       
    49 	morecomment=[s][\color{javadocblue}]{/**}{*/},
       
    50 	numbers=left,
       
    51 	numberstyle=\tiny\color{black},
       
    52 	stepnumber=1,
       
    53 	numbersep=10pt,
       
    54 	tabsize=2,
       
    55 	showspaces=false,
       
    56 	showstringspaces=false}
       
    57 
       
    58 \lstdefinelanguage{while}{
       
    59   morekeywords={if,then,else,while,do,true,false,write,upto,for,skip},
       
    60   otherkeywords={=,!=,:=,<,>,;},
       
    61   sensitive=true,
       
    62   morecomment=[n]{/*}{*/},
       
    63 }
       
    64 
       
    65 
       
    66 \lstset{language=While,
       
    67 	basicstyle=\ttfamily,
       
    68 	keywordstyle=\color{javapurple}\bfseries,
       
    69 	stringstyle=\color{javagreen},
       
    70 	commentstyle=\color{javagreen},
       
    71 	morecomment=[s][\color{javadocblue}]{/**}{*/},
       
    72 	numbers=left,
       
    73 	numberstyle=\tiny\color{black},
       
    74 	stepnumber=1,
       
    75 	numbersep=10pt,
       
    76 	tabsize=2,
       
    77 	showspaces=false,
       
    78 	showstringspaces=false}