ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mattDisertation/lstdoc.sty
Revision: 1092
Committed: Tue Mar 16 21:35:16 2004 UTC (20 years, 3 months ago) by mmeineke
File size: 15738 byte(s)
Log Message:
added lst styles, and some preliminary fixes to the intro.

File Contents

# Content
1 %%
2 %% This is file `lstdoc.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% listings.dtx (with options: `doc')
8 %%
9 %% Please read the software license in listings.dtx or listings.pdf.
10 %%
11 %% (w)(c) 1996 -- 2003 Carsten Heinz and/or any other author
12 %% listed elsewhere in this file.
13 %%
14 %% This file is distributed under the terms of the LaTeX Project Public
15 %% License from CTAN archives in directory macros/latex/base/lppl.txt.
16 %% Either version 1.0 or, at your option, any later version.
17 %%
18 %% Permission is granted to modify this file. If your changes are of
19 %% general interest, please contact the address below.
20 %%
21 %% Send comments and ideas on the package, error reports and additional
22 %% programming languages to <cheinz@gmx.de>.
23 %%
24 \def\filedate{2003/06/21}
25 \def\fileversion{1.1}
26 \ProvidesPackage{lstdoc}
27 [\filedate\space\fileversion\space(Carsten Heinz)]
28 \let\lstdoc@currversion\fileversion
29 \RequirePackage[writefile]{listings}[2002/04/01]
30 \newif\iffancyvrb \IfFileExists{fancyvrb.sty}{\fancyvrbtrue}{}
31 \newif\ifcolor \IfFileExists{color.sty}{\colortrue}{}
32 \newif\ifhyper \@ifundefined{pdfoutput}{}
33 {\IfFileExists{hyperref.sty}{\hypertrue}{}}
34 \newif\ifalgorithmic \IfFileExists{algorithmic.sty}{\algorithmictrue}{}
35 \newif\iflgrind \IfFileExists{lgrind.sty}{\lgrindtrue}{}
36 \iffancyvrb \RequirePackage{fancyvrb}\fi
37 \ifhyper \RequirePackage[colorlinks]{hyperref}\else
38 \def\href#1{\texttt}\fi
39 \ifcolor \RequirePackage{color}\fi
40 \ifalgorithmic \RequirePackage{algorithmic}\fi
41 \iflgrind \RequirePackage{lgrind}\fi
42 \RequirePackage{nameref}
43 \renewcommand\ref{\protect\T@ref}
44 \renewcommand\pageref{\protect\T@pageref}
45 \def\lst@BeginRemark#1{%
46 \begin{quote}\topsep0pt\let\small\footnotesize\small#1:}
47 \def\lst@EndRemark{\end{quote}}
48 \newenvironment{TODO}
49 {\lst@BeginRemark{To do}}{\lst@EndRemark}
50 \newenvironment{ALTERNATIVE}
51 {\lst@BeginRemark{Alternative}}{\lst@EndRemark}
52 \newenvironment{REMOVED}
53 {\lst@BeginRemark{Removed}}{\lst@EndRemark}
54 \newenvironment{OLDDEF}
55 {\lst@BeginRemark{Old definition}}{\lst@EndRemark}
56 \def\advise{\par\list\labeladvise
57 {\advance\linewidth\@totalleftmargin
58 \@totalleftmargin\z@
59 \@listi
60 \let\small\footnotesize \small\sffamily
61 \parsep \z@ \@plus\z@ \@minus\z@
62 \topsep6\p@ \@plus1\p@\@minus2\p@
63 \def\makelabel##1{\hss\llap{##1}}}}
64 \let\endadvise\endlist
65 \def\advisespace{\hbox{}\qquad}
66 \def\labeladvise{$\to$}
67 \newenvironment{syntax}
68 {\list{}{\itemindent-\leftmargin
69 \def\makelabel##1{\hss\lst@syntaxlabel##1,,,,\relax}}}
70 {\endlist}
71 \def\lst@syntaxlabel#1,#2,#3,#4\relax{%
72 \llap{\scriptsize\itshape#3}%
73 \def\lst@temp{#2}%
74 \expandafter\lst@syntaxlabel@\meaning\lst@temp\relax
75 \rlap{\hskip-\itemindent\hskip\itemsep\hskip\linewidth
76 \llap{\ttfamily\lst@temp}\hskip\labelwidth
77 \def\lst@temp{#1}%
78 \ifx\lst@temp\lstdoc@currversion#1\fi}}
79 \def\lst@syntaxlabel@#1>#2\relax
80 {\edef\lst@temp{\zap@space#2 \@empty}}
81 \newcommand*\syntaxnewline{\newline\hbox{}\kern\labelwidth}
82 \newcommand*\syntaxor{\qquad or\qquad}
83 \newcommand*\syntaxbreak
84 {\hfill\kern0pt\discretionary{}{\kern\labelwidth}{}}
85 \let\syntaxfill\hfill
86 \def\alternative#1{\lst@true \alternative@#1,\relax,}
87 \def\alternative@#1,{%
88 \ifx\relax#1\@empty
89 \expandafter\@gobble
90 \else
91 \ifx\@empty#1\@empty\else
92 \lst@if \lst@false \else $\vert$\fi
93 \textup{\texttt{#1}}%
94 \fi
95 \fi
96 \alternative@}
97 \long\def\m@cro@#1#2#3{\endgroup \topsep\MacroTopsep \trivlist
98 \edef\saved@macroname{\string#3}%
99 \def\makelabel##1{\llap{##1}}%
100 \if@inlabel
101 \let\@tempa\@empty \count@\macro@cnt
102 \loop \ifnum\count@>\z@
103 \edef\@tempa{\@tempa\hbox{\strut}}\advance\count@\m@ne \repeat
104 \edef\makelabel##1{\llap{\vtop to\baselineskip
105 {\@tempa\hbox{##1}\vss}}}%
106 \advance \macro@cnt \@ne
107 \else \macro@cnt\@ne \fi
108 \edef\@tempa{\noexpand\item[%
109 #1%
110 \noexpand\PrintMacroName
111 \else
112 \expandafter\noexpand\csname Print#2Name\endcsname % MODIFIED
113 \fi
114 {\string#3}]}%
115 \@tempa
116 \global\advance\c@CodelineNo\@ne
117 #1%
118 \SpecialMainIndex{#3}\nobreak
119 \DoNotIndex{#3}%
120 \else
121 \csname SpecialMain#2Index\endcsname{#3}\nobreak % MODIFIED
122 \fi
123 \global\advance\c@CodelineNo\m@ne
124 \ignorespaces}
125 \def\macro{\begingroup
126 \catcode`\\12
127 \MakePrivateLetters \m@cro@ \iftrue {Macro}}% MODIFIED
128 \def\environment{\begingroup
129 \catcode`\\12
130 \MakePrivateLetters \m@cro@ \iffalse {Env}}% MODIFIED
131 \def\newdocenvironment#1#2#3#4{%
132 \@namedef{#1}{#3\begingroup \catcode`\\12\relax
133 \MakePrivateLetters \m@cro@ \iffalse {#2}}%
134 \@namedef{end#1}{#4\endmacro}%
135 \@ifundefined{Print#2Name}{\expandafter
136 \let\csname Print#2Name\endcsname\PrintMacroName}{}%
137 \@ifundefined{SpecialMain#2Index}{\expandafter
138 \let\csname SpecialMain#2Index\endcsname\SpecialMainIndex}{}}
139 \newdocenvironment{aspect}{Aspect}{}{}
140 \def\PrintAspectName#1{}
141 \def\SpecialMainAspectIndex#1{%
142 \@bsphack
143 \index{aspects:\levelchar\protect\aspectname{#1}\encapchar main}%
144 \@esphack}
145 \newdocenvironment{lstkey}{Key}{}{}
146 \def\PrintKeyName#1{\strut\keyname{#1}\ }
147 \def\SpecialMainKeyIndex#1{%
148 \@bsphack
149 \index{keys\levelchar\protect\keyname{#1}\encapchar main}%
150 \@esphack}
151 \newcounter{argcount}
152 \def\labelargcount{\texttt{\#\arabic{argcount}}\hskip\labelsep$=$}
153 \def\macroargs{\list\labelargcount
154 {\usecounter{argcount}\leftmargin=2\leftmargin
155 \parsep \z@ \@plus\z@ \@minus\z@
156 \topsep4\p@ \@plus\p@ \@minus2\p@
157 \itemsep\z@ \@plus\z@ \@minus\z@
158 \def\makelabel##1{\hss\llap{##1}}}}
159 \def\endmacroargs{\endlist\@endparenv}
160 \lst@RequireAspects{writefile}
161 \newbox\lst@samplebox
162 \lstnewenvironment{lstsample}[3][]
163 {\global\let\lst@intname\@empty
164 \gdef\lst@sample{#2}%
165 \setbox\lst@samplebox=\hbox\bgroup
166 \setkeys{lst}{language={},style={},tabsize=4,gobble=5,%
167 basicstyle=\small\ttfamily,basewidth=0.51em,point={#1}}
168 #3%
169 \lst@BeginAlsoWriteFile{\jobname.tmp}}
170 {\lst@EndWriteFile\egroup
171 \ifdim \wd\lst@samplebox>.5\linewidth
172 \begin{center}%
173 \hbox to\linewidth{\box\lst@samplebox\hss}%
174 \end{center}%
175 \lst@sampleInput
176 \else
177 \begin{center}%
178 \begin{minipage}{0.45\linewidth}\lst@sampleInput\end{minipage}%
179 \qquad
180 \begin{minipage}{0.45\linewidth}%
181 \hbox to\linewidth{\box\lst@samplebox\hss}%
182 \end{minipage}%
183 \end{center}%
184 \fi}
185 \lst@InstallKeywords{p}{point}{pointstyle}\relax{keywordstyle}{}ld
186 \lstnewenvironment{lstxsample}[1][]
187 {\begingroup
188 \setkeys{lst}{belowskip=-\medskipamount,language={},style={},%
189 tabsize=4,gobble=5,basicstyle=\small\ttfamily,%
190 basewidth=0.51em,point={#1}}
191 \lst@BeginAlsoWriteFile{\jobname.tmp}}
192 {\endgroup
193 \endgroup}
194 \def\lst@sampleInput{%
195 \MakePercentComment\catcode`\^^M=10\relax
196 \small\lst@sample
197 {\setkeys{lst}{SelectCharTable=\lst@ReplaceInput{\^\^I}%
198 {\lst@ProcessTabulator}}%
199 \leavevmode \input{\jobname.tmp}}\MakePercentIgnore}
200 \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
201 {1.25ex \@plus1ex \@minus.2ex}%
202 {-1em}%
203 {\normalfont\normalsize\bfseries}}
204 \def\lstref#1{\emph{\ref{#1} \nameref{#1}}}
205 \def\@part[#1]#2{\addcontentsline{toc}{part}{#1}%
206 {\parindent\z@ \raggedright \interlinepenalty\@M
207 \normalfont \huge \bfseries #2\markboth{}{}\par}%
208 \nobreak\vskip 3ex\@afterheading}
209 \renewcommand*\l@section[2]{%
210 \addpenalty\@secpenalty
211 \addvspace{.25em \@plus\p@}%
212 \setlength\@tempdima{1.5em}%
213 \begingroup
214 \parindent \z@ \rightskip \@pnumwidth
215 \parfillskip -\@pnumwidth
216 \leavevmode
217 \advance\leftskip\@tempdima
218 \hskip -\leftskip
219 #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
220 \endgroup}
221 \renewcommand*\l@subsection{\@dottedtocline{2}{0pt}{2.3em}}
222 \renewcommand*\l@subsubsection{\@dottedtocline{3}{0pt}{3.2em}}
223 \newcommand\ikeyname[1]{%
224 \lstkeyindex{#1}{}%
225 \lstaspectindex{#1}{}%
226 \keyname{#1}}
227 \newcommand\ekeyname[1]{%
228 \@bsphack
229 \lstkeyindex{#1}{\encapchar usage}%
230 \lstaspectindex{#1}{\encapchar usage}%
231 \@esphack}
232 \newcommand\rkeyname[1]{%
233 \@bsphack
234 \lstkeyindex{#1}{\encapchar main}%
235 \lstaspectindex{#1}{\encapchar main}%
236 \@esphack{\rstyle\keyname{#1}}}
237 \newcommand\icmdname[1]{%
238 \@bsphack
239 \lstaspectindex{#1}{}%
240 \@esphack\texttt{\string#1}}
241 \newcommand\rcmdname[1]{%
242 \@bsphack
243 \lstaspectindex{#1}{\encapchar main}%
244 \@esphack\texttt{\rstyle\string#1}}
245 \def\lstaspectindex#1#2{%
246 \global\@namedef{lstkandc@\string#1}{}%
247 \@ifundefined{lstisaspect@\string#1}
248 {\index{unknown\levelchar
249 \protect\texttt{\protect\string\string#1}#2}}%
250 {\index{\@nameuse{lstisaspect@\string#1}\levelchar
251 \protect\texttt{\protect\string\string#1}#2}}%
252 }
253 \def\lstkeyindex#1#2{%
254 }
255 \def\lstisaspect[#1]#2{%
256 \global\@namedef{lstaspect@#1}{#2}%
257 \lst@AddTo\lst@allkeysandcmds{,#2}%
258 \@for\lst@temp:=#2\do
259 {\ifx\@empty\lst@temp\else
260 \global\@namedef{lstisaspect@\lst@temp}{#1}%
261 \fi}}
262 \gdef\lst@allkeysandcmds{}
263 \def\lstprintaspectkeysandcmds#1{%
264 \lst@true
265 \expandafter\@for\expandafter\lst@temp
266 \expandafter:\expandafter=\csname lstaspect@#1\endcsname\do
267 {\lst@if\lst@false\else, \fi \texttt{\lst@temp}}}
268 \def\lstcheckreference{%
269 \@for\lst@temp:=\lst@allkeysandcmds\do
270 {\ifx\lst@temp\@empty\else
271 \@ifundefined{lstkandc@\lst@temp}
272 {\typeout{\lst@temp\space not in reference guide?}}{}%
273 \fi}}
274 \newcommand*\lst{\texttt{lst}}
275 \newcommand*\Cpp{C\texttt{++}}
276 \let\keyname\texttt
277 \let\keyvalue\texttt
278 \let\hookname\texttt
279 \newcommand*\aspectname[1]{{\normalfont\sffamily#1}}
280 \DeclareRobustCommand\packagename[1]{%
281 {\leavevmode\text@command{#1}%
282 \switchfontfamily\sfdefault\rmdefault
283 \check@icl #1\check@icr
284 \expandafter}}%
285 \renewcommand\packagename[1]{{\normalfont\sffamily#1}}
286 \def\switchfontfamily#1#2{%
287 \begingroup\xdef\@gtempa{#1}\endgroup
288 \ifx\f@family\@gtempa\fontfamily#2%
289 \else\fontfamily#1\fi
290 \selectfont}
291 \ifcolor
292 \definecolor{darkgreen}{rgb}{0,0.5,0}
293 \def\rstyle{\color{darkgreen}}
294 \else
295 \let\rstyle\empty
296 \fi
297 \gdef\lst@emails{}
298 \newcommand*\lstthanks[2]
299 {#1\lst@AddTo\lst@emails{,#1,<#2>}%
300 \ifx\@empty#2\@empty\typeout{Missing email for #1}\fi}
301 \newcommand*\lsthelper[3]
302 {{\let~\ #1}%
303 \lst@IfOneOf#1\relax\lst@emails
304 {}{\typeout{^^JWarning: Unknown helper #1.^^J}}}
305 \lstdefinelanguage[doc]{Pascal}{%
306 morekeywords={alfa,and,array,begin,boolean,byte,case,char,const,div,%
307 do,downto,else,end,false,file,for,function,get,goto,if,in,%
308 integer,label,maxint,mod,new,not,of,or,pack,packed,page,program,%
309 procedure,put,read,readln,real,record,repeat,reset,rewrite,set,%
310 text,then,to,true,type,unpack,until,var,while,with,write,writeln},%
311 sensitive=false,%
312 morecomment=[s]{(*}{*)},%
313 morecomment=[s]{\{}{\}},%
314 morestring=[d]{'}}
315 \lstdefinestyle{}
316 {basicstyle={},%
317 keywordstyle=\bfseries,identifierstyle={},%
318 commentstyle=\itshape,stringstyle={},%
319 numberstyle={},stepnumber=1,%
320 pointstyle=\pointstyle}
321 \def\pointstyle{%
322 {\let\lst@um\@empty \xdef\@gtempa{\the\lst@token}}%
323 \expandafter\lstkeyindex\expandafter{\@gtempa}{}%
324 \expandafter\lstaspectindex\expandafter{\@gtempa}{}%
325 \rstyle}
326 \lstset{defaultdialect=[doc]Pascal,language=Pascal,style={}}
327 \def\lstscanlanguages#1#2#3{%
328 \begingroup
329 \def\lst@DefDriver@##1##2##3##4[##5]##6{%
330 \lst@false
331 \lst@lAddTo\lst@scan{##6(##5),}%
332 \begingroup
333 \@ifnextchar[{\lst@XDefDriver{##1}##3}{\lst@DefDriver@@##3}}%
334 \def\lst@XXDefDriver[##1]{}%
335 \lst@InputCatcodes
336 \def\lst@dontinput{#3}%
337 \let\lst@scan\@empty
338 \lst@for{#2}\do{%
339 \lst@IfOneOf##1\relax\lst@dontinput
340 {}%
341 {\InputIfFileExists{##1}{}{}}}%
342 \global\let\@gtempa\lst@scan
343 \endgroup
344 \let#1\@gtempa}
345 \def\lstprintlanguages#1{%
346 \def\do##1{\setbox\@tempboxa\hbox{##1\space\space}%
347 \ifdim\wd\@tempboxa<.5\linewidth \wd\@tempboxa.5\linewidth
348 \else \wd\@tempboxa\linewidth \fi
349 \box\@tempboxa\allowbreak}%
350 \begin{quote}
351 \par\noindent
352 \hyphenpenalty=\@M \rightskip=\z@\@plus\linewidth\relax
353 \lst@BubbleSort#1%
354 \expandafter\lst@NextLanguage#1\relax(\relax),%
355 \end{quote}}
356 \def\lst@NextLanguage#1(#2),{%
357 \ifx\relax#1\else
358 \def\lst@language{#1}\def\lst@dialects{(#2),}%
359 \expandafter\lst@NextLanguage@
360 \fi}
361 \def\lst@NextLanguage@#1(#2),{%
362 \def\lst@temp{#1}%
363 \ifx\lst@temp\lst@language
364 \lst@lAddTo\lst@dialects{(#2),}%
365 \expandafter\lst@NextLanguage@
366 \else
367 \do{\lst@language
368 \ifx\lst@dialects\lst@emptydialect\else
369 \expandafter\lst@NormedDef\expandafter\lst@language
370 \expandafter{\lst@language}%
371 \space(%
372 \lst@BubbleSort\lst@dialects
373 \expandafter\lst@PrintDialects\lst@dialects(\relax),%
374 )%
375 \fi}%
376 \def\lst@next{\lst@NextLanguage#1(#2),}%
377 \expandafter\lst@next
378 \fi}
379 \def\lst@emptydialect{(),}
380 \def\lst@PrintDialects(#1),{%
381 \ifx\@empty#1\@empty empty\else
382 \lst@PrintDialect{#1}%
383 \fi
384 \lst@PrintDialects@}
385 \def\lst@PrintDialects@(#1),{%
386 \ifx\relax#1\else
387 , \lst@PrintDialect{#1}%
388 \expandafter\lst@PrintDialects@
389 \fi}
390 \def\lst@PrintDialect#1{%
391 \lst@NormedDef\lst@temp{#1}%
392 \expandafter\ifx\csname\@lst dd@\lst@language\endcsname\lst@temp
393 \texttt{\underbar{#1}}%
394 \else
395 \texttt{#1}%
396 \fi}
397 \def\lst@IfLE#1#2\@empty#3#4\@empty{%
398 \ifx #1\relax
399 \let\lst@next\@firstoftwo
400 \else \ifx #3\relax
401 \let\lst@next\@secondoftwo
402 \else
403 \lowercase{\ifx#1#3}%
404 \def\lst@next{\lst@IfLE#2\@empty#4\@empty}%
405 \else
406 \lowercase{\ifnum`#1<`#3}\relax
407 \let\lst@next\@firstoftwo
408 \else
409 \let\lst@next\@secondoftwo
410 \fi
411 \fi
412 \fi \fi
413 \lst@next}
414 \def\lst@BubbleSort#1{%
415 \ifx\@empty#1\else
416 \lst@false
417 \expandafter\lst@BubbleSort@#1\relax,\relax,%
418 \expandafter\lst@BubbleSort@\expandafter,\lst@sorted
419 \relax,\relax,%
420 \let#1\lst@sorted
421 \lst@if
422 \def\lst@next{\lst@BubbleSort#1}%
423 \expandafter\expandafter\expandafter\lst@next
424 \fi
425 \fi}
426 \def\lst@BubbleSort@#1,#2,{%
427 \ifx\@empty#1\@empty
428 \def\lst@sorted{#2,}%
429 \def\lst@next{\lst@BubbleSort@@}%
430 \else
431 \let\lst@sorted\@empty
432 \def\lst@next{\lst@BubbleSort@@#1,#2,}%
433 \fi
434 \lst@next}
435 \def\lst@BubbleSort@@#1,#2,{%
436 \ifx\relax#1\else
437 \ifx\relax#2%
438 \lst@lAddTo\lst@sorted{#1,}%
439 \expandafter\expandafter\expandafter\lst@BubbleSort@@@
440 \else
441 \lst@IfLE #1\relax\@empty #2\relax\@empty
442 {\lst@lAddTo\lst@sorted{#1,#2,}}%
443 {\lst@true \lst@lAddTo\lst@sorted{#2,#1,}}%
444 \expandafter\expandafter\expandafter\lst@BubbleSort@@
445 \fi
446 \fi}
447 \def\lst@BubbleSort@@@#1\relax,{}
448 \endinput
449 %%
450 %% End of file `lstdoc.sty'.