From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/lstaddons/README | 50 ++++ macros/latex/contrib/lstaddons/lstaddons.ins | 11 + macros/latex/contrib/lstaddons/lstautogobble.dtx | 329 +++++++++++++++++++++++ macros/latex/contrib/lstaddons/lstautogobble.pdf | Bin 0 -> 183234 bytes macros/latex/contrib/lstaddons/lstlinebgrd.dtx | 289 ++++++++++++++++++++ macros/latex/contrib/lstaddons/lstlinebgrd.pdf | Bin 0 -> 213449 bytes 6 files changed, 679 insertions(+) create mode 100644 macros/latex/contrib/lstaddons/README create mode 100644 macros/latex/contrib/lstaddons/lstaddons.ins create mode 100644 macros/latex/contrib/lstaddons/lstautogobble.dtx create mode 100644 macros/latex/contrib/lstaddons/lstautogobble.pdf create mode 100644 macros/latex/contrib/lstaddons/lstlinebgrd.dtx create mode 100644 macros/latex/contrib/lstaddons/lstlinebgrd.pdf (limited to 'macros/latex/contrib/lstaddons') diff --git a/macros/latex/contrib/lstaddons/README b/macros/latex/contrib/lstaddons/README new file mode 100644 index 0000000000..7306f47deb --- /dev/null +++ b/macros/latex/contrib/lstaddons/README @@ -0,0 +1,50 @@ +LaTeX bundle 'lstaddons' +~~~~~~~~~~~~~~~~~~~~~~~~ +Copyright (c) 2011-2012 by Martin Scharrer +CTAN: http://www.ctan.org/pkg/lstaddons +Code repository: https://bitbucket.org/martin_scharrer/lstaddons + +This bundle contains a small collections of add-on packages for +the 'listings' package. +These packages patch internal macros to provide additional features +to 'listings'. + +The add-ons are so far: + + +lstlinebgrd +~~~~~~~~~~~ +Provides 'linebackground' options for 'lstlisting' which +can be used to color the background of each line of the listing. +The use of conditionals which depend on the line number is supported, +which allows zebra-effects etc. + +This package was originally written in response to the question +"Creating a zebra effect using listings" +(http://tex.stackexchange.com/q/18969/2975). + + +lstautogobble +~~~~~~~~~~~~~ +Provides an 'autogobble=true|false' option for 'listing' which will set the +standard 'gobble' option to the indention of the first line. This allows +people to indent their listings code in the source file without having to +use a suitable value for 'gobble' themselves. + +This package was originally written in response to the question +"How to automatically skip leading white spaces in listings" +(http://tex.stackexchange.com/q/19953/2975) + + +INSTALLATION +============ +Run 'tex lstaddons.ins' to extract all package files. +Compile all .dtx files with pdflatex to produce the package manuals. +Copy the files to the following subdirectories of your TEXMF tree: + + *.sty => tex/latex/lstaddons/ + *.dtx *.ins => source/latex/lstaddons/ + *.pdf README => doc/latex/lstaddons/ + +Finally update your TeX file list by running 'texhash' or similar tool. + diff --git a/macros/latex/contrib/lstaddons/lstaddons.ins b/macros/latex/contrib/lstaddons/lstaddons.ins new file mode 100644 index 0000000000..89d32859f9 --- /dev/null +++ b/macros/latex/contrib/lstaddons/lstaddons.ins @@ -0,0 +1,11 @@ +\input ydocstrip.tex +\keepsilent +\askforoverwritefalse + +\generate{% + \file{lstlinebgrd.sty}{\nopreamble\from{lstlinebgrd.dtx}{lstlinebgrd.sty}}% + \file{lstautogobble.sty}{\nopreamble\from{lstautogobble.dtx}{lstautogobble.sty}}% +} +\endbatchfile + +%% vim: ft=tex diff --git a/macros/latex/contrib/lstaddons/lstautogobble.dtx b/macros/latex/contrib/lstaddons/lstautogobble.dtx new file mode 100644 index 0000000000..f9d62cf8d3 --- /dev/null +++ b/macros/latex/contrib/lstaddons/lstautogobble.dtx @@ -0,0 +1,329 @@ +% \iffalse meta-comment +%<=*COPYRIGHT> +%% Copyright (C) 2011-2012 by Martin Scharrer +%% ----------------------------------------------------------------------- +%% 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. +%% +%<=/COPYRIGHT> +% \fi +% +% \iffalse +%<*driver> +\ProvidesFile{lstautogobble.dtx}[% +%<=*DATE> + 2012/05/03 +%<=/DATE> +%<=*VERSION> + v0.1 +%<=/VERSION> + DTX file for 'lstautogobble'] +\documentclass{ydoc} +\GetFileInfo{lstautogobble.dtx} +\usepackage{lstautogobble}[\filedate] +\EnableCrossrefs +\CodelineIndex +\RecordChanges +\begin{document} + \DocInput{\jobname.dtx} + \PrintChanges + \PrintIndex +\end{document} +% +% \fi +% +% \CheckSum{0} +% +% \CharacterTable +% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} +% +% +% \changes{v0.1}{2012/05/03}{Initial release.} +% +% \DoNotIndex{\newcommand,\newenvironment} +% +% \GetFileInfo{lstautogobble.dtx} +% \author{Martin Scharrer} +% \email{martin@scharrer-online.de} +% \ifdefined\repository +% \repository{https://bitbucket.org/martin_scharrer/lstautogobble} +% \fi +% +% \maketitle +% +% \begin{abstract}\noindent +% This add-on package to \pkg{listings} provides a boolean \Key{autogobble} +% setting which will automatically set the \Key{gobble} setting to indention +% of the first line. +% +% This package was created as response to the question +% \href{http://tex.stackexchange.com/q/19953/2975}{``How to automatically skip leading white spaces in listings?''} +% on \href{http://tex.stackexchange.com/}{\TeX\ Stack Exchange}. +% \end{abstract} +% +% \section{Introduction} +% The \pkg{listings} package has a setting \Key{gobble}'=' which allows to remove a certain number +% of characters from the beginning of every line in the listing. This can be used to indent the listing +% in the source code without affecting the printed result. However, this forces the user to set a suitable +% value manually. An incorrect value will lead either to an indented listing or to missing leading characters. +% +% A solution for this is to automatically detect the used indention of the listing and that the \Key{gobble} setting +% to this value. This functionality is provided by this package. +% For this it reads and scans the first listing line and reinserts it again afterwards. +% +% +% \section{Usage} +% After loading \pkg{lstautogobble} the following new \pkg{listings} setting +% is available: +% +% \DescribeKey{autogobble}'=true|false' +% This boolean setting switches the autogobble feature on or off. +% If no value is used the default is `|true|'. The initial setting is `|false|'. +% One enabled the first line of any \pkg{lstlisting} is scanned and the amount +% of spaces or tabulators is used to set the \Key{gobble} setting. +% If \Key{gobble} is set manually it will not be overwritten and \Key{autogobble}'=true' +% is ignored. +% +% \section{Examples / Tests} +% The following code is intended as examples and also for testing the package. +% Here the \Key{autogobble} feature is globally enabled. +% +% \lstdefinestyle{exampleresult}{basicstyle=\ttfamily,columns=fullflexible,autogobble=true}% +% +% \begin{example} +% \caption{Only environment (with \Key{autogobble} enabled globally).} +% \begin{examplecode} +% \begin{lstlisting} +% test +% it +% \end{lstlisting} +% \end{examplecode} +% \end{example} +% +% \begin{example} +% \caption{With options (must be skipped and reinserted).} +% \begin{examplecode} +% \begin{lstlisting}[basicstyle=\ttfamily\scriptsize] +% test +% it +% \end{lstlisting} +% \end{examplecode} +% \end{example} +% +% \begin{example} +% \caption{Manual gobble option (override). Intentionally set to an incorrect value.} +% \begin{examplecode} +% \begin{lstlisting}[gobble=7] +% test +% it +% \end{lstlisting} +% \end{examplecode} +% \end{example} +% +% \begin{example} +% \caption{Locally turned-off \Key{autogobble}.} +% \begin{examplecode} +% \begin{lstlisting}[autogobble=false] +% test +% it +% \end{lstlisting} +% \end{examplecode} +% \end{example} +% +% \begin{example} +% \caption{With some material on the same line as \texttt{\string\begin} (dropped by listings. The warning message got preserved).} +% \begin{examplecode} +% \begin{lstlisting} some text at the first line +% test +% it +% \end{lstlisting} +% \end{examplecode} +% \end{example} +% +% \begin{example} +% \caption{As before, but with optional argument.} +% \begin{examplecode} +% \begin{lstlisting}[] some text at the first line +% test +% it +% \end{lstlisting} +% \end{examplecode} +% \end{example} +% +% \begin{example} +% \caption{Different indention levels.} +% \begin{examplecode} +% \begin{lstlisting} +% test +% it +% \end{lstlisting} +% \end{examplecode} +% \begin{examplecode} +% \begin{lstlisting} +% test +% it +% \end{lstlisting} +% \end{examplecode} +% \begin{examplecode} +% \begin{lstlisting} +% test +% it +% \end{lstlisting} +% \end{examplecode} +% \begin{examplecode} +% \begin{lstlisting} +% test +% it +% \end{lstlisting} +% \end{examplecode} +% \begin{examplecode} +% \begin{lstlisting} +% test +% it +% \end{lstlisting} +% \end{examplecode} +% \end{example} +% +% \begin{example} +% \caption{Some real C Code.} +% \begin{examplecode} +% \begin{lstlisting}[autogobble] +% #include +% int main(){ +% printf("tex.stackexchange.com: the coolest community ever!\n"); +% } +% \end{lstlisting} +% \end{examplecode} +% \end{example} +% +% \StopEventually{} +% \clearpage +% \section{Implementation} +% +% \iffalse +%<*lstautogobble.sty> +% \fi +% \begin{macrocode} +% +\ProvidesPackage{lstautogobble}[% +% +% +%<*DRIVER> + 2099/01/01 develop +% + Implements 'autogobble' option for 'listings'] +% \end{macrocode} +% \begin{macrocode} + +% This is an add-on to the `listings` package +\RequirePackage{listings} + +% Counter for leading spaces +\newcount\lstag@spacecount + +% Some macros for comparison: +\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 + + +% Define `autogobble` option as boolean (by default off) +\lst@Key{autogobble}{false}[t]{\lstKV@SetIf{#1}\lst@ifautogobble} + +% `ungobble` option +\lst@Key{ungobble}{0}{\def\lst@ungobble{#1}} + +% Insert required code at environment init +\lst@AddToHook{Init}{\lst@autogobble} + +% Autogobble init macro. +% If the option is active and `gobble` is not set, init vars and overwrite the process macro with own definition. +\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 +} + +% Checks if the next following character (read as argument) is a line break (as it is supposed to be) +% Otherwise there is some text direct after the `\begin{}[]` which is dropped by `listings`. +\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 +} + +% After the new line is found this macro counts the spaces and tabulators +\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 +} +% \end{macrocode} +% \iffalse +% +% \fi +% +% \Finale +\endinput diff --git a/macros/latex/contrib/lstaddons/lstautogobble.pdf b/macros/latex/contrib/lstaddons/lstautogobble.pdf new file mode 100644 index 0000000000..5321a97319 Binary files /dev/null and b/macros/latex/contrib/lstaddons/lstautogobble.pdf differ diff --git a/macros/latex/contrib/lstaddons/lstlinebgrd.dtx b/macros/latex/contrib/lstaddons/lstlinebgrd.dtx new file mode 100644 index 0000000000..860e6b6e81 --- /dev/null +++ b/macros/latex/contrib/lstaddons/lstlinebgrd.dtx @@ -0,0 +1,289 @@ +% \iffalse meta-comment +%<=*COPYRIGHT> +%% Copyright (C) 2011-2012 by Martin Scharrer +%% ---------------------------------------------------------------------- +%% 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. +%% +%<=/COPYRIGHT> +% \fi +% +% \iffalse +%<*driver> +\ProvidesFile{lstlinebgrd.dtx}[% +%<=*DATE> + 2012/05/03 +%<=/DATE> +%<=*VERSION> + v0.1 +%<=/VERSION> + DTX file for 'lstlinebgrd'] +\documentclass{ydoc} +\GetFileInfo{lstlinebgrd.dtx} +\usepackage{lstlinebgrd}[\filedate] +\EnableCrossrefs +\CodelineIndex +\RecordChanges +\floatstyle{plaintop} +\restylefloat{example} +\belowcaptionskip=\medskipamount + +\renewcommand\topfraction{.9} +\renewcommand\bottomfraction{.9} +\renewcommand\textfraction{.1} +\renewcommand\floatpagefraction{.7} +\renewcommand\dbltopfraction{.9} +\begin{document} + \DocInput{\jobname.dtx} + \PrintChanges + \PrintIndex +\end{document} +% +% \fi +% +% \CheckSum{0} +% +% \CharacterTable +% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} +% + +% \changes{v0.1}{2012/05/03}{Initial release.} +% +% \DoNotIndex{\newcommand,\newenvironment} +% +% \GetFileInfo{lstlinebgrd.dtx} +% \author{Martin Scharrer} +% \email{martin@scharrer-online.de} +% \ifdefined\repository +% \repository{https://bitbucket.org/martin_scharrer/lstlinebgrd} +% \fi +% +% \maketitle +% +% \begin{abstract}\noindent +% This add-on package to \pkg{listings} provides the option to add background colors to lines of listings. +% Every line can be given a different color by using a conditional which +% depends on the line number. +% +% This package was created as response to the question +% \href{http://tex.stackexchange.com/q/18969/2975}{``Creating a zebra effect using listings''} +% on \href{http://tex.stackexchange.com/}{\TeX\ Stack Exchange}. +% \end{abstract} +% +% \section{Usage} +% The following settings are added by \pkg{lstlinebgrd} for \pkg{listings} and can be used in \Macro\lstset or any +% \pkg{listings} macro which accepts options. +% +% \DescribeKey{linebackgroundcolor}'=' +% This options allows the user to provide some \LaTeX\ code which sets the background +% color. The code must use \Macro\color{} or a different color macro. +% The use of conditionals is permitted and can be used to color lines depending on +% the line number (|\value{lstnumber}|) etc., as shown in the example section. +% The initial setting of this option is |{}|, i.e.\ no coloring is done. +% +% \DescribeKey{linebackgroundsep}'=' +% Sets the distance of the begin of the background color bar and the line. +% A horizontal skip of this amount to the left from the start of the line is done +% before drawing the background line. This means that positive amounts will move +% the background color bar to the left and negative amounts to the right. +% This does not effect the total width of the color bar. +% +% \DescribeKey{linebackgroundwidth}'=' +% Sets the width of the background color bar. The initial default value is |\linewidth|. +% Note that the background width does not take the actual width of the text into account, +% because \pkg{listing} does not provide this information. +% +% \DescribeKey{linebackgroundheight}'=' +% Sets the height of the background color bar, i.e.\ the amount above the baseline. +% The initial value is |\ht\strutbox|, i.e.\ the full height of the line. +% +% \DescribeKey{linebackgrounddepth}'=' +% Sets the depth of the background color bar, i.e.\ the amount below the baseline. +% The initial value is |\dp\strutbox|, i.e.\ the full depth of the line. +% +% \DescribeKey{linebackgroundcmd}'=' +% This advanced option sets the macro used to draw the background color bar. It is called at the correct +% starting position and receives the width, height and depth as three arguments in this order. +% The initial value is |\color@block| which is an internal macro of the \pkg{xcolor} package. +% This option can be used by advanced users to fine tune the background coloring. +% +% +% \clearpage +% \section{Examples} +% \def\PrintExample{% +% \begingroup +% \BoxExample +% \sffamily +% \par\medskip +% \centerline{Code\strut}% +% \smallskip +% \hrule +% \usebox\examplecodebox +% \par\hrule\bigskip +% \centerline{Result\strut}% +% \smallskip +% \hrule +% \usebox\exampleresultbox +% \par\hrule\medskip +% \endgroup +% } +% +% \begin{example} +% \caption{Basic example: zebra effect.} +% \begin{examplecode} +% \begin{lstlisting}[language=C,basicstyle=\ttfamily,linebackgroundcolor={\ifodd\value{lstnumber}\color{green}\fi}] +% /** +% * Prints Hello World. +% **/ +% #include + +% int main(void) { +% printf("Hello World!"); +% return 0; +% } +% \end{lstlisting} +% \end{examplecode} +% \end{example} +% \begin{example} +% \caption{Two-colored zebra effect with extra adjustments.} +% \begin{examplecode} +% \begin{lstlisting}[language=C,basicstyle=\ttfamily\Large,linebackgroundcolor={\ifodd\value{lstnumber}\color{green}\else\color{yellow}\fi},numbers=left,linebackgroundsep=1em,linebackgroundwidth=18em] +% /** +% * Prints Hello World. +% **/ +% #include +% +% int main(void) { +% printf("Hello World!"); +% return 0; +% } +% \end{lstlisting} +% \end{examplecode} +% \end{example} +% +% \begin{example} +% \caption{Gradient effect with extra adjustments.} +% \begin{examplecode} +% \begin{lstlisting}[language=C,basicstyle=\ttfamily\tiny,linebackgroundcolor={\color{blue!\the\numexpr 5*\value{lstnumber}\relax}},linebackgroundheight=1.7ex,linebackgrounddepth=.4ex] +% /** +% * Prints Hello World. +% **/ +% #include +% +% int main(void) { +% printf("Hello World!"); +% return 0; +% } +% /** +% * Prints Hello World. +% **/ +% #include +% +% int main(void) { +% printf("Hello World!"); +% return 0; +% } +% \end{lstlisting} +% \end{examplecode} +% \end{example} +% +% \StopEventually{} +% \clearpage +% \section{Implementation} +% +% \iffalse +%<*lstlinebgrd.sty> +% \fi +% \begin{macrocode} +% +\ProvidesPackage{lstlinebgrd}[% +% +% +%<*DRIVER> + 2099/01/01 develop +% + Provides 'listings' options to color the background of lines] +% \end{macrocode} +% \begin{macrocode} +% +\RequirePackage{listings} +\RequirePackage{xcolor} + +% Patch line number key to call line background macro +\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}} + +% New keys +\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}% +} + + +% Line Background macro +\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 +} +% \end{macrocode} +% \iffalse +% +% \fi +% +% \Finale +\endinput diff --git a/macros/latex/contrib/lstaddons/lstlinebgrd.pdf b/macros/latex/contrib/lstaddons/lstlinebgrd.pdf new file mode 100644 index 0000000000..55843f75a6 Binary files /dev/null and b/macros/latex/contrib/lstaddons/lstlinebgrd.pdf differ -- cgit v1.2.3