/[escript]/trunk/doc/user/lstdoc.sty
ViewVC logotype

Contents of /trunk/doc/user/lstdoc.sty

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26