summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-05-04 23:49:12 +0000
committerKarl Berry <karl@freefriends.org>2012-05-04 23:49:12 +0000
commitbb88380c39955ed093fc8d2edef96bb704b0d467 (patch)
treeb81ecbceb803e02bd16f5039c9dce1eb94d8435a /Master/texmf-dist/tex
parentd931fa83ba0968013396f6a08fa4c6eb3a9c1b94 (diff)
new package lstaddons 0.1 (3may12)
git-svn-id: svn://tug.org/texlive/trunk@26196 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/lstaddons/lstautogobble.sty93
-rw-r--r--Master/texmf-dist/tex/latex/lstaddons/lstlinebgrd.sty71
2 files changed, 164 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/lstaddons/lstautogobble.sty b/Master/texmf-dist/tex/latex/lstaddons/lstautogobble.sty
new file mode 100644
index 00000000000..8f065b4a5c2
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/lstaddons/lstautogobble.sty
@@ -0,0 +1,93 @@
+%% Copyright (C) 2011-2012 by Martin Scharrer <martin@scharrer-online.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'.
+%%
+%% The Current Maintainer of this work is Martin Scharrer.
+%%
+%% This work consists of the files lstautogobble.dtx and lstaddons.ins
+%% and the derived filebase lstautogobble.sty.
+%%
+\ProvidesPackage{lstautogobble}[%
+ 2012/05/03
+ v0.1
+ Implements 'autogobble' option for 'listings']
+
+\RequirePackage{listings}
+
+\newcount\lstag@spacecount
+
+\def\lstag@activespace{\lst@ProcessSpace}% Definition of an active space
+\def\lstag@tabulator{\lst@ProcessTabulator}% Definition of an tabulator
+
+\begingroup
+\catcode`\^^M=\active%
+\gdef\lstag@activenl{^^M}% Active CR (ASCII 13) character which is used as line break
+\endgroup
+
+\lst@Key{autogobble}{false}[t]{\lstKV@SetIf{#1}\lst@ifautogobble}
+
+\lst@Key{ungobble}{0}{\def\lst@ungobble{#1}}
+
+\lst@AddToHook{Init}{\lst@autogobble}
+
+\def\lst@autogobble{%
+ \lst@ifautogobble
+ \ifnum\lst@gobble>0\else
+ \def\lst@gobble{\lstag@gobble}%
+ \def\lstag@gobble{0}%
+ \lstag@spacecount\z@
+ \def\lstag@spaceaccu{}%
+ \let\lstag@restofline\empty
+ \let\lstag@origlstenv@Process\lstenv@Process
+ \let\lstenv@Process\lstag@countleadingspaces
+ \fi
+ \fi
+}
+
+\def\lstag@countleadingspaces#1{%
+ \expandafter\ifx\lstag@activenl#1\relax
+ \expandafter\lstag@countleadingspaces@
+ \else
+ \def\lstag@restofline{Dummy replacement of text after begin of listing to trigger original warning message}%
+ \expandafter\lstag@countleadingspaces
+ \fi
+}
+
+\def\lstag@countleadingspaces@#1{%
+ \ifx\lstag@activespace#1\relax
+ \advance\lstag@spacecount by \@ne
+ % Accumulate spaces (i.e. their definitions) for later re-insertion:
+ \expandafter\def\expandafter\lstag@spaceaccu\expandafter{\lstag@spaceaccu\lst@ProcessSpace}%
+ \let\next\lstag@countleadingspaces@
+ \else% Character wasn't a space
+ \ifx\lstag@tabulator#1\relax
+ \advance\lstag@spacecount by \lst@tabsize\relax
+ % Accumulate spaces (i.e. their definitions) for later re-insertion:
+ \@tempcnta=\lst@tabsize\relax
+ \loop
+ \ifnum\@tempcnta>\z@
+ \expandafter\def\expandafter\lstag@spaceaccu\expandafter{\lstag@spaceaccu\lst@ProcessSpace}%
+ \advance\@tempcnta\m@ne
+ \repeat
+ \let\next\lstag@countleadingspaces@
+ \else% Character wasn't a tabulator either
+ % Set gobble option (indirect):
+ \xdef\lstag@gobble{\the\numexpr\lstag@spacecount-\lst@ungobble\relax}%
+ % Restore original definition of process macro:
+ \global\let\lstenv@Process\lstag@origlstenv@Process
+ % Re-insert all collected material or appropriate replacement material:
+ \edef\next{\noexpand\lstenv@Process\lstag@restofline\expandafter\noexpand\lstag@activenl\expandafter\unexpanded\expandafter{\lstag@spaceaccu}\noexpand#1}%
+ \fi\fi
+ \next
+}
+\endinput
+%%
+%% End of file `lstautogobble.sty'.
diff --git a/Master/texmf-dist/tex/latex/lstaddons/lstlinebgrd.sty b/Master/texmf-dist/tex/latex/lstaddons/lstlinebgrd.sty
new file mode 100644
index 00000000000..66f42ab2c96
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/lstaddons/lstlinebgrd.sty
@@ -0,0 +1,71 @@
+
+
+%% Copyright (C) 2011-2012 by Martin Scharrer <martin@scharrer-online.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'.
+%%
+%% The Current Maintainer of this work is Martin Scharrer.
+%%
+%% This work consists of the files lstlinebgrd.dtx and lstladdons.ins
+%% and the derived filebase lstlinebgrd.sty.
+%%
+\ProvidesPackage{lstlinebgrd}[%
+ 2012/05/03
+ v0.1
+ Provides 'listings' options to color the background of lines]
+\RequirePackage{listings}
+\RequirePackage{xcolor}
+
+\lst@Key{numbers}{none}{%
+ \def\lst@PlaceNumber{\lst@linebgrd}%
+ \lstKV@SwitchCases{#1}%
+ {none&\\%
+ left&\def\lst@PlaceNumber{\llap{\normalfont
+ \lst@numberstyle{\thelstnumber}\kern\lst@numbersep}\lst@linebgrd}\\%
+ right&\def\lst@PlaceNumber{\rlap{\normalfont
+ \kern\linewidth \kern\lst@numbersep
+ \lst@numberstyle{\thelstnumber}}\lst@linebgrd}%
+ }{\PackageError{Listings}{Numbers #1 unknown}\@ehc}}
+
+\lst@Key{linebackgroundcolor}{}{%
+ \def\lst@linebgrdcolor{#1}%
+}
+\lst@Key{linebackgroundsep}{0pt}{%
+ \def\lst@linebgrdsep{#1}%
+}
+\lst@Key{linebackgroundwidth}{\linewidth}{%
+ \def\lst@linebgrdwidth{#1}%
+}
+\lst@Key{linebackgroundheight}{\ht\strutbox}{%
+ \def\lst@linebgrdheight{#1}%
+}
+\lst@Key{linebackgrounddepth}{\dp\strutbox}{%
+ \def\lst@linebgrddepth{#1}%
+}
+\lst@Key{linebackgroundcmd}{\color@block}{%
+ \def\lst@linebgrdcmd{#1}%
+}
+
+\newcommand{\lst@linebgrd}{%
+ \ifx\lst@linebgrdcolor\empty\else
+ \rlap{%
+ \lst@basicstyle
+ \color{-.}% By default use the opposite (`-`) of the current color (`.`) as background
+ \lst@linebgrdcolor{%
+ \kern-\dimexpr\lst@linebgrdsep\relax%
+ \lst@linebgrdcmd{\lst@linebgrdwidth}{\lst@linebgrdheight}{\lst@linebgrddepth}%
+ }%
+ }%
+ \fi
+}
+\endinput
+%%
+%% End of file `lstlinebgrd.sty'.