-
Notifications
You must be signed in to change notification settings - Fork 0
/
hgblistings.sty
203 lines (170 loc) · 4.76 KB
/
hgblistings.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
%% File encoding: UTF-8
\ProvidesPackage{hgblistings}
\RequirePackage{ifthen}
%\RequirePackage{upquote} % Setzt "richtige" Quotes in verbatim-Umgebung
%\RequirePackage{textcomp}
\RequirePackage{xcolor}
\definecolor{ListingsBackgroundColor}{gray}{0.95}
%\RequirePackage{listings} % utf8-change
\RequirePackage{listingsutf8} % utf8-change
\lstset{
%language=Java,%
inputencoding=utf8, % utf8-change
extendedchars=true, % utf8-change
basicstyle=\ttfamily\footnotesize,%
keywordstyle=,%\ttfamily,%\bfseries,
identifierstyle=,%\sffamily, %\bfseries
commentstyle=\normalfont\itshape,%
stringstyle=\ttfamily,%
showstringspaces=false,%
columns = flexible,% fixed,
breaklines=true,%
tabsize=2, %
backgroundcolor=\color{ListingsBackgroundColor},
xleftmargin=6mm,%
frame=none,
framexleftmargin=6mm,
numbers=left,%
numbersep=5pt,%
numberstyle=\normalfont\scriptsize,%
stepnumber=1,%
numberfirstline=true,%
numberblanklines=true,%
texcl=false,% %important: read program comments as Latex content
mathescape=false, %no mathescape by default
upquote=true,%
keepspaces=true,%
}
\RequirePackage[utf8]{inputenc}
\lstset{literate=% to allow Umlauts etc. in listed code % utf8-change
{Ö}{{\"O}}1
{Ä}{{\"A}}1
{Ü}{{\"U}}1
{ü}{{\"u}}1
{ä}{{\"a}}1
{ö}{{\"o}}1
{ß}{{\ss}}2
}
% --- Code Environments
% Code Environment for C (ANSI)
\lstnewenvironment{CCode}[1][]
{\lstset{%
language=[ANSI]C,
escapeinside={/+}{+/}, % makes "/+" and "+/" available for Latex escapes (labels etc.)
#1}}%
{}
% Code Environment for C++ (ISO)
\lstnewenvironment{CppCode}[1][]
{\lstset{%
language=[ISO]C++,
escapeinside={/+}{+/}, % makes "/+" and "+/" available for Latex escapes (labels etc.)
#1}}%
{}
% Code Environment for C#
\lstnewenvironment{CsCode}[1][]
{\lstset{%
language=[Sharp]C,
escapeinside={/+}{+/}, % makes "/+" and "+/" available for Latex escapes (labels etc.)
#1}}%
{}
% Language Definition and Code Environment for CSS
\lstdefinelanguage{CSS}
{ morekeywords={color,background,margin,padding,font,weight,display,position,top,%
left,right,bottom,list,style,border,size,white,space,min,width},
sensitive=false,
morecomment=[l]{//},
morecomment=[s]{/*}{*/},
morestring=[b]"
}
\lstnewenvironment{CssCode}[1][]
{\lstset{%
language=CSS,
escapeinside={/+}{+/}, % makes "/+" and "+/" available for Latex escapes (labels etc.)
#1}}%
{}
% Code Enivornmente for Generic Code
\lstnewenvironment{GenericCode}[1][]
{\lstset{%
language={},
keepspaces=true,
commentstyle={},
texcl=false,
escapechar={},
escapeinside={},
#1}}
{}
% Code Enivornmente for HTML
\lstnewenvironment{HtmlCode}[1][]
{\lstset{%
language=HTML,
escapeinside={/+}{+/}, % makes "/+" and "+/" available for Latex escapes (labels etc.)
#1}}%
{}
% Code Enivornmente for Java
\lstnewenvironment{JavaCode}[1][]
{\lstset{%
language=Java,
escapeinside={/+}{+/}, % makes "/+" and "+/" available for Latex escapes (labels etc.)
#1}}%
{}
% Language Definition and Code Environment for JavaScript
\lstdefinelanguage{JavaScript}
{ keywords={attributes, class, classend, do, empty, endif, endwhile, fail, function,%
functionend, if, implements, in, inherit, inout, not, of, operations, out,%
return, set, then, types, while, use},
sensitive=false,
morecomment=[l]{//},
morecomment=[s]{/*}{*/}
}
\lstnewenvironment{JsCode}[1][]
{\lstset{%
language=JavaScript,
escapeinside={/+}{+/}, % makes "/+" and "+/" available for Latex escapes (labels etc.)
#1}}%
{}
% Code Environment for LaTeX
\lstnewenvironment{LaTeXCode}[1][] % code environment for Latex
{\lstset{%
language=[LaTeX]TeX,
escapeinside={/+}{+/}, % makes "/+" and "+/" available for Latex escapes (labels etc.)
#1}}%
{}
% Code Environment for Objective-C
\lstnewenvironment{ObjCCode}[1][]
{\lstset{%
language=[Objective]C,
escapeinside={/+}{+/}, % makes "/+" and "+/" available for Latex escapes (labels etc.)
#1}}%
{}
% Code Environment for PHP
\lstnewenvironment{PhpCode}[1][]
{\lstset{%
language=PHP,
escapeinside={/+}{+/}, % makes "/+" and "+/" available for Latex escapes (labels etc.)
#1}}%
{}
% Language Definition and Code Environment for Swift
\lstdefinelanguage{Swift}
{ keywords=[1]{typealias,true, false,catch,private,internal,public,func,protocol,%
optional,return,nil,catch,switch,let,as,var,if,in,for,while,where,do,else,case,%
break,import,class,struct,enum,override,super,required,designated,convenience},
keywords=[2]{String,Int,Double,Float},
sensitive=true,
morecomment=[l]{//},
morecomment=[s]{/*}{*/},
morestring=[b]',
morestring=[b]"
}
\lstnewenvironment{SwiftCode}[1][]
{\lstset{%
language=Swift,
escapeinside={/+}{+/}, % makes "/+" and "+/" available for Latex escapes (labels etc.)
#1}}%
{}
% Code Environment for XML
\lstnewenvironment{XmlCode}[1][]
{\lstset{%
language=XML,
escapeinside={/+}{+/}, % makes "/+" and "+/" available for Latex escapes (labels etc.)
#1}}%
{}