|
6 | 6 | % |
7 | 7 | \def\@lstbasicstyle{\small\color{listing-text-color}\linespread{1.0}\lst@ifdisplaystyle\small\fi\ttfamily{}}% |
8 | 8 | % |
| 9 | +\newsavebox\@lst@mypostbreak% |
| 10 | +\savebox\@lst@mypostbreak{\textcolor{red}{$\hookrightarrow$}\space}% |
| 11 | +% |
9 | 12 | \lstdefinestyle{basic_style}{% |
10 | 13 | backgroundcolor=\color{listing-background},% |
11 | 14 | numbers=left,% |
@@ -34,7 +37,7 @@ stringstyle=\color{listing-string},% |
34 | 37 | showspaces=false,% |
35 | 38 | showtabs=false,% |
36 | 39 | showstringspaces=false,% |
37 | | -postbreak=\mbox{\textcolor{red}{$\hookrightarrow$}\space},% |
| 40 | +postbreak=\usebox\@lst@mypostbreak,% |
38 | 41 | % |
39 | 42 | literate=% |
40 | 43 | {á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1% |
@@ -199,198 +202,6 @@ breaklines=true% |
199 | 202 | \gdef\pythoniles#1{% |
200 | 203 | \inlinelistingbox{\lstinline[style=python_style]$#1$\resizebox{!}{\@lstbasicstylesheight}{\color{darkgray}es}}}% |
201 | 204 | % |
202 | | -%% |
203 | | -%% Use latexgit to place a listing. |
204 | | -%% #1 the git repository |
205 | | -%% #2 the local path |
206 | | -%% #3 the post-processing |
207 | | -%% #4 the label (lst: will be pre-pended) |
208 | | -%% #5 the caption |
209 | | -%% #6 the style to use |
210 | | -\protected\gdef\gitCode#1#2#3#4#5#6{% |
211 | | -\gitLoad{#1}{#2}{#3}% |
212 | | -\expandafter\expandafter\expandafter\edef\expandafter\csname @pwp@gitUrl:lst:#4\endcsname{\gitUrl}% |
213 | | -\expandafter\expandafter\expandafter\edef\expandafter\csname @pwp@gitFile:lst:#4\endcsname{\gitFile}% |
214 | | -\begin{figure}[tb]% |
215 | | -\lstinputlisting[label={lst:#4}#6,caption={#5~(\href{\csname @pwp@gitUrl:lst:#4\endcsname}{src})}]{\csname @pwp@gitFile:lst:#4\endcsname}% |
216 | | -\end{figure}% |
217 | | -}% |
218 | | -% |
219 | | -%% |
220 | | -%% Use latexgit to place a Python listing. |
221 | | -%% #1 the git repository |
222 | | -%% #2 the local path |
223 | | -%% #3 the post-processing |
224 | | -%% #4 the label (lst: will be pre-pended) |
225 | | -%% #5 the caption |
226 | | -\protected\gdef\gitPython#1#2#3#4#5{% |
227 | | -\gitCode{#1}{#2}{python3 -m latexgit.formatters.python #3}{#4}{#5}{,style=python_style}% |
228 | | -}% |
229 | | -% |
230 | | -%% |
231 | | -%% Use latexgit to place a Bash listing. |
232 | | -%% #1 the git repository |
233 | | -%% #2 the local path |
234 | | -%% #3 the label (lst: will be pre-pended) |
235 | | -%% #4 the caption |
236 | | -\protected\gdef\gitBash#1#2#3#4{% |
237 | | -\gitCode{#1}{#2}{}{#3}{#4}{,style=bash_style}% |
238 | | -}% |
239 | | -% |
240 | | -%% |
241 | | -%% Use latexgit to place a windows BAT listing. |
242 | | -%% #1 the git repository |
243 | | -%% #2 the local path |
244 | | -%% #3 the label (lst: will be pre-pended) |
245 | | -%% #4 the caption |
246 | | -\protected\gdef\gitBat#1#2#3#4{% |
247 | | -\gitCode{#1}{#2}{}{#3}{#4}{,style=bat_style}% |
248 | | -}% |
249 | | -% |
250 | | -%% |
251 | | -%% Use latexgit to place a plain text listing. |
252 | | -%% #1 the git repository |
253 | | -%% #2 the local path |
254 | | -%% #3 the label (lst: will be pre-pended) |
255 | | -%% #4 the caption |
256 | | -\protected\gdef\gitText#1#2#3#4{% |
257 | | -\gitCode{#1}{#2}{}{#3}{#4}{,style=text_style}% |
258 | | -}% |
259 | | -% |
260 | | -%% Use latexgit to place a listing with program output. |
261 | | -%% #1 the git repository |
262 | | -%% #2 the local path |
263 | | -%% #3 the command |
264 | | -%% #4 the label (exec: will be pre-pended) |
265 | | -%% #5 the additional parameters, if any |
266 | | -%% #6 the style to use |
267 | | -\protected\gdef\gitOutputWithStyle#1#2#3#4#5#6{% |
268 | | -\gitExec{#1}{#2}{#3}% |
269 | | -\expandafter\expandafter\expandafter\edef\expandafter\csname @pwp@gitFile:exec:#4\endcsname{\gitFile}% |
270 | | -\lstinputlisting[style=#6#5]{\csname @pwp@gitFile:exec:#4\endcsname}% |
271 | | -}% |
272 | | -% |
273 | | -%% Use latexgit to place a listing with tool output. |
274 | | -%% #1 the git repository |
275 | | -%% #2 the local path |
276 | | -%% #3 the command |
277 | | -%% #4 the label (exec: will be pre-pended) |
278 | | -%% #5 the caption |
279 | | -\protected\gdef\gitOutputTool#1#2#3#4#5{% |
280 | | -\gitExec{#1}{#2}{#3}% |
281 | | -\expandafter\expandafter\expandafter\edef\expandafter\csname @pwp@gitFile:exec:#4\endcsname{\gitFile}% |
282 | | -\begin{figure}[tb]% |
283 | | -\lstinputlisting[style=tool_style,label={exec:#4},caption={#5}]{\csname @pwp@gitFile:exec:#4\endcsname}% |
284 | | -\end{figure}% |
285 | | -}% |
286 | | -% |
287 | | -%%% Set the output format, because sometimes we want to have different formats in the output |
288 | | -\protected\gdef\gitPythonAndOutputFormat#1{\xdef\@gitPythonAndOutputFormat{#1}}% |
289 | | -\protected\gdef\gitPythonAndOutputFormatDefault{\gitPythonAndOutputFormat{text_style}}% |
290 | | -\gitPythonAndOutputFormatDefault% |
291 | | -% |
292 | | -%% Use latexgit to place a listing with Python code and the program output. |
293 | | -%% #1 the git repository |
294 | | -%% #2 the path to the directory |
295 | | -%% #3 the path to the file inside the directory |
296 | | -%% #4 the post-processing |
297 | | -%% #5 the label (lst: will be prepended to the program, exec: will be |
298 | | -%% pre-pended to the output) |
299 | | -%% #6 the caption |
300 | | -\protected\gdef\gitPythonAndOutput#1#2#3#4#5#6{% |
301 | | -\expandafter\expandafter\expandafter\edef\expandafter\csname @gitPythonAndOutputFormat:exec:#5\endcsname{\@gitPythonAndOutputFormat}% |
302 | | -\gitPythonAndOutputFormatDefault% |
303 | | -% |
304 | | -\gitLoad{#1}{#2/#3}{python3 -m latexgit.formatters.python #4}% |
305 | | -\expandafter\expandafter\expandafter\edef\expandafter\csname @pwp@gitUrl:lst:#5\endcsname{\gitUrl}% |
306 | | -\expandafter\expandafter\expandafter\edef\expandafter\csname @pwp@gitFile:lst:#5\endcsname{\gitFile}% |
307 | | -\gitExec{#1}{#2}{python3 #3}% |
308 | | -\expandafter\expandafter\expandafter\edef\expandafter\csname @pwp@gitFile:exec:#5\endcsname{\gitFile}% |
309 | | -% |
310 | | -\begin{figure}[tb]% |
311 | | -\centering% |
312 | | -\lstinputlisting[label={lst:#5},style=python_style,caption={#6~(stored in file~\href{\csname @pwp@gitUrl:lst:#5\endcsname}{\textil{#3}}; output in~\cref{exec:#5})}]{\csname @pwp@gitFile:lst:#5\endcsname}% |
313 | | -% |
314 | | -$\downarrow$~~\expandafter\bashil{python3 #3}~~$\downarrow$% |
315 | | -% |
316 | | -\edef\@@@@gitOutputFmt{\csname @gitPythonAndOutputFormat:exec:#5\endcsname}% |
317 | | -\lstinputlisting[label={exec:#5},style=\@@@@gitOutputFmt,caption={The \gls{stdout} of the program~\href{\csname @pwp@gitUrl:lst:#5\endcsname}{\textil{#3}} given in~\cref{lst:#5}.}]{\csname @pwp@gitFile:exec:#5\endcsname}% |
318 | | -\end{figure}% |
319 | | -}% |
320 | | -% |
321 | | -%% Use latexgit to place a listing with Bash code and the program output. |
322 | | -%% #1 the git repository |
323 | | -%% #2 the path to the directory |
324 | | -%% #3 the path to the file inside the directory |
325 | | -%% #4 the label (lst: will be prepended to the program, exec: will be |
326 | | -%% pre-pended to the output) |
327 | | -%% #5 the caption |
328 | | -\protected\gdef\gitBashAndOutput#1#2#3#4#5{% |
329 | | -% |
330 | | -\gitLoad{#1}{#2/#3}{}% |
331 | | -\expandafter\expandafter\expandafter\edef\expandafter\csname @pwp@gitUrl:lst:#4\endcsname{\gitUrl}% |
332 | | -\expandafter\expandafter\expandafter\edef\expandafter\csname @pwp@gitFile:lst:#4\endcsname{\gitFile}% |
333 | | -\gitExec{#1}{#2}{bash #3}% |
334 | | -\expandafter\expandafter\expandafter\edef\expandafter\csname @pwp@gitFile:exec:#4\endcsname{\gitFile}% |
335 | | -% |
336 | | -\begin{figure}[tb]% |
337 | | -\centering% |
338 | | -\lstinputlisting[label={lst:#4},style=bash_style,caption={#5~(stored in file~\href{\csname @pwp@gitUrl:lst:#4\endcsname}{\textil{#3}}; output in~\cref{exec:#4})}]{\csname @pwp@gitFile:lst:#4\endcsname}% |
339 | | -% |
340 | | -$\downarrow$~~\expandafter\bashil{bash #3}~~$\downarrow$% |
341 | | -% |
342 | | -\edef\@@@@gitOutputFmt{\csname @gitPythonAndOutputFormat:exec:#4\endcsname}% |
343 | | -\lstinputlisting[label={exec:#4},style=tool_style,caption={The \gls{stdout} of the program~\href{\csname @pwp@gitUrl:lst:#4\endcsname}{\textil{#3}} given in~\cref{lst:#4}.}]{\csname @pwp@gitFile:exec:#4\endcsname}% |
344 | | -\end{figure}% |
345 | | -}% |
346 | | -% |
347 | | -% |
348 | | -%% Use latexgit to place a listing with code and the program output. |
349 | | -%% Ignore errors. |
350 | | -%% #1 the git repository |
351 | | -%% #2 the path to the directory |
352 | | -%% #3 the path to the file inside the directory |
353 | | -%% #4 the post-processing |
354 | | -%% #5 the label (lst: will be prepended to the program, exec: will be |
355 | | -%% pre-pended to the output) |
356 | | -%% #6 the caption |
357 | | -\protected\gdef\gitPythonAndErrorOutput#1#2#3#4#5#6{% |
358 | | -% |
359 | | -\gitLoad{#1}{#2/#3}{python3 -m latexgit.formatters.python #4}% |
360 | | -\expandafter\expandafter\expandafter\edef\expandafter\csname @pwp@gitUrl:lst:#5\endcsname{\gitUrl}% |
361 | | -\expandafter\expandafter\expandafter\edef\expandafter\csname @pwp@gitFile:lst:#5\endcsname{\gitFile}% |
362 | | -\gitExec{#1}{.}{./_scripts_/pythonIgnoreErrors.sh #2 #3}% |
363 | | -\expandafter\expandafter\expandafter\edef\expandafter\csname @pwp@gitFile:exec:#5\endcsname{\gitFile}% |
364 | | -% |
365 | | -\begin{figure}[tb]% |
366 | | -\centering% |
367 | | -\lstinputlisting[label={lst:#5},style=python_style,caption={#6~(stored in file~\href{\csname @pwp@gitUrl:lst:#5\endcsname}{\textil{#3}}; output in~\cref{exec:#5})}]{\csname @pwp@gitFile:lst:#5\endcsname}% |
368 | | -% |
369 | | -$\downarrow$~~\expandafter\bashil{python3 #3}~~$\downarrow$% |
370 | | -% |
371 | | -\lstinputlisting[label={exec:#5},style=text_style,caption={The \gls{stdout} and \gls{stderr} as well as the \pgls{exitCode} of the program~\href{\csname @pwp@gitUrl:lst:#5\endcsname}{\textil{#3}} given in~\cref{lst:#5}.}]{\csname @pwp@gitFile:exec:#5\endcsname}% |
372 | | -\end{figure}% |
373 | | -}% |
374 | | -% |
375 | | -%% |
376 | | -%% The python syntax environment. |
377 | | -%% Warning: If we do not use the minipage, this may or may not |
378 | | -%% cause strange errors like: |
379 | | -%% "! Argument of ? has an extra }." |
380 | | -\lstnewenvironment{pythonSyntax}[1][true]{% |
381 | | -\center% |
382 | | -\minipage{\linewidth}% |
383 | | -\let\@old@lst@visiblespace\lst@visiblespace% |
384 | | -\def\lst@visiblespace{{\color{listing-spaces}\@old@lst@visiblespace}}% |
385 | | -\lstset{% |
386 | | -style=python_style,% |
387 | | -showspaces=#1% |
388 | | -}}{% |
389 | | -\let\lst@visiblespace\@old@lst@visiblespace% |
390 | | -\endminipage% |
391 | | -\endcenter% |
392 | | -}% |
393 | | -% |
394 | 205 | %% A dunder method |
395 | 206 | %% #1 the method name |
396 | 207 | %% This addss the underscores and a index entry. |
|
0 commit comments