summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/jvlisting/jvlisting.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-07-24 23:41:00 +0000
committerKarl Berry <karl@freefriends.org>2011-07-24 23:41:00 +0000
commit50df8d67f3b81cc8b2fc0650757e6b44cec633ff (patch)
tree1b734e103fe8b7b14c99ad9e3e7429dee046be06 /Master/texmf-dist/tex/latex/jvlisting/jvlisting.sty
parent614632bed2faf4987fda2085965c16e83ed29178 (diff)
new latex package jvlisting (22jul11)
git-svn-id: svn://tug.org/texlive/trunk@23211 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/jvlisting/jvlisting.sty')
-rw-r--r--Master/texmf-dist/tex/latex/jvlisting/jvlisting.sty150
1 files changed, 150 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/jvlisting/jvlisting.sty b/Master/texmf-dist/tex/latex/jvlisting/jvlisting.sty
new file mode 100644
index 00000000000..7794887939a
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/jvlisting/jvlisting.sty
@@ -0,0 +1,150 @@
+%%
+%% This is file `jvlisting.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% jvlisting.dtx (with options: `package')
+%% jvlisting.dtx (with options: `listingdef')
+%%
+%% Copyright (C) 2011 Jochen Voss <voss@seehuhn.de>
+%%
+%% This work may be distributed and/or modified under the conditions of
+%% the LaTeX Project Public License, either version 1.3 of this license
+%% or (at your option) any later version. The latest version of this
+%% license is in
+%%
+%% http://www.latex-project.org/lppl.txt
+%%
+%% and version 1.3 or later is part of all distributions of LaTeX version
+%% 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained' and the current
+%% Maintainer of this work is Jochen Voss <voss@seehuhn.de>.
+%%
+%% This work consists of the files jvlisting.dtx and the derived files
+%% jvlisting.sty, jvlisting.ins and examples.tex.
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{jvlisting}[2011/06/27 v0.1 Formatted Program Listings]
+
+\def\jvl@iterlines#1{\obeylines
+ \expandafter\jvl@iterla\expandafter{#1}{\jvl@dropempty}}
+{\obeylines
+\gdef\jvl@iterla#1#2#3
+ {\def\jvl@testmarker##1#1{}%
+ \expandafter\def\expandafter\w\expandafter{\jvl@testmarker#3#1}%
+ \ifx\w\empty%
+ \def\next{#2#3\jvl@eol\jvl@iterla{#1}{\jvl@countspaces}}%
+ \else%
+ \def\y##1#1##2#1{\jvl@dropempty ##1\jvl@eol\jvl@end##2}%
+ \def\next{\y#3#1}%
+ \fi\next}}
+
+\def\jvl@dropempty{\jvl@dropa{}}
+\def\jvl@dropa#1#2{\ifx\jvl@eol#2%
+ \let\next=\relax
+ \else
+ \if#2 \def\next{\jvl@dropa{#1#2}}\else
+ \def\next{\jvl@countspaces #1#2}\fi
+ \fi\next}
+
+\def\jvl@countspaces{\@tempcnta=0\jvl@counta}
+{\catcode`\^^I=12
+\gdef\jvl@counta#1{\expandafter\if\noexpand#1^^I%
+ \advance\@tempcnta by8\divide\@tempcnta by8\multiply\@tempcnta by8
+ \let\next=\jvl@counta
+ \else
+ \expandafter\if\noexpand#1 %
+ \advance\@tempcnta by1
+ \let\next=\jvl@counta
+ \else
+ \def\next{\jvl@fixspaces #1}
+ \fi
+ \fi\next}}
+
+\newcount\jvl@idt \jvl@idt=-1
+\def\jvl@fixspaces#1{\ifx\jvl@eol#1\else
+ \ifnum\jvl@idt<0
+ \jvl@idt=\@tempcnta
+ \else
+ \ifnum\@tempcnta<\jvl@idt\jvl@idt=\@tempcnta\fi
+ \fi\fi\jvl@fixa#1}
+\def\jvl@fixa{\ifnum\@tempcnta>\jvl@idt
+ \advance\@tempcnta by\m@ne
+ \def\next{\jvl@fixa\space}%
+ \else
+ \let\next\jvl@output
+ \fi\next}
+
+\def\jvl@output#1\jvl@eol{\jvl@typeset{#1}}
+
+\begingroup
+ \catcode`|=0 \catcode`[=1 \catcode`]=2
+ \catcode`\{=12 \catcode`\}=12 \catcode`\\=12
+ |gdef|jvl@makemarker#1[%
+ |expandafter|gdef|csname jvl@@#1marker|endcsname[\end{#1}]]
+|endgroup
+\def\jvl@setup{\begingroup
+ \parskip0pt \advance\leftskip by\@totalleftmargin
+ \let\do\@makeother\dospecials \catcode`\^^I=12}
+\def\NewListingEnvironment#1#2#3#4#5#6{\jvl@makemarker{#1}%
+ \expandafter\newcommand\csname #1\endcsname[#2]{#3\jvl@setup
+ #4\def\jvl@end{\end{#1}}\let\jvl@typeset=#5%
+ \expandafter\jvl@iterlines\csname jvl@@#1marker\endcsname}%
+ \expandafter\gdef\csname end#1\endcsname{\endgroup #6}}
+
+\newread\jvl@fileinput
+\def\jvl@iterfile{\read\jvl@fileinput to\l
+ \ifeof\jvl@fileinput
+ \let\next\relax
+ \else
+ \expandafter\jvl@iterfa\l
+ \let\next\jvl@iterfile
+ \fi\next}
+{\catcode`\^^M=12
+\gdef\jvl@iterfa#1^^M{\jvl@countspaces#1\jvl@eol}}
+\def\NewFileListingCommand#1#2#3#4#5#6{%
+ \ifnum#2<1
+ \PackageError{jvlisting}{%
+ Invalid number of arguments: `#2'
+ }{%
+ The second argument to \protect\NewFileListingCommand\space must be at
+ least 1.
+ }%
+ \fi
+ \newcommand{#1}[#2]{#3\jvl@setup\catcode`\^^M=12
+ #4\let\jvl@typeset=#5%
+ \openin\jvl@fileinput=##1\jvl@iterfile\closein\jvl@fileinput
+ \endgroup #6
+ }
+}
+
+\newskip\listingskipamount \listingskipamount=1ex
+\newdimen\listingindent \listingindent=2em
+\newcount\prelistingpenalty \prelistingpenalty=100
+\newcount\listingpenalty \listingpenalty=500
+\newcount\postlistingpenalty \postlistingpenalty=-50
+
+{\catcode`\ =\active%
+\gdef\jvl@obeyspaces{\frenchspacing\catcode`\ =\active\let \space}}
+{\catcode`\`=\active\gdef`{\relax\lq}}
+\gdef\jvl@noligs{\catcode`\`=\active}
+\def\normallistingfont{\normalfont\ttfamily
+ \jvl@obeyspaces\jvl@noligs\hyphenchar\font-1}
+
+\let\listingfont=\normallistingfont
+\newcommand{\ListingTypesetLine}[1]{\noindent\hskip\listingindent\strut
+ #1\par\penalty\listingpenalty}
+\newcommand{\prelistingskip}{\endgraf\ifdim\lastskip<\listingskipamount
+ \removelastskip\penalty\prelistingpenalty\vskip\listingskipamount\fi}
+\newcommand{\postlistingskip}{\endgraf\penalty\postlistingpenalty
+ \vskip\listingskipamount}
+\NewListingEnvironment{listing}{0}{\prelistingskip}%
+ {\listingfont}{\ListingTypesetLine}{\postlistingskip}
+
+\NewFileListingCommand{\filelisting}{1}{\prelistingskip}%
+ {\listingfont}{\ListingTypesetLine}{\postlistingskip}
+\endinput
+%%
+%% End of file `jvlisting.sty'.