texlive[74832] Master/texmf-dist: pdftoolbox (2apr25)

commits+karl at tug.org commits+karl at tug.org
Wed Apr 2 22:19:12 CEST 2025


Revision: 74832
          https://tug.org/svn/texlive?view=revision&revision=74832
Author:   karl
Date:     2025-04-02 22:19:11 +0200 (Wed, 02 Apr 2025)
Log Message:
-----------
pdftoolbox (2apr25)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/acknowledgments.tex
    trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfToolbox-docs.pdf
    trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfToolbox-docs.tex
    trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfdata-docs.tex
    trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfdata-internal-docs.tex
    trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfdstruct-docs.tex
    trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfgraphics-docs.tex
    trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfgraphics-internal-docs.tex
    trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/preamble.tex
    trunk/Master/texmf-dist/doc/latex/pdftoolbox/README.md
    trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfDstruct/ptb-hyperlinks.tex
    trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfDstruct/ptb-lists.tex
    trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfDstruct/ptb-tableofcontents.tex
    trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/ptb-colorboxes.tex
    trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/ptb-colors.tex
    trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfToolbox.tex
    trunk/Master/texmf-dist/tex/plain/pdftoolbox/ptb-pdfGraphics.tex
    trunk/Master/texmf-dist/tex/plain/pdftoolbox/ptb-utils.tex

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/versions.tex
    trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/listingcommands/
    trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/listingcommands/ptb-syntax-C.tex
    trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/listingcommands/ptb-syntax-TeX.tex
    trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/ptb-listings.tex

Removed Paths:
-------------
    trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/ptb-syntax-hi.tex

Modified: trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/acknowledgments.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/acknowledgments.tex	2025-04-02 20:18:49 UTC (rev 74831)
+++ trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/acknowledgments.tex	2025-04-02 20:19:11 UTC (rev 74832)
@@ -4,6 +4,9 @@
 Thank you to plante (\url{https://github.com/plante3}{github}) for the guidance and mentoring in the way of \TeX.
 Many of the macros in this project are due to, or inspired by, him.
 
+Thank you to Petr Ol\v s\'ak (\url{https://petr.olsak.net/}{website}), whose articles and documentations have given me much insight and inspiration.
+Especially his article on \macro\pdfliteral s and his Op\TeX{} documentation (which inspired much of the mechanism around \pdftoolbox's listings feature).
+
 Thank you to the Mathematics Discord server (\url{https://discord.com/invite/math}{invite}) for fostering a welcoming community where anyone can learn math, and for first introducing me to the world of \TeX.
 
 Thank you to all my friends for their continued support and interest.

Modified: trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfToolbox-docs.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfToolbox-docs.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfToolbox-docs.tex	2025-04-02 20:18:49 UTC (rev 74831)
+++ trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfToolbox-docs.tex	2025-04-02 20:19:11 UTC (rev 74832)
@@ -5,6 +5,10 @@
 \parindent=0pt
 \parskip=3pt plus 2pt minus 2pt
 
+\loadsyntax{TeX}
+\setsyntax{TeX}
+\everylisting={\lstlinenum=\z@}
+
 \footline={}
 
 \headline={\pageborder{rgb{.5 .5 1}}{rgb{0 0 .4}}{5}}
@@ -53,6 +57,10 @@
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+\section{pdfToolbox Versions}
+
+\input versions
+
 \part{pdfToolbox in brief}
 
 \section{pdfData}

Modified: trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfdata-docs.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfdata-docs.tex	2025-04-02 20:18:49 UTC (rev 74831)
+++ trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfdata-docs.tex	2025-04-02 20:19:11 UTC (rev 74832)
@@ -214,7 +214,7 @@
 \eenum
 So for example,
 
-\beginhi \color{white}
+\blisting
 \def\X{0}
 \beginscope
     \localize\X
@@ -227,12 +227,12 @@
     \X
 \endscope
 \X
-\endhi
+\elisting
 
 Will output 1 2 2 0.
 As opposed to
 
-\beginhi \color{white}
+\blisting
 \def\X{0}
 \bgroup
     \def\X{1}
@@ -244,7 +244,7 @@
     \X
 \egroup
 \X
-\endhi
+\elisting
 
 Which will output 1 2 1 0.
 
@@ -327,7 +327,7 @@
 
 So for example, you may have a macro defined like so:
 
-\beginhi \color{white}
+\blisting
 \def\puthi#1{Hello (#1)}
 
 \def\getinput#1{%
@@ -340,7 +340,7 @@
         },
         second={
             name=snd,
-            default=S. Lurp%
+            default=A. Feiglin%
         }%
     }{#1}%
 }
@@ -347,9 +347,9 @@
 
 \getinput{first=pdftoolbox}
 (\fst) (\snd)
-\endhi
+\elisting
 
-This will output {\tt (Hello (pdftoolbox)) (S. Lurp)}.
+This will output {\tt (Hello (pdftoolbox)) (A. Feiglin)}.
 
 \macroexp{\keyexists {<key>}<macro>\lastkeys}
 This is an internal command, added to this documentation only due to its usefulness.

Modified: trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfdata-internal-docs.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfdata-internal-docs.tex	2025-04-02 20:18:49 UTC (rev 74831)
+++ trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfdata-internal-docs.tex	2025-04-02 20:19:11 UTC (rev 74832)
@@ -23,20 +23,20 @@
 The simplest setter ({\it mapkey macro}) is \macro\_vanilla_mapkey\anchormacro\_vanilla_mapkey, which does exactly what was described and nothing more.
 Its definition is simply:
 
-\begincode
+\blisting
 \def\_vanilla_mapkey#1#2#3{%
     \_xp\def\csname key@\_id#2\endcsname{#3}%
     \_update_lastkeys{#1}{#2}{#3}%
 }
-/endcode
+\elisting
 
 You can use the macro \macro\getvalue\anchormacro\getvalue{} to get the value of a key: its definition is simply
 
-\begincode
+\blisting
 \def\getvalue#1{%
     \csname key@#1\endcsname%
 }
-/endcode
+\elisting
 
 Another macro is \macro\keyexists{} whose use is
 
@@ -51,7 +51,7 @@
 
 \macro\mapkeys{} is defined as follows:
 
-\begincode
+\blisting
 \def\mapkeys#1#2{%
     \_mapkeys_with_setter\_vanilla_mapkey\_keymappings{#1}%
     \_xp\_setdefaults\_xp{\_keymappings}%
@@ -58,7 +58,7 @@
     \_mapkeys_with_setter\_protected_mapkey\lastkeys{#2}%
     \_check_required_supplied%
 }
-/endcode
+\elisting
 
 So first it gets the key-value pairs in {\it options} (\inlinecode|#1|) using \macro\_vanilla_mapkey; it places the results in \macro\_keymappings.
 Then it sets the default values (this is what \macro\_setdefaults{} does; as well as figuring out which keys are required).

Modified: trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfdstruct-docs.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfdstruct-docs.tex	2025-04-02 20:18:49 UTC (rev 74831)
+++ trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfdstruct-docs.tex	2025-04-02 20:19:11 UTC (rev 74832)
@@ -39,7 +39,7 @@
 {\it sizes} is a key-value dictionary which specifies the font codes for different sizes of the font.
 For example, in {\tt pdfDstruct/fonts.tex} is the usage:
 
-\beginhi \color{white}
+\blisting
 \addfont{rm}{%
     default=cmr10,
     5pt=cmr5,
@@ -51,7 +51,7 @@
     12pt=cmr12,
     17pt=cmr17
 }
-\endhi
+\elisting
 
 So now \pdftoolbox{} has access to the computer modern roman font ({\tt cmr}) at the sizes specified.
 The purpose of the default size is for when a size is not available.
@@ -206,10 +206,11 @@
 Similarly enumerated lists start with \macro\benum\anchormacro\benum{} and end with \macro\elist\anchormacro\eenum.
 Each item begins with \macro\item, and the style for the enumeration is determined by the depth of the list.
 For a depth of $N$, the $n$th element is styled with \inlinecode|\enumstyleN{n}|.
+It is put in a box of width \inlinecode|\enumstyleN at wd|.
 
 To add text in between items (not as part of the list), you can use \macro\mtext\anchormacro\mtext.
 
-\subsection{Table of Contents}
+\subsection{Table of Contents} \anchor{table-of-contents}
 
 In {\tt pdfDstruct/tableofcontents.tex}, \pdftoolbox{} provides macros for creating and displaying tables of content.
 
@@ -241,6 +242,10 @@
 \pdftoolbox{} provides four types of sectioning: parts, sections, subsections, and subsubsections.
 Each has a counter in its name (e.g. {\tt section}), and a macro with the current section name (e.g. \macro\currsection).
 
+\macroexp{\part {<title>}}
+Adds a part to the document.
+\emacroexp
+
 \macroexp{\section (*){<title>}}
 Adds a section to the document.
 If the asterisk is added, the section is a ``pseudosection'': the section counter is not incremented and not displayed, and the section is not added to the table of contents.

Modified: trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfgraphics-docs.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfgraphics-docs.tex	2025-04-02 20:18:49 UTC (rev 74831)
+++ trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfgraphics-docs.tex	2025-04-02 20:19:11 UTC (rev 74832)
@@ -56,18 +56,25 @@
 \macroexp{\curvedcolorbox {<stroke color>}{<bg color>}{<material>}{<curve control>}}
 Creates a curved color framed box around {\it material} with frame color {\it stroke color} and background color {\it bg color} (which may be names or of the form \inlinecode|<color space>{<code>}|.
 The curve's stroke width is determined by \macro\curvewidth, and the buffer around the material is determined by \macro\curvebuffer.
-{\it control} is a sequence of $4$ symbols (either {\tt .} or {\tt X}) which determine whether a corner is curved or not.
-A {\tt .} corresponds to a curve and a {\tt X} corresponds to a right corner.
+
+{\it control} is a sequence of $8$ symbols of the form \getmacrousageB{<bline><bldot><lline><tldot><tline><trdot><rline><brdot>} where each $\langle{\tt X\it dot}\rangle$ corresponds to whether or not a corner is curved or not
+({\tt bl} for bottom left, {\tt tl} for top left, etc.), and each $\langle{\tt X\it line}\rangle$ corresponds to whether or not a border is drawn or not ({\tt b} for bottom, {\tt l} for left, etc.).
+For a corner, {\tt.} corresponds to a curve and {\tt X} for a right corner.
+For a border, {\tt-} corresponds to drawing the line and \inlinecode|_| to not.
+
 A shadow of color \macro\boxshadowcolor{} is added to to the box, at an x and y offset of \macro\shadowxoff{} and \macro\shadowyoff{} respectively.
 
 So for example:
 
 \displaycode{%
-\curvedcolorbox{blue}{red}{\color{white}pdfToolbox}{....}&\cr
-\curvedcolorbox{blue}{red}{\color{white}pdfToolbox}{X...}&\cr
-\curvedcolorbox{blue}{red}{\color{white}pdfToolbox}{.X..}&\cr
-\curvedcolorbox{blue}{red}{\color{white}pdfToolbox}{..X.}&\cr
-\curvedcolorbox{blue}{red}{\color{white}pdfToolbox}{...X}&}
+\curvedcolorbox{blue}{red}{\color{white}pdfToolbox}{-.-.-.-.}&\cr
+\curvedcolorbox{blue}{red}{\color{white}pdfToolbox}{-X-.-.-.}&\cr
+\curvedcolorbox{blue}{red}{\color{white}pdfToolbox}{-.-X-.-.}&\cr
+\curvedcolorbox{blue}{red}{\color{white}pdfToolbox}{-.-.-X-.}&\cr
+\curvedcolorbox{blue}{red}{\color{white}pdfToolbox}{-.-.-.-X}&\cr
+\curvedcolorbox{blue}{red}{\color{white}pdfToolbox}{_X-X_X-X}&\cr
+\curvedcolorbox{blue}{red}{\color{white}pdfToolbox}{_._._._.}&\cr
+\curvedcolorbox{blue}{red}{\color{white}pdfToolbox}{-X_X-X_X}&}
 \emacroexp
 
 \macroexp{\fakebold {<material>}}
@@ -183,7 +190,7 @@
 So for example, 
 
 \bgroup\parindent=\z@
-\beginhi \color{white}
+\blisting
 \drawdiagram{
     A&B\cr
     C&D
@@ -193,7 +200,7 @@
     \diagarrow{from={2,2}, to={2,1}, curve=10pt, origin orient={xcenter,bottom}, dest orient={xcenter,bottom}}
     \diagarrow{from={2,1}, to={1,1}, dashed, left cap=o, right cap=o}
 }
-\endhi
+\elisting
 \egroup
 
 Will yield
@@ -212,3 +219,60 @@
 Between each column, \macro\diagcolbuf.
 The height of each row is at least \macro\diagrowheight{} and the width of each column is at least \macro\diagcolwidth.
 
+\subsection{Listings}
+
+In {\tt pdfGraphics/ptb-listings.tex}, \pdftoolbox{} provides macros for writing code listings.
+The mechanism for how \pdftoolbox's listing works is greatly inspired by Petr Ol\v s\'ak's \url{https://ctan.org/pkg/optex?lang=en}{Op\TeX}.
+The mechanism is largely the same, though the implementation may differ.
+
+\macroexp{\setupverb}
+This will set up a verbatim environment, essentially changing all special category codes to $12$.
+\emacroexp
+
+\macroexp{\blisting <first line> ... \elisting}
+Writes {\tt...} in a verbatim environment, with syntax highlighting if set (see \gotomacro\loadsyntax{} and \gotomacro\setsyntax).
+{\it first line} (the rest of the line after \macro\blisting) will be executed as normal (so you can set syntax here; see \gotomacro\setsyntax).
+The line number of each line in the listing is stored in \macro\lstlinenum\anchormacro\lstlinennum, which is not reset after each listing.
+\emacroexp
+
+\macroexp{\listfile {<file>}[<start>-<end>]}
+Creates a listing from file {\it file}.
+Reads between lines {\it start} and {\it end} (inclusive).
+If {\it start} isn't provided, starts from $1$.
+If {\it end} isn't provided reads until the end (actually a large number).
+\emacroexp
+
+\macroexp{\loadsyntax {<language>}}
+Loads in the necessary information for {\it language} syntax highlighting.
+The information is input from the ptb-syntax file {\tt ptb-syntax-{\it language}}.
+See the \gotoanchor{internal-listings}{internals of this section} for more information on how to write such a file.
+
+Currently \pdftoolbox{} provides support for syntax highlighting of \TeX{} ({\it language} is {\tt TeX}) and of C ({\it language} is {\tt C}).
+\emacroexp
+
+\macroexp{\setsyntax {<language>}}
+Sets the syntax to be used for syntax highlighting.
+This must be used after \macro\loadsyntax{} for {\it language}.
+\emacroexp
+
+Some useful macros for customizing syntax highlighting are the following:
+\blist
+    \item \macro\lstlineskip: the space added between each line in the listing;
+    \item \macro\lstvbuf: the space added before and after the listing;
+    \item \macro\lstlinenumbuf: the kerning added between the number and code on each line in the listing;
+    \item \macro\lstnumfontset: sets the font (and whatever else, e.g. color) of the numbers of each line in the listing;
+    \item \macro\lstfontset: sets the font (and whatever else, e.g. color) of the content of each line;
+    \item \macro\lststrut: the strut added to each line in the listing (for uniform spacing).
+\elist
+
+Some useful colors to be aware of:
+\blist
+    \item {\tt lst-fg}: the default foreground color of the listing;
+    \item {\tt lst-bg}: the background color of the listing;
+    \item {\tt lst-comment}: the colors of comments (must be activated in the ptb-syntax file);
+    \item {\tt lst-number}: the colors of numbers (must be activated in the ptb-syntax file).
+\elist
+
+\pdftoolbox{} also provides a token list \macro\everylisting{} which is inserted before every listing.
+So for example doing \inlinecode|\everylisting={\lstlinenum=0}| will reset the line numbering before each listing.
+

Modified: trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfgraphics-internal-docs.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfgraphics-internal-docs.tex	2025-04-02 20:18:49 UTC (rev 74831)
+++ trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/pdfgraphics-internal-docs.tex	2025-04-02 20:19:11 UTC (rev 74832)
@@ -53,15 +53,17 @@
 Expands to the pdf code for {\it color} ({\it place} is either {\tt fg}, {\tt bg}, or left empty).
 \emacroexp
 
-\section{Colorboxes}
+\subsection{Colorboxes}
 
 \pdftoolbox{} provides a relatively simple interface for creating colorboxes like \macro\bppbox.
 The main macro is \macro\_splitcontentbox\anchormacro\_splitcontentbox, whose usage is
 
-\getmacrousage{\_splitcontentbox {<buffer>}<macro>}
+\getmacrousage{\_splitcontentbox {<buffer>}<macroT><macroS><macroM><macroE>}
 
 Which repetitively splits the box \macro\_contentbox\anchormacro\_contentbox{} into \macro\_splitbox{} to fill the remaining material on a page or in the box itself.
-Then the split box is passed to {\it macro} for pretty formatting.
+Then the split box is passed to {\it macroX} for pretty formatting.
+{\it macroT} is if the material fits entirely on a single page, otherwise the first box uses {\it macroS}, the
+last box uses {\it macroE}, and all intermediate boxes use {\it macroM}.
 {\it buffer} is the total amount of vertical buffering that {\it macro} adds to the box it prints.
 
 So to create your own prettyprint-box (ppbox), you create two macros, say \macro\beginpp{} and \macro\endpp.
@@ -68,7 +70,7 @@
 In \macro\beginpp{} you add the code which should go before the ppbox and starts getting content for \macro\_contentbox.
 For example, it could be as simple as:
 
-\begincode
+\blisting
 \def\beginpp#1#2{%
     \def\_colorcontentbox{%
         \hbox{\coloredbox{#1}{\_setcolor{}{#2}\box\_splitbox}}%
@@ -80,10 +82,11 @@
 
 \def\endpp{%
     \egroup%
-    \_splitcontentbox{\bufferwidth * 2}\_colorcontentbox%
+    \_splitcontentbox{\bufferwidth * 2}%
+        \_colorcontentbox\_colorcontentbox\_colorcontentbox\_colorcontentbox%
     \kern.5cm\relax%
 }
-/endcode
+\elisting
 
 This creates a ppbox which is simply a wrapper around \gotomacro\coloredbox.
 It colors the background in \inlinecode|#1| and the foreground in \inlinecode|#2|.
@@ -102,6 +105,71 @@
     \item \macro\endpp{} adds buffering after the final ppbox.
 \eenum
 
+\subsubsection{The Mechanism}
+
+In this section we describe the mechanism through which \pdftoolbox{} creates colorboxes.
+A good reference for this section, which discusses the mechanism through which \TeX{} creates pages (the output routine) is ``The Advanced \TeX book'' by David Salomon.
+
+We begin with a simple macro which expands to the amount of space left in the page.
+\listfile{ptb-colorboxes}[9-15]
+\macro\pagetotal{} is the height of the main vertical list (MVL).
+\macro\pagegoal{} is the goal height of the MVL.
+It is generally equal to \macro\vsize, but when footnotes or similar are generated, their heights are
+subtracted from \macro\pagegoal.
+At the beginning of each page, \macro\pagegoal{} is set to \macro\maxdimen{} (hence the use of the
+\macro\ifdim).
+
+\pdftoolbox{} stores the content to be split across pages in \inlinecode|\box\_contentbox|.
+
+The following macro \macro\_getsplitdim{} gives the dimension that \macro\_contentbox{} should be split into.
+Its parameter is the size of the extra vertical glue that is added to each box.
+\listfile{ptb-colorboxes}[17-41]
+\benum
+    \item First we check if there is enough space to place the entirety of the box into the page.
+        If so set \macro\_splitdim{} to the height of the box, and set \macro\_lastbox{} to true since we wil be placing the entirity of the box.
+    \item Otherwise, check if there is any space left on the current page (recall that \inlinecode|#1| is the
+        amount of vertical space added.)
+        If there is, then set \macro\_splitdim{} to the amount of space left.
+    \item Otherwise, we perform the following checks:
+        \benum
+            \item If \macro\_recheck{} is false, then we add \inlinecode|\null\par| to the page.
+                This just moves all recent contributions to the MVL.
+                The reason for this is that we need to get rid of all the material that came before the
+                colorbox, and we then recheck the dimension, and set \macro\_recheck{} to true.
+            \item Otherwise, the MVL is up-to-date, and there is still not enough room.
+                So we try to fill in the rest of the vertical space and \macro\break.
+                If for whatever reason this doesn't work, we add \macro\vfilneg{} to remove the glue added.
+        \eenum
+        In either case we get the dimension again.
+\eenum
+
+Now, the main macro is \macro\_splitcontentbox:
+\listfile{ptb-colorboxes}[46-77]
+It first sets \macro\splittopskip{} to $0{\tt pt}$ so that no extra glue is added to the top of \macro\vsplit.
+Then \macro\boxmaxdepth{} is also set to $0{\tt pt}$ so that the depth of the split boxes will be $0{\tt pt}$
+and we can deal only with height.
+We also turn off interlineskip so there is no extra glue added around the split boxes (these do not affect
+the contents of \macro\_contentbox{} since it has already been boxed).
+
+Now we repeat until \macro\_contentbox{} is empty:
+\benum
+    \item we get the amount of space to split the box into via \macro\_getsplitdim{} (explained above);
+    \item we split \macro\_contentbox{} into \macro\_splitbox{} of this dimension;
+    \item \inlinecode|#2| is the output routine of the colorbox, it places the contents of \macro\_splitbox{}
+        into whatever format the user specifies.
+        We set \inlinecode|\box0| to this;
+    \item we add the box to the page, and set a penalty of $0$ so that the page can be broken at that point
+        if necessary.
+\eenum
+
+The definition of \macro\bppbox{} and \macro\eppbox{} are a little enlightening:
+\listfile{ptb-colorboxes}[79-116]
+What's of interest here is how \macro\_bppbox{} defines the different \macro\_colorcontentbox s.
+Firstly, \macro\_getdotsnlines{} is a macro which defines \macro\_line{\it side} and \macro\_dot{\it corner} according to the stream of $8$ characters which follow it (until \macro\_nul).
+Now, \macro\_colorcontentboxT{} is defined as you'd expect.
+And \macro\_colorcontentboxS{} is defined so that it preserves the top corners that are input as well as all but the bottom side.
+\macro\_colorcontentboxM{} and \macro\_colorcontentboxE{} are defined similarly.
+
 \subsection{Illustrating} \anchor{internal-pdfdraw}
 
 \bwarning
@@ -109,3 +177,233 @@
 Documentation will be added once it is cleaned up.
 \eppbox
 
+\subsection{Listings} \anchor{internal-listings}
+
+\subsubsection{The Mechanism}
+
+We first begin by discussing the mechanism for how listings work in \pdftoolbox.
+Credit where credit is due; the mechanism is greatly inspired and copied from Petr Ol\v s\'ak's \url{https://ctan.org/pkg/optex?lang=en}{Op\TeX}, though the implementation may differ.
+
+The mechanism is relatively simple: all \pdftoolbox{} does is the following:
+\benum
+    \item call \inlinecode|\the\everylisting| and whatever is given in the remaining line after \macro\blisting;
+    \item call \macro\setupverb{} which changes the catcode of special characters and \inlinecode|^^M| to $12$;
+    \item capture the entirety of the listing from \macro\blisting{} to \macro\elisting;
+    \item set line spacing (via \macro\_setuplstlines);
+    \item call \inlinecode|\the\_commandcapture| which simply sets up macros which are called in \inlinecode|\the\_listingcommands|, which is called immediately afterward (see below);
+    \item call \inlinecode|\the\_commandexecute| which executes the commands added in \inlinecode|\the\_listingcommands| on the listing, and then \inlinecode|\the\_macrocallmanager| which alters the definitions of the macros in
+        \macro\_listingcommands{} to their proper definitions (explanation later);
+    \item at this point, the listing is set up so that everything is ready for printing;
+    \item the line manager is set up (which handles printing each line in the listing);
+    \item the additional vertical buffering added by \macro\syntaxoutbox{} is computed into \macro\syntaxoutboxbuf{} by \macro\syntaxoutboxsetbuf;
+    \item the listing is processed through a ppbox dictated by \macro\syntaxoutbox.
+\eenum
+
+This is a deceptive description of how this process works.
+But what's important is \macro\_commandexecute, which has all the commands for setting up syntax highlighting and the verbatim environment.
+This is not a token list to messed with by the user directly, it should be done indirectly through \macro\_listingcommands, which in turn should be altered indirectly through ptb-syntax files.
+
+But if no syntax is set, the definition of \macro\_commandexecute{} is essentially:
+
+\blisting
+\_commandexecute={
+    \_execute{\_r_replace{ }{\w \w}}
+    \_execute{\_r_replace{^^M}{\w\n\n\w}}
+}
+\elisting
+
+\macro\_execute{} is defined simply to \inlinecode|\def\_execute#1{#1\_code}| right before execution, where \macro\_code{} is the captured listing.
+And \macro\_r_replace{} is defined to simply be \inlinecode|\def\_r_replace#1#2#3{\replace{#3}{#1}{#2}}|.
+So when \macro\_commandexecute{} is called, the result is simply two lines: \inlinecode|\replace{\_code}{ }{\w \w}| and \inlinecode|\replace{\_code}{^^M}{\w\n\n\w}|.
+
+\macroexp{\replace <macro>{<pattern>}{<replacement>}}
+Replaces (the expansion of) {\it pattern} with (the expansion of) {\it replacement} in the definition of {\it macro}.
+\emacroexp
+
+So the result is that now \macro\_code{} contains the listing, but where each space is now swapped with \inlinecode|\w \w| and each line ending with \inlinecode|\w\n\n\w|.
+\macro\_code{} is actually defined to be the listing wrapped in \inlinecode|\n\w...\w\n|, so the result is that every line in the listing is wrapped in \inlinecode|\n...\n| and every word is wrapped in \inlinecode|\w...\w|.
+
+Now suppose you wanted to replace all occurrences of {\tt hi} with {\tt hello}.
+You'd need to add the line \inlinecode|\_execute{\_r_replace{\w hi\w}{\w hello\w}}| to \macro\_commandexecute{} (note that the pattern and replacement are wrapped in \macro\w s).
+You can do so with the following command:
+
+\macroexp{\_add_command_replace {<pattern>}{<replacement>}}
+Adds \getmacrousage{\_execute{\_r_replace{<pattern>}{<replacement>}}} to \macro\_commandexecute.
+\emacroexp
+
+But this is unwieldy, so the actual mechanism used is as follows:
+\benum
+    \item \macro\_commandcapture{} sets the definitions of \macro\replace{} and \gotomacro\replacefromto{} (see below) to\hfill\break\macro\_add_command_replace{} and \macro\_add_command_replacefromto{}.
+    \item \macro\_listingcommands{} contains uses of \macro\replace{} and \macro\replacefromto{}, which are executed.
+        This adds the required lines to \macro\_commandexecute.
+    \item \macro\_commandexecute{} is executed.
+\eenum
+
+Now to explain \gotomacro\loadsyntax{} and \gotomacro\setsyntax: \getmacrousageB{\loadsyntax {<language>}} reads from the ptb-syntaxptb-syntax  file {\tt ptb-syntax-{\it language}.tex}, which should define a token list
+\macro\_{\it language}{\tt _listingcommands}.
+Then \macro\setsyntax{} simply sets \macro\_listingcommands{} to \macro\_{\it language}{\tt _listingcommands}.
+
+\subsubsection{Usage}
+
+Now notice an issue: \macro\replace{} (and \macro\replacefromto) both expand their arguments.
+What if the arguments expand to invalid code?
+This is the purpose of \macro\_macrocallmanager{} and two basic macros: \macro\call{} and \macro\mlcall.
+They are set to \macro\relax{} so they aren't expanded in \macro\replace{} and friends, and \macro\_macrocallmanager{} sets them to their proper definitions:
+
+\macroexp{\call <macro>{<parameters>}{<last>}}
+Simply calls \getmacrousageB{\macro <parameters>{<last>}}.
+\emacroexp
+
+\macroexp{\mlcall <macro>{<parameters>}{<last>}}
+If {\it last} is equal to \inlinecode|x1\n\n x2\n\n...\n\n XN|, expands to \inlinecode|\call <macro>{<parameters>}{x1}\n\n...\n\n\call <macro>{<parameters>}{xN}|.
+\emacroexp
+
+Since \macro\call{} and friends are redefined only after \macro\_commandexecute{} is executed, to call a macro without it expanding you can use them.
+For example, to replace {\tt int} with {\tt int} colored red, you can use \inlinecode|\replace{\w int\w}{\w\call localcolor{{red}}{int}\w}|.
+
+Two shortcuts are provided: \macro\c{} and \macro\mc{}.
+\getmacrousageB{\c{<color>}{<text>}} will set the color of {\it text} (in a \macro\call), and \getmacrousageB{\mc{<color>}{<text>}} will also set the color but in a \macro\mlcall.
+
+Now what is \macro\replacefromto?
+
+\macroexp{\replacefromto <macro>{<start>}{<end>}{<replacement>}}
+Replacement is a macro definition with a single pattern (e.g. \inlinecode|{#1}|).
+\macro\replacefrom{} matches \getmacrousage{<start>#1<end>} in the expansion of {\it macro} and replaces it with {\it replacement}, this redefines {\it macro}.
+
+So for example if \macro\X{} expands to \inlinecode|(.)(.)|, \inlinecode|\replacefrom\X(){[#1]}| will redefine \macro\X{} to be \inlinecode|[.][.]|.
+\emacroexp
+
+\subsubsection{An Example}
+
+\pdftoolbox{} provides syntax highlight for the C language in {\tt ptb-syntax-C.tex}, whose content is:
+
+\listfile{ptb-syntax-C}
+
+Let us now explain each part of the file:
+
+\listfile{ptb-syntax-C}[1-9]
+
+This defines two new token lists, \macro\lstCcolor{} (for use within the file), and \macro\_C_listingcommands,
+which as explained previously is what sets the listing commands for the {\tt C} syntax.
+\macro\lstCcolor{} has C-specific colors, changing it allows you to change the colors of C-specific
+highlighting.
+Note that all changes in this file must be global.
+
+\listfile{ptb-syntax-C}[11-12]
+
+Begins the definition of \macro\_C_listing_commands{} by first defining C-specific colors.
+
+\listfile{ptb-syntax-C}[13-17]
+
+\benum
+    \item Swaps \macro\"{} with \inlinecode|{\"}|, so that the quotation in \macro\"{} (backslash-quote) is
+        not replaced by the following lines.
+    \item Colors between \inlinecode|"| and \inlinecode|"| with a multiline coloring of color {\tt quote}.
+    \item Colors between \inlinecode|//| and \macro\n{} (the end of the line) with the color of a comment.
+        Notice that it adds back in the \macro\n; otherwise this will mess up the line-reading.
+    \item Replaces between \inlinecode|/*| and \inlinecode|*/| with a multline coloring of color
+            {\tt lst-comment}.
+    \item Replaces from \inlinecode|#| to the end of line with a coloring of color {\tt preprocessor}.
+        (Again adding back in \macro\n.)
+\eenum
+
+\listfile{ptb-syntax-C}[18-22]
+
+Sets replacement for \TeX-reserved characters (open and close curly braces, percent).
+
+\listfile{ptb-syntax-C}[23-25]
+
+Replaces non-character letters with a coloring and word break (since, e.g. {\tt x.y} is not a single word).
+Note the use of \gotomacro\map.
+
+\listfile{ptb-syntax-C}[26-32]
+
+Replaces keywords with color {\tt keyword}.
+
+\listfile{ptb-syntax-C}[33-34]
+
+Colors numbers with {\tt lst-number}.
+
+\subsubsection{Changing the Output}
+
+\pdftoolbox{} outputs the listing in colorboxes according to \macro\syntaxoutbox.
+The default is just as follows:
+
+\listfile{ptb-listings}[121-127]
+
+This just places the content in a colored box of color {\tt lst-bg} with a text color of {\tt lst-fg}, along with placing a header and footer.
+We must also set \macro\syntaxoutboxbuf, which is the total amount of vertical buffering added by
+\macro\syntaxoutbox{} to its contents.
+This is done by \macro\syntaxoutboxsetbuf{} which must define a macro \macro\syntaxoutboxbuf{} to be the total amount of extra vertical space \macro\syntaxoutbox{} adds.
+
+But we can also do, for example:
+
+\blisting
+\letcolor{lst-stroke}{lst-fg}
+\def\syntaxoutbox#1{%
+    \hbox{\curvedcolorbox{lst-stroke}{lst-bg}{\_setcolor{}{lst-fg}#1}{-.-.-.-.}}%
+}
+\def\syntaxoutboxsetbuf{%
+    \edef\syntaxoutboxbuf{\the\dimexpr\_actual_curve_buf * 2\relax}%
+}
+\elisting
+
+\bgroup
+\letcolor{lst-stroke}{lst-fg}
+\def\syntaxoutbox#1{%
+    \hbox{\curvedcolorbox{lst-stroke}{lst-bg}{\_setcolor{}{lst-fg}#1}{-.-.-.-.}}%
+}
+\def\syntaxoutboxsetbuf{%
+    \edef\syntaxoutboxbuf{\the\dimexpr\_actual_curve_buf * 2\relax}%
+}
+
+Now listings will have a curve colored box:
+
+\blisting
+\def\X#1#2{%
+    \ifnum#1>0 %
+        {\X{\numexpr#1-1\relax}{#2}}^{\X{\numexpr#1-1\relax}{#2}}_{\X{\numexpr#1-1\relax}{#2}}%
+    \else%
+        \vcenter{\hbox{$\m at th\scriptscriptstyle#2$}}%
+    \fi%
+}
+
+$$\X{4}\blacksquare$$
+\elisting
+\egroup
+
+(The code outputs the following by the way:)
+
+\bgroup\catcode`_=8
+\def\X#1#2{%
+    \ifnum#1>0 %
+        {\X{\numexpr#1-1\relax}{#2}}^{\X{\numexpr#1-1\relax}{#2}}_{\X{\numexpr#1-1\relax}{#2}}%
+    \else%
+        \vcenter{\hbox{$\m at th\scriptscriptstyle#2$}}%
+    \fi%
+}
+
+$$\X{4}\blacksquare$$
+\egroup
+
+You can also alter how each line is output.
+This is done by \anchormacro\_syntax_linemanager, which takes a single input and outputs the line to print in the listing.
+The default definition is
+\listfile{ptb-listings}[212-229]
+But a simpler definition would be just
+\blisting
+\def\_syntax_linemanager#1{{
+    \def\_regA{#1}%
+    \def\_regB{\w}%
+    \unless\ifx\_regA\_regB%
+        \hbox{#1}%
+    \fi%
+}}
+\elisting
+Which will simply output the line as-is; without line numbering or splitting over multiple lines.
+The reason for the conditional is because \pdftoolbox{} will pass an empty line containing only \macro\w{} to \macro\_syntax_linemanager{} at the last line (this is the only line to do so).
+
+\bnote
+The passing of \macro\w{} as the final line was unintended behavior, but it could be useful and was therefore kept.
+\eppbox
+

Modified: trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/preamble.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/preamble.tex	2025-04-02 20:18:49 UTC (rev 74831)
+++ trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/preamble.tex	2025-04-02 20:19:11 UTC (rev 74832)
@@ -6,6 +6,8 @@
 
 \def\LaTeX{L\kern-.36em{\setbox0=\hbox{T}\vbox to\ht0{\hbox{\sevenrm A}\vss}}\kern-.15em\TeX}
 
+\def\_setupverb{\setupverb\catcode`\ =10\relax}
+
 \chardef\fslash=`\/
 {\catcode`\^^M=\active%
 \gdef\begincode{%
@@ -32,21 +34,9 @@
     \egroup%
 }
 
-\def\setupverb{%
-    \catcode`\ =\active%
-    \catcode`\{=12%
-    \catcode`\}=12%
-    \catcode`\/=0%
-    \catcode`\$=12%
-    \catcode`\\=12%
-    \catcode`\#=12%
-    \catcode`\%=12%
-    \catcode`\_=12%
-}
-
 \def\inlinecode#1{
     \bgroup%
-    \setupverb%
+    \_setupverb%
     \catcode`#1=2%
     \tt%
 }
@@ -65,6 +55,7 @@
     \catcode`\\=12%
     \catcode`\<=\active%
     \catcode`\^^M=\active%
+    \catcode`\#=12\relax%
     \def<##1>{$\langle${\it ##1}$\rangle$}%
     \def^^M{\crcr}%
     \ifx.#1.%
@@ -93,5 +84,5 @@
 
 \def\gotomacro#1{\gotoanchor{\string#1}{{\tt\string#1}}}
 
+\def\displaycode#1{\centerline{\vbox{\def\cr{\crcr\relax}\halign{\hfil\gdef\@@{##}{\_setupverb\tt\scantokens\_xp\_xp\_xp{\_xp\_gobble\@@}}: &\_gobble{##}\@@\hfil\crcr\relax#1\crcr}}}}
 
-\def\displaycode#1{\centerline{\vbox{\def\cr{\crcr\relax}\halign{\hfil\gdef\@@{##}{\setupverb\tt\scantokens\_xp\_xp\_xp{\_xp\_gobble\@@}}: &\_gobble{##}\@@\hfil\crcr\relax#1\crcr}}}}

Added: trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/versions.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/versions.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/versions.tex	2025-04-02 20:19:11 UTC (rev 74832)
@@ -0,0 +1,37 @@
+\subsection{pdfToolbox v0.1} \anchor{v0.1}
+
+First version of \pdftoolbox.
+
+\subsubsection{Known Bugs}
+
+\blist
+    \item \macro\url{} inserts invalid characters into the PDF.
+        Some readers can still read the PDF, others won't.
+        Fixed in \gotoanchor{v0.2}{version 0.2}.
+\elist
+
+\subsection{pdfToolbox v0.2} \anchor{v0.2}
+
+Bug fixes and added features.
+
+\subsubsection{What's New?}
+
+\blist
+    \item Fixed bug caused \macro\url{} to create malformed PDF files.
+    \item Added listings.
+    \item Changed the method of creating section headers, and their corresponding toc line (see \gotoanchor{table-of-contents}), more work is now done by \gotomacro\settocdepthformat{} and \gotomacro\addtoccontent.
+        (This is also a breaking change.)
+\elist
+
+\subsubsection{What's Broken}
+
+\pdftoolbox{} v0.2 adds breaking changes to the toolbox.
+These changes will render files created with previous versions un-compilable.
+\blist
+    \item \macro\linkborder{} no longer wraps its ouput in \inlinecode|attr {...}|, which is necessary for anchors;
+        now \macro\_gotoanchor{} adds this wrapping.
+    \item \macro\_splitcontentbox{} now requires more arguments which allows for more customization (for more information, see \gotomacro\_splitcontentbox).
+    \item Changed the method of creating section headers, and their corresponding toc line (see the section on \gotoanchor{table-of-contents}{tables of content}),
+        more work is now done by \gotomacro\settocdepthformat{} and \gotomacro\addtoccontent.
+\elist
+


Property changes on: trunk/Master/texmf-dist/doc/latex/pdftoolbox/Documentation/versions.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/latex/pdftoolbox/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/pdftoolbox/README.md	2025-04-02 20:18:49 UTC (rev 74831)
+++ trunk/Master/texmf-dist/doc/latex/pdftoolbox/README.md	2025-04-02 20:19:11 UTC (rev 74832)
@@ -1,4 +1,4 @@
-# pdfToolbox v0.1
+# pdfToolbox v0.2
 ## Ari Feiglin -- ari.feiglin at gmail.com
 
 pdfToolbox is a toolbox of various "subpackages" intended for programming and creating beautiful plain-pdfTeX documents.
@@ -10,5 +10,7 @@
 pdfToolbox currently on works with pdfTeX.
 It is not compatible with any form of LaTeX, and currently does not work with XeTeX or LuaTeX (though hopefully LuaTeX support will be added in the future).
 
+Documentation can be found in the pdfToolbox/Documentation/pdfToolbox-docs.pdf PDF file.
+
 pdfToolbox is free to use under the MIT license.
 

Modified: trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfDstruct/ptb-hyperlinks.tex
===================================================================
--- trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfDstruct/ptb-hyperlinks.tex	2025-04-02 20:18:49 UTC (rev 74831)
+++ trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfDstruct/ptb-hyperlinks.tex	2025-04-02 20:19:11 UTC (rev 74832)
@@ -3,12 +3,12 @@
 
 \def\linkborder#1{%
     \ifx^#1^%
-        attr {/C [\default at border] /Border [0 0 \default at border@wd]}%
+        /C [\default at border] /Border [0 0 \default at border@wd]%
     \else\ifcsname #1 at border\endcsname%
         \_xp\ifx\csname #1 at border\endcsname\empty%
-            attr {/Border [0 0 0]}%
+            /Border [0 0 0]%
         \else%
-            attr {/C [\csname #1 at border\endcsname] /Border [0 0 \csname #1 at border@wd\endcsname]}%
+            /C [\csname #1 at border\endcsname] /Border [0 0 \csname #1 at border@wd\endcsname]%
         \fi%
     \fi\fi%
 }
@@ -28,7 +28,7 @@
     \setbox0=\hbox{#3}%
     \quitvmode%
     \pdfstartlink height \dimexpr\ht0 + \@anchorbuf\relax depth \dimexpr\dp0 + \@anchorbuf\relax
-        \linkborder{#1} goto name{#1:#2}\relax{\kern\@anchorwbuf\relax#3\kern\@anchorwbuf\relax}\pdfendlink%
+        attr {\linkborder{#1}} goto name{#1:#2}\relax{\kern\@anchorwbuf\relax#3\kern\@anchorwbuf\relax}\pdfendlink%
 }}
 
 \def\gotoanchor{\_ifnextchar[ {\_gotoanchor}{\_gotoanchor[]}}

Modified: trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfDstruct/ptb-lists.tex
===================================================================
--- trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfDstruct/ptb-lists.tex	2025-04-02 20:18:49 UTC (rev 74831)
+++ trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfDstruct/ptb-lists.tex	2025-04-02 20:19:11 UTC (rev 74832)
@@ -24,8 +24,11 @@
 \createcounter{enum count}
 \createcounter{enum depth}
 \_xp\def\csname enumstyle1\endcsname#1{{\bf(#1)}}
+\_xp\setmacrotolen\_xp{\csname enumstyle1 at wd\endcsname}{\csname enumstyle1\endcsname{20}}
 \_xp\def\csname enumstyle2\endcsname#1{{\bf(\romannumeral#1)}}
+\_xp\setmacrotolen\csname enumstyle2 at wd\endcsname{\csname enumstyle2\endcsname{20}}
 \_xp\def\csname enumstyle3\endcsname#1{{\bf(\_numtoletter{#1})}}
+\_xp\setmacrotolen\csname enumstyle3 at wd\endcsname{\csname enumstyle3\endcsname{20}}
 \def\enumindent{.25cm}
 \def\benum{\bgroup\par%
     \setcounter{enum count}{0}%
@@ -32,7 +35,10 @@
     \advancecounter{enum depth}{1}%
     \def\item{%
         \par\egroup\advancecounter{enum count}{1}\bgroup\medskip%
-        \setbox0=\hbox{\csname enumstyle\the\counter{enum depth}\endcsname{\the\counter{enum count}}\quad}%
+        \setbox0=\hbox{\hbox to\csname enumstyle\the\counter{enum depth}@wd\endcsname%
+            {\hss\csname enumstyle\the\counter{enum depth}\endcsname{\the\counter{enum count}}}%
+            \quad%
+        }%
         \advance\leftskip by \dimexpr\wd0+\enumindent\relax\noindent\kern-\wd0\box0%
     }%
     \def\mtext{%

Modified: trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfDstruct/ptb-tableofcontents.tex
===================================================================
--- trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfDstruct/ptb-tableofcontents.tex	2025-04-02 20:18:49 UTC (rev 74831)
+++ trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfDstruct/ptb-tableofcontents.tex	2025-04-02 20:19:11 UTC (rev 74832)
@@ -70,13 +70,6 @@
 
 \def\dotfill{\xleaders\hbox{$\m at th\mkern1.5mu\hbox{.}\mkern1.5mu$}\hfill}
 
-\def\setmacrotolen#1#2{{%
-    \ifx\undefined#1%
-        \setbox0=\hbox{#2}%
-        \xdef#1{\the\wd0}%
-    \fi%
-}}
-
 \def\settomax#1#2{{%
     \setbox0=\hbox{#2}%
     \ifdim\wd0>#1 %

Added: trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/listingcommands/ptb-syntax-C.tex
===================================================================
--- trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/listingcommands/ptb-syntax-C.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/listingcommands/ptb-syntax-C.tex	2025-04-02 20:19:11 UTC (rev 74832)
@@ -0,0 +1,35 @@
+\global\newtoks\lstCcolors
+\global\newtoks\_C_listingcommands
+
+\global\lstCcolors={
+    \definecolor{preprocessor}{rgb}{0 0 1}
+    \definecolor{special char}{rgb}{.7 0 .7}
+    \definecolor{keyword}{rgb}{1 0 0}
+    \definecolor{quote}{rgb}{.6 .6 0}
+}
+
+\global\_C_listingcommands={
+    \the\lstCcolors
+    \replace {\string\"} {{\string\"}}
+    \replacefromto "" {\mc{quote}{"#1"}}
+    \replacefromto {//}\n {\c{lst-comment}{//#1}\n}
+    \replacefromto {/*}{*/} {\mc{lst-comment}{/*#1*/}}
+    \replacefromto {\string#}\n {\c{preprocessor}{\string##1}\n}
+    \bgroup\lccode`?=`\{\lccode`!=`\}\lccode`.=`\%\lowercase{\egroup
+        \replace ?{\w\c{special char}{?}\w}%
+        \replace !{\w\c{special char}{!}\w}%
+        \replace .{\w\c{special char}{.}\w}%
+    }
+    \edef\_regA{{!@\string$\string^\string&*()-+=[];:,.<>/}}%$
+    \def\_regB#1{\replace{#1}{\w\c{special char}{#1}\w}}
+    \_xp\map\_xp\_regB\_regA
+    \def\_regB#1{\replace{\w#1\w}{\w\c{keyword}{#1}\w}}
+    \map\_regB{%
+        {auto}{bool}{break}{case}{char}{const}{continue}{default}{do}{double}{else}{enum}%
+        {extern}{false}{float}{for}{goto}{if}{inline}{int}{long}{NULL}{register}{restrict}%
+        {return}{short}{signed}{sizeof}{static}{struct}{switch}{true}{typedef}{union}%
+        {unsigned}{void}{volatile}{while}%
+    }
+    \def\_regB#1{\replace{\w#1}{\w\c{lst-number}{#1}\w}}
+    \map\_regB{0123456789}
+}


Property changes on: trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/listingcommands/ptb-syntax-C.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/listingcommands/ptb-syntax-TeX.tex
===================================================================
--- trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/listingcommands/ptb-syntax-TeX.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/listingcommands/ptb-syntax-TeX.tex	2025-04-02 20:19:11 UTC (rev 74832)
@@ -0,0 +1,28 @@
+\global\newtoks\lstTeXcolors
+\global\newtoks\_TeX_listingcommands
+
+\global\lstTeXcolors={
+    \definecolor{special char}{rgb}{.7 0 .4}
+    \definecolor{macro}{rgb}{1 0 0}
+    \definecolor{math}{rgb}{.7 0 .4}
+    \definecolor{code char}{rgb}{0 .6 0}
+}
+
+\global\_TeX_listingcommands={
+    \the\lstTeXcolors
+    \bgroup\lccode`?=`\%\lowercase{\egroup
+        \replace {\_mstrip\\?}{\w\c{special char}{\_mstrip\\?}\w}
+        \replacefromto ?\n{\w\c{lst-comment}{?#1}\w\n}%
+    }
+    \replace {\string$}{\w\c{math}{\string$}\w}
+    \replace {\string&}{\w\c{special char}{\string&}\w}
+    \replace {\string#}{\w\c{special char}{\string#}\w}
+    \bgroup\lccode`?=`\{\lccode`!=`\}
+    \lowercase{\egroup
+        \replace ?{\w\c{special char}{?}\w}%
+        \replace !{\w\c{special char}{!}\w}%
+    }
+    \replacefromto {\string^\string^}\w {\c{code char}{\string^\string^#1}\w}
+    \replacefromto {\_mstrip\\}\w{\c{macro}{\_mstrip\\#1}\w}
+}
+


Property changes on: trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/listingcommands/ptb-syntax-TeX.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/ptb-colorboxes.tex
===================================================================
--- trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/ptb-colorboxes.tex	2025-04-02 20:18:49 UTC (rev 74831)
+++ trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/ptb-colorboxes.tex	2025-04-02 20:19:11 UTC (rev 74832)
@@ -15,12 +15,19 @@
 }
 
 \newif\if_recheck
+\newif\if_lastbox
+\newif\if_firstbox
 \def\_getsplitdim#1{%
     \ifdim\dimexpr\_spaceleft-#1\relax>\ht\_contentbox%
         \edef\_splitdim{\the\ht\_contentbox}%
         \_recheckfalse%
+        \_lastboxtrue%
     \else%
-        \ifdim\dimexpr\_spaceleft-#1\relax<\z@%
+        \_lastboxfalse%
+        \ifdim\dimexpr\_spaceleft-#1\relax>\z@%
+            \edef\_splitdim{\the\dimexpr\_spaceleft-#1\relax}%
+            \_recheckfalse%
+        \else
             \if_recheck%
                 \vfil\break\vfilneg%
                 \_recheckfalse%
@@ -29,9 +36,6 @@
                 \_rechecktrue%
             \fi%
             \_getsplitdim{#1}%
-        \else%
-            \edef\_splitdim{\the\dimexpr\_spaceleft-#1\relax}%
-            \_recheckfalse%
         \fi%
     \fi%
 }
@@ -39,25 +43,60 @@
 %   Splits the content box to fit into pages.
 %   #1: Total vertical buffer
 %   #2: Output routine for new box
-\def\_splitcontentbox#1#2{{%
-    \splittopskip=\z@%
-    \boxmaxdepth=\z@%
-    \offinterlineskip%
+\def\__splitcontentbox#1#2#3#4#5{
     \unless\ifvoid\_contentbox%
         \_getsplitdim{#1}%
         \setbox\_splitbox = \vsplit\_contentbox to\_splitdim\relax%
-        \setbox0=\vbox{#2}%
+        \setbox0=\vbox{%
+            \if_firstbox%
+                \if_lastbox%
+                    #2%
+                \else%
+                    #3%
+                \fi%
+            \else%
+                \if_lastbox%
+                    #5%
+                \else%
+                    #4%
+                \fi%
+            \fi%
+        }%
         \vbox to\z@{\copy0\vss}%
         \kern\ht0\relax\penalty\z@%
-        \_splitcontentbox{#1}{#2}%
+        \_firstboxfalse%
+        \__splitcontentbox{#1}{#2}{#3}{#4}{#5}%
     \fi%
+}
+\def\_splitcontentbox#1#2#3#4#5{{%
+    \splittopskip=\z@%
+    \boxmaxdepth=\z@%
+    \offinterlineskip%
+    \_firstboxtrue%
+    \__splitcontentbox{#1}{#2}{#3}{#4}{#5}%
 }}
 
 \def\_ppbuf{0pt}
 \def\_bppbox#1#2#3[#4]{%
-    \def\_colorcontentbox{%
+    \_getdotsnlines#4\_nul%
+    \def\_colorcontentboxT{%
         \hbox{\curvedcolorbox{#2}{#1}{\_setcolor{}{#3}\box\_splitbox}{#4}}%
-    }
+    }%
+    \def\_colorcontentboxS{%
+        \hbox{\curvedcolorbox{#2}{#1}{\_setcolor{}{#3}\box\_splitbox}%
+            {_X\_linel\_dottl\_linet\_dottr\_liner X}%
+        }%
+    }%
+    \def\_colorcontentboxM{%
+        \hbox{\curvedcolorbox{#2}{#1}{\_setcolor{}{#3}\box\_splitbox}%
+            {_X\_linel X_X\_liner X}%
+        }%
+    }%
+    \def\_colorcontentboxE{%
+        \hbox{\curvedcolorbox{#2}{#1}{\_setcolor{}{#3}\box\_splitbox}%
+            {\_lineb\_dotbl\_linel X_X\_liner\_dotbr}%
+        }%
+    }%
     \par%
     \kern\_ppbuf\relax%
     \null\par% Move the kern from recent contributions to MVL
@@ -66,12 +105,13 @@
 }
 
 \def\bppbox#1#2#3{%
-    \_ifnextchar[ {\_bppbox{#1}{#2}{#3}}{\_bppbox{#1}{#2}{#3}[....]}%
+    \_ifnextchar[ {\_bppbox{#1}{#2}{#3}}{\_bppbox{#1}{#2}{#3}[-.-.-.-.]}%
 }
 
 \def\eppbox{%
     \egroup%
-    \_splitcontentbox{2\_actual_curve_buf}\_colorcontentbox%
+    \_splitcontentbox{2\_actual_curve_buf}%
+        \_colorcontentboxT\_colorcontentboxS\_colorcontentboxM\_colorcontentboxE%
     \vskip\_ppbuf\relax%
 }
 
@@ -91,7 +131,8 @@
 }
 \def\elinedppbox{%
     \egroup%
-    \_splitcontentbox{2\dimexpr\pprulevbuf\relax}\_colorcontentbox%
+    \_splitcontentbox{2\dimexpr\pprulevbuf\relax}%
+        \_colorcontentbox\_colorcontentbox\_colorcontentbox\_colorcontentbox%
     \vskip\_ppbuf\relax%
 }
 

Modified: trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/ptb-colors.tex
===================================================================
--- trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/ptb-colors.tex	2025-04-02 20:18:49 UTC (rev 74831)
+++ trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/ptb-colors.tex	2025-04-02 20:19:11 UTC (rev 74832)
@@ -120,6 +120,84 @@
     #1 \_nopt{#2pt-#5pt} l
 }
 
+\def\_blcorner#1#2#3#4#5#6#7#8#9{%
+    \if.#9
+        \_nopt{#5} \_nopt{#2} m
+    \else
+        \_nopt{#8} \_nopt{#2} m
+    \fi
+    \if-#7
+        \if.#6
+            #1 \_nopt{#2} l
+            \_nopt{#3} \_nopt{#2} \_nopt{#3} #4 v
+        \else
+            \_nopt{#3} \_nopt{#2} l
+        \fi
+    \else
+        #1 \_nopt{#2} m
+        \if.#6
+            #1 \_nopt{#2} l
+            \_nopt{#3} \_nopt{#2} \_nopt{#3} #4 v
+        \else
+            \_nopt{#3} \_nopt{#2} m
+        \fi
+    \fi
+}
+
+\def\_tlcorner#1#2#3#4#5#6{%
+    \if-#6
+        \if.#5
+            \_nopt{#1} \_nopt{#2} l
+            \_nopt{#1} \_nopt{#3} #4 \_nopt{#3} v
+        \else
+            \_nopt{#1} \_nopt{#3} l
+        \fi
+    \else
+        \if.#5
+            \_nopt{#1} \_nopt{#2} m
+            \_nopt{#1} \_nopt{#3} #4 \_nopt{#3} v
+        \else
+            \_nopt{#1} \_nopt{#3} m
+        \fi
+    \fi
+}
+
+\def\_trcorner#1#2#3#4#5#6{%
+    \if-#6
+        \if.#5
+            \_nopt{#1} \_nopt{#2} l
+            \_nopt{#3} \_nopt{#2} \_nopt{#3} \_nopt{#4} v
+        \else
+            \_nopt{#3} \_nopt{#2} l
+        \fi
+    \else
+        \if.#5
+            \_nopt{#1} \_nopt{#2} m
+            \_nopt{#3} \_nopt{#2} \_nopt{#3} \_nopt{#4} v
+        \else
+            \_nopt{#3} \_nopt{#2} m
+        \fi
+    \fi
+}
+
+\def\_brcorner#1#2#3#4#5#6{%
+    \if-#6
+        \if.#5
+            \_nopt{#1} #2 l
+            \_nopt{#1} \_nopt{#3} \_nopt{#4} \_nopt{#3} v
+        \else
+            \_nopt{#1} \_nopt{#3} l
+        \fi
+    \else
+        \if.#5
+            \_nopt{#1} #2 m
+            \_nopt{#1} \_nopt{#3} \_nopt{#4} \_nopt{#3} v
+        \else
+            \_nopt{#1} \_nopt{#3} m
+        \fi
+    \fi
+}
+
 %   #1: origin x
 %   #2: origin y
 %   #3: width
@@ -154,6 +232,32 @@
     %#1 \_nopt{#2pt-#5pt} l
 }
 
+\def\_curvedbox#1#2#3#4#5{%
+    \_blcorner{#1}{#2pt-#5pt}{#1pt-#5pt}{#2}{#1pt+#3pt}\_dotbl\_lineb{#1pt+#3pt+#5pt}\_dotbr\_space
+    \_tlcorner{#1pt-#5pt}{#2pt+#4pt}{#2pt+#4pt+#5pt}{#1}\_dottl\_linel\_space
+    \_trcorner{#1pt+#3pt}{#2pt+#4pt+#5pt}{#1pt+#3pt+#5pt}{#2pt+#4pt}\_dottr\_linet\_space
+    \_brcorner{#1pt+#3pt+#5pt}{#2}{#2pt-#5pt}{#1pt+#3pt}\_dotbr\_liner\_space
+}
+
+\def\_curvedboxbg#1#2#3#4#5{%
+    \_blcorner{#1}{#2pt-#5pt}{#1pt-#5pt}{#2}{#1pt+#3pt}\_dotbl-{#1pt+#3pt+#5pt}\_dotbr\_space
+    \_tlcorner{#1pt-#5pt}{#2pt+#4pt}{#2pt+#4pt+#5pt}{#1}\_dottl-\_space
+    \_trcorner{#1pt+#3pt}{#2pt+#4pt+#5pt}{#1pt+#3pt+#5pt}{#2pt+#4pt}\_dottr-\_space
+    \_brcorner{#1pt+#3pt+#5pt}{#2}{#2pt-#5pt}{#1pt+#3pt}\_dotbr-\_space
+}
+
+
+\def\_getdotsnlines#1#2#3#4#5#6#7#8\_nul{%
+    \edef\_lineb{#1}%
+    \edef\_dotbl{#2}%
+    \edef\_linel{#3}%
+    \edef\_dottl{#4}%
+    \edef\_linet{#5}%
+    \edef\_dottr{#6}%
+    \edef\_liner{#7}%
+    \edef\_dotbr{#8}%
+}
+
 \def\curvebuffer{4pt}
 \def\curvewidth{1pt}
 \def\_actual_curve_buf{\dimexpr\curvebuffer + \curvewidth\relax}
@@ -162,6 +266,7 @@
 \def\shadowyoff{-3pt}
 
 \long\def\curvedcolorbox#1#2#3#4{{%
+    \_xp\_getdotsnlines\expanded{#4}\_nul%
     \setbox\_colorbox=\hbox{{#3}}%
     \hbox{%
         \lower\dimexpr\curvebuffer + \curvewidth + \dp\_colorbox\relax%
@@ -173,11 +278,11 @@
                     q \_pdf_pt_scale,
                     \_getcolor{}{\boxshadowcolor}
                     \_nopt{\curvewidth} w
-                    \_curvedbox{\_nopt{\shadowxoff}}{\_nopt{-\dp\_colorbox+\shadowyoff}}{\_nopt{\wd\_colorbox}}{\_nopt{\ht\_colorbox+\dp\_colorbox}}{\_nopt{\curvebuffer}}#4
+                    \_curvedboxbg{\_nopt{\shadowxoff}}{\_nopt{-\dp\_colorbox+\shadowyoff}}{\_nopt{\wd\_colorbox}}{\_nopt{\ht\_colorbox+\dp\_colorbox}}{\_nopt{\curvebuffer}}\_space%#4
                     b
                     \_getcolor{bg}{#2}
                     \_getcolor{fg}{#1}
-                    \_curvedbox{0}{\_nopt{-\dp\_colorbox}}{\_nopt{\wd\_colorbox}}{\_nopt{\ht\_colorbox+\dp\_colorbox}}{\_nopt{\curvebuffer}}#4
+                    \_curvedboxbg{0}{\_nopt{-\dp\_colorbox}}{\_nopt{\wd\_colorbox}}{\_nopt{\ht\_colorbox+\dp\_colorbox}}{\_nopt{\curvebuffer}}\_space%#4
                     W f
                 }%
                 \rlap{\copy\_colorbox}%
@@ -187,8 +292,8 @@
                     \_pdf_pt_scale,
                     \_nopt{\curvewidth} w
                     \_getcolor{fg}{#1}
-                    \_curvedbox{0}{\_nopt{-\dp\_colorbox}}{\_nopt{\wd\_colorbox}}{\_nopt{\ht\_colorbox+\dp\_colorbox}}{\_nopt{\curvebuffer}}#4
-                    s
+                    \_curvedbox{0}{\_nopt{-\dp\_colorbox}}{\_nopt{\wd\_colorbox}}{\_nopt{\ht\_colorbox+\dp\_colorbox}}{\_nopt{\curvebuffer}}\_space%#4
+                    S
                     Q
                 }%
                 \kern\wd\_colorbox%

Added: trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/ptb-listings.tex
===================================================================
--- trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/ptb-listings.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/ptb-listings.tex	2025-04-02 20:19:11 UTC (rev 74832)
@@ -0,0 +1,254 @@
+\input ptb-utils
+
+\_checkloaded{listings}
+
+\input ptb-colors
+\input ptb-colorboxes
+\input ptb-fonts
+
+\def\setupverb{%
+    \def\do##1{\catcode`##1=12\relax}%
+    \dospecials%
+    \catcode`\^^M=12\relax%
+}
+
+\letcolor{lst-fg}{black}
+\definecolor{lst-bg}{rgb}{.8 .9 .9}
+
+\newtoks\_listingcommands
+\newtoks\_commandcapture
+\newtoks\_commandexecute
+\newtoks\_macrocallmanager
+\newtoks\lstheader
+\newtoks\lstfooter
+\newtoks\everylisting
+\newcount\lstlinenum \lstlinenum=0
+\newdimen\lstcodelinewd
+\everylisting={}
+
+\def\lstlineskip{2pt}
+\def\lstvbuf{.25cm}
+
+\def\_setuplstlines{%
+    \parindent=\z@%
+    \baselineskip=-\maxdimen%
+    \lineskip=\lstlineskip\relax%
+    \lineskiplimit=\maxdimen%
+}
+
+\def\lstlinenumbuf{.25cm}
+
+\def\blisting{\bgroup\_getline\_blisting}
+
+\def\_blisting#1{\the\everylisting#1\relax\setupverb\__blisting}
+
+{\catcode`\^^M=12
+\_xp\gdef\_xp\__blisting\_xp#\_xp1\expanded{\_mstrip\\}elisting#2^^M{%
+    \_setuplstlines%
+    \the\_commandcapture%
+    \the\_listingcommands%
+    \def\_code{\n\w#1\n}%
+    \setuplstcodelinewd%
+    \def\_execute##1{##1\_code}%
+    \the\_commandexecute%
+    \the\_macrocallmanager%
+    \edef\_code{\_code}%
+    \def\n##1\n{\_syntax_linemanager{##1}}%
+    \def\_colorcontentbox{\syntaxoutbox{\box\_splitbox}}%
+    \syntaxoutboxsetbuf%
+    \setbox\_contentbox=\vbox{\_code}%
+    \par\vskip\lstvbuf\relax%
+    \null\par%
+    \_splitcontentbox\syntaxoutboxbuf\_colorcontentbox\_colorcontentbox\_colorcontentbox\_colorcontentbox%
+    \vskip\lstvbuf\relax%
+    \egroup%
+}}
+
+{\catcode`\^^M=12
+\gdef\_listfile#1[#2-#3]{%
+    \bgroup%
+    \lstheader={\hfil\lstfileheaderfontset#1}%
+    \lstfooter={}%
+    \the\everylisting%
+    \setupverb%
+    \immediate\openin\_PTBread{#1}%
+    \the\_commandcapture%
+    \the\_listingcommands%
+    \def\_code{\n\w}%
+    \lstlinenum=\z@%
+    \def\_begin{#2}%
+    \def\_finish{#3}%
+    \ifx\_begin\_empty%
+        \def\_begin{1}%
+    \fi%
+    \ifx\_finish\_empty%
+        \def\_finish{999999}%
+    \fi%
+    \let\_stop=\_empty%
+    \loop%
+        \advance\lstlinenum by 1\relax%
+        \immediate\read\_PTBread to\_codeline%
+        \ifeof\_PTBread%
+            \let\_stop=\_nul%
+        \else\ifnum\lstlinenum>\numexpr\_begin-1\relax%
+        \ifnum\lstlinenum<\numexpr\_finish+1\relax%
+            \edef\_code{\_code\_codeline}%
+        \else\let\_stop=\_nul\fi\fi\fi%
+        \unless\ifx\_stop\_nul%
+    \repeat%
+    \immediate\closein\_PTBread%
+    \edef\_code{\_code\n}%
+    \setuplstcodelinewd%
+    \def\_execute##1{##1\_code}%
+    \the\_commandexecute%
+    \the\_macrocallmanager%
+    \lstlinenum=\numexpr\_begin-1\relax%
+    \edef\_code{\_code}%
+    \def\n##1\n{\_syntax_linemanager{##1}}%
+    \def\_colorcontentbox{\syntaxoutbox{\box\_splitbox}}%
+    \syntaxoutboxsetbuf%
+    \setbox\_contentbox=\vbox{\_code}%
+    \par\vskip\lstvbuf\relax%
+    \null\par%
+    \_splitcontentbox\syntaxoutboxbuf\_colorcontentbox\_colorcontentbox\_colorcontentbox\_colorcontentbox%
+    \vskip\lstvbuf\relax%
+    \egroup%
+}}
+
+\def\setuplstcodelinewd{%
+    \lstcodelinewd=\dimexpr\hsize - \_lstlinenumwd - \lstlinenumbuf\relax%
+}
+
+\def\listfile#1{\_ifnextchar[ {\_listfile{#1}}{\_listfile{#1}[-]}}
+
+\def\lstfileheaderfontset{\setfontandscale{tt}{8pt}}
+
+\def\syntaxoutbox#1{%
+    \vbox{\offinterlineskip%
+        \hbox{\makelstheader}%
+        \hbox{\coloredbox{lst-bg}{\color{lst-fg}#1}}%
+        \hbox{\makelstfooter}%
+    }
+}
+\def\syntaxoutboxsetbuf{{%
+    \setbox0=\hbox{\makelstheader}%
+    \setbox1=\hbox{\makelstfooter}%
+    \xdef\syntaxoutboxbuf{\the\dimexpr\bufferwidth * 2 + \ht0 + \dp0 + \ht1 + \dp1\relax}
+}}
+
+\def\makelstheader{\hbox to\hsize{\the\lstheader}}
+\def\makelstfooter{\hbox to\hsize{\the\lstfooter}}
+
+\def\_ptb_empty_macro{\_ptb_empty_macro}
+
+\def\replace#1#2#3{\_xp\_replace\_xp#1\expanded{{#2}{#3}}}
+\def\_replace#1#2#3{%
+    \def\__replace?##1#2##2\_nul{%
+        ##1%
+        \unless\ifcsname _ptb_empty_macro\detokenize{##2}\endcsname%
+            \_afterfi{#3\__replace?##2\_nul}%
+        \fi%
+    }%
+    \edef#1{\_xp\__replace\_xp?#1#2\_nul}%
+}
+
+\def\replacefromto#1#2#3#4{\_xp\_replacefromto\_xp#1\expanded{{#2}{#3}{#4}}}
+\def\_replacefromto#1#2#3#4{%
+    \def\_replacement##1{#4}%
+    \def\_replaceA?##1#2##2\_nul{%
+        ##1%
+        \unless\ifcsname _ptb_empty_macro\detokenize{##2}\endcsname%
+            \_afterfi{\_replaceB?##2\_nul}%
+        \fi%
+    }%
+    \def\_replaceB?##1#3##2\_nul{%
+        \ifcsname _ptb_empty_macro\detokenize{##2}\endcsname%
+            ##1%
+        \else%
+            \_afterfi{\_replacement{##1}%
+            \_replaceA?##2\_nul}%
+        \fi%
+    }%
+    \edef#1{\_xp\_replaceA\_xp?\expanded{#1#2#3}\_nul}%
+}
+
+\let\_o_replace=\replace
+\let\_o_replacefromto=\replacefromto
+
+\def\_r_replace#1#2#3{\replace{#3}{#1}{#2}}
+\def\_r_replacefromto#1#2#3#4{\replacefromto{#4}{#1}{#2}{#3}}
+
+\def\_addexecution#1{\_commandexecute=\_xp{\the\_commandexecute\_execute{#1}}}
+\def\_add_command_replace#1#2{\_addexecution{\_r_replace{#1}{#2}}}
+\def\_add_command_replacefromto#1#2#3{\_addexecution{\_r_replacefromto{#1}{#2}{#3}}}
+
+\def\lstnumfontset{\setfontandscale{tt}{6pt}}
+\def\lstfontset{\setfontandscale{tt}{8pt}}
+\def\lststrut{\vrule width\z@ height6pt depth1pt}
+
+\def\_c#1#2{{\_setcolor{}{#1}#2}}
+\def\mc#1#2{\mlcall _c{{#1}}{#2}}
+\def\c#1#2{\call _c{{#1}}{#2}}
+
+\_commandcapture={%
+    \setmacrotolen\_lstlinenumwd{\lstnumfontset\lstmaxnum}%
+    \let\w=\relax%
+    \let\n=\relax%
+    \let\mlcall=\relax%
+    \let\call=\relax%
+    \let\replace=\_add_command_replace%
+    \let\replacefromto=\_add_command_replacefromto%
+}
+
+\_commandexecute={%
+    \let\replace\_o_replace%
+    \let\replacefromto\_o_replacefromto%
+}
+
+\long\def\_syntax_printline#1{%
+    \hbox{\hbox to\_lstlinenumwd{\hss\lstnumfontset\the\lstlinenum}\kern\lstlinenumbuf\relax#1}%
+}
+
+\def\_syntax_linemanager#1{{%
+    \def\_regA{#1}%
+    \def\_regB{\w}%
+    \unless\ifx\_regA\_regB%
+        \global\advance\lstlinenum by 1\relax%
+        \def\w{}%
+        \setbox0=\hbox{\lstfontset\lststrut\relax#1}%
+        \ifdim\wd0<\lstcodelinewd %
+            \_syntax_printline{\hbox to\lstcodelinewd{\box0\hfil}}%
+        \else%
+            \def\w{\allowbreak}%
+            \_syntax_printline{\vtop{%
+                \hsize=\lstcodelinewd\hangindent=1cm\relax\hangafter=1\relax%
+                \lstfontset\lststrut\relax#1\par%
+            }}%
+        \fi%
+    \fi%
+}}
+
+\def\lstmaxnum{9999}
+
+\_macrocallmanager={%
+    \def\call#1#{\_call{#1}}%
+    \protected\def\_call#1#2#3{\csname #1\endcsname#2{#3}}%
+    \def\mlcall#1#{\_mlcall{#1}}%
+    \def\_mlcall#1#2#3{\__mlcall{#1}{#2}#3\n\n\_nul}%
+    \def\__mlcall#1#2#3\n\n#4\_nul{%
+        \_call{#1}{#2}{#3}%
+        \unless\ifcsname _ptb_empty_macro\detokenize{#4}\endcsname%
+            \n\n\_afterfi{\__mlcall{#1}{#2}#4\_nul}%
+        \fi%
+    }%
+}
+
+\bgroup\catcode`\ =12\relax\lowercase{\egroup\_add_command_replace{ }{\w\ \w}}
+\bgroup\catcode`\^^M=12\relax\lowercase{\egroup\_add_command_replace{^^M}{\w\n\n\w}}
+
+\def\loadsyntax#1{{\catcode`_=11\relax\input{ptb-syntax-#1.tex}}}
+\def\setsyntax#1{\_listingcommands=\_xp{\_xp\_xp\_xp\the\csname _#1_listingcommands\endcsname}}
+
+\definecolor{lst-comment}{rgb}{0 .6 0}
+\definecolor{lst-number}{rgb}{.2 .7 .2}
+


Property changes on: trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/ptb-listings.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Deleted: trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/ptb-syntax-hi.tex
===================================================================
--- trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/ptb-syntax-hi.tex	2025-04-02 20:18:49 UTC (rev 74831)
+++ trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfGraphics/ptb-syntax-hi.tex	2025-04-02 20:19:11 UTC (rev 74832)
@@ -1,253 +0,0 @@
-\input ptb-pdfGraphics
-\input ptb-pdfData
-
-\createarray{catcodes}
-\createarray{colors}
-\createarray{swapped}
-\createarray{initcolors}
-\appendarraymanyvalued{catcodes}{0}{abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_}
-\appendarraymanyvalued{colors}{rgb{1 0 0}}{{fun}{let}{_prim_print}{def}{if}{for}{int}{float}{double}{short}{char}{long}{while}{main}{printf}{return}{exit}}
-\appendarraymanyvalued{colors}{rgb{0 .8 0}}{1234567890}
-\appendarraymanyvalued{colors}{rgb{1 0 0}}{{pt}{cm}{in}{mu}{sp}}
-%\appendarraymanyvalued{colors}{.2 0 0}{*+-<>=}
-
-\def\_nextother{\_nextother}
-\appendarray{swapped}{{ }{\_syntaxspace}}
-\appendarray{swapped}{{`}{\backtick}}
-\chardef\backtick=0
-\appendarray{swapped}{{:}{$\mathop{:}$}}
-\appendarray{swapped}{{-}{$\vcenter{\hbox{\tt-}}$}}
-\bgroup\catcode`\^^I=11\relax\lowercase{\egroup\appendarray{swapped}{{^^I}{\hiindent}}}
-\bgroup\catcode`\^^M=11\relax\lowercase{\egroup\appendarray{swapped}{{^^M}{%
-    \par\egroup\_output_box%
-    \setbox\_outputbox=\vtop\bgroup%
-        \hsize=\dimexpr\hsize - \leftskip - \rightskip - \_output_indent - 15pt - \@numhskip\relax%
-        \hangindent=.5cm\relax \hangafter=1\relax%
-        \raggedright%
-        \baselineskip=15pt%
-        \tolerance=10000\relax \hbadness=10000\relax%
-        \_tokcount=0\relax%
-        \quitvmode%
-}}}
-\bgroup\lccode`\?=`\\ \lowercase{\egroup\appendarray{catcodes}{{?}{-1}}}
-\bgroup\lccode`\?=`\\ \lowercase{\egroup\appendarray{initcolors}{{?}{\_nextother}{rgb{1 0 0}}}}
-\bgroup\lccode`\?=`\# \lowercase{\egroup\appendarray{colors}{{?}{rgb{0 .3 0}}}}
-\bgroup\lccode`\?=`\& \lowercase{\egroup\appendarray{colors}{{?}{rgb{0 .8 0}}}}
-%\bgroup\lccode`\?=`\% \catcode`\^^M=11\relax\lowercase{\egroup\appendarray{initcolors}{{?}{^^M}{rgb{.6 .7 .6}}}}
-\appendarray{initcolors}{{"}{"}{rgb{.6 .6 .3}}}
-
-
-\newif\ifstrequals
-\def\_ifstrequals#1#2{%
-    \edef\_regA{\detokenize{#1}}\edef\_regB{\detokenize{#2}}%
-    \ifx\_regA\_regB \strequalstrue\else\strequalsfalse\fi%
-}
-
-\long\def\_get_second_conditionally#1#2#3#4{%
-    \_ifstrequals{#2}{#3}%
-    \ifstrequals%
-        \def#1{#4}%
-    \fi%
-}
-
-\long\def\_get_second_third_conditionally#1#2#3#4#5#6{%
-    \_ifstrequals{#3}{#4}%
-    \ifstrequals%
-        \def#1{#5}%
-        \def#2{#6}%
-    \fi%
-}
-
-\def\_get_catcode#1{%
-    \def\_catcode{1}%
-    \long\def\_arr_index##1{\_get_second_conditionally\_catcode{#1}##1}%
-    \executearray{catcodes}%
-}
-
-\def\_get_initcolor#1{%
-    \let\_initcolor=\_nul%
-    \let\_end_initcolor=\_nul%
-    \long\def\_arr_index##1{\_get_second_third_conditionally\_end_initcolor\_initcolor{#1}##1}%
-    \executearray{initcolors}%
-}
-
-\newcount\_tokcount
-\newtoks\_currtoken
-\newtoks\_currprinttoken
-\newif\ifpotentialescape
-
-\def\_catcode_normal{0}
-\def\_catcode_potential_escape{-1}
-\def\_potential_escape_token{endhi}
-
-\def\_get_next_tok#1#2{%
-    \advance\_tokcount by 1\relax%
-    \global\let\_next=\_get_next_tok%
-    \_get_catcode{#2}%
-    \ifstrcases{\_catcode}%
-        \_catcode_normal{%
-            \_currtoken\_xp{\the\_currtoken#2}%
-            \_currprinttoken\_xp{\the\_currprinttoken#2\allowbreak}%
-        }%
-        \_catcode_potential_escape{%
-            \ifpotentialescape%
-                \_print{\_potential_escape_char}{\_potential_escape_char}%
-                \_print{\the\_currprinttoken}{\the\_currtoken}%
-                \_print{#2\allowbreak}{#2}%
-                \_currtoken={}%
-                \_currprinttoken={}%
-                \potentialescapefalse%
-            \else%
-                \_print{\the\_currprinttoken\allowbreak}{\the\_currtoken}%
-                \_currtoken={}%
-                \_currprinttoken={}%
-                \def\_potential_escape_char{#2}%
-                \potentialescapetrue%
-            \fi%
-        }%
-        \default{%
-            \ifpotentialescape%
-                \expanded{\unexpanded{\_ifstrequals}{\the\_currtoken}{\_potential_escape_token}}%
-                \ifstrequals%
-                   \gdef\_next{\_xp\endhi\_gobble}%
-                \else%
-                   \potentialescapefalse%
-                   \_print{\_potential_escape_char}{\_potential_escape_char}%
-                   \_xp\_ifstrequals\_xp{\the\_currtoken}{}%
-                   \unless\ifstrequals \_print{\the\_currprinttoken}{\the\_currtoken}\fi%
-                   \_print{#2}{#2}%
-                   \_currtoken={}%
-                   \_currprinttoken={}%
-                \fi%
-            \else%
-                \_xp\_ifstrequals\_xp{\the\_currtoken}{}%
-                \unless\ifstrequals \_print{\the\_currprinttoken}{\the\_currtoken}\fi%
-                \_print{#2}{#2}%
-                \_currtoken={}%
-                \_currprinttoken={}%
-            \fi%
-        }%
-    \endifcases%
-    \_next{}%
-}
-
-%\def\color#1#2{\pdfliteral{#1 rg #1 RG}#2\pdfliteral{0 0 0 rg 0 0 0 RG}}
-
-\newif\ifcolorinit
-\colorinitfalse
-\def\_print_token#1#2{%
-    \def\_tok_swap{#1}%
-    \long\def\_arr_index##1{\_get_second_conditionally\_tok_swap{#2}##1}%
-    \executearray{swapped}%
-    \ifcolorinit%
-        {\_xp\_setcolor\_xp{\_xp}\_xp{\_nextcolor}\_tok_swap}%
-        \unless\ifx\_end_initcolor\undefined%
-            \ifx\_nextother\_end_initcolor%
-                \global\colorinitfalse%
-            \else%
-                \_xp\_ifstrequals\_xp{\_end_initcolor}{#2}%
-                \ifstrequals%
-                    \global\colorinitfalse%
-                \fi%
-            \fi%
-        \fi%
-    \else%
-        \_get_initcolor{#2}%
-        \unless\ifx\_initcolor\_nul%
-            {\_xp\_setcolor\_xp{\_xp}\_xp{\_initcolor}\_tok_swap}%
-            \global\let\_nextcolor=\_initcolor%
-            \global\let\_end_initcolor=\_end_initcolor%
-            \global\colorinittrue%
-        \else%
-            \let\_tok_color=\_nul%
-            \long\def\_arr_index##1{\_get_second_conditionally\_tok_color{#2}##1}%
-            \executearray{colors}%
-            \ifx\_tok_color\_nul \_tok_swap\else{\_xp\_setcolor\_xp{\_xp}\_xp{\_tok_color}\_tok_swap}\fi%
-        \fi%
-    \fi%
-}
-
-\def\_print#1#2{%
-    \def\_print_temp{#1}%
-    \_xp\_print_token\_xp\_print_temp\_xp{#2}%
-}
-
-\newbox\_hibox
-\long\def\_beginhi#1{\bgroup%
-    \tt%
-    \frenchspacing%
-    \def\do##1{\catcode`##1=11\relax}\dospecials%
-    \catcode`\^^M=11%
-    \catcode`\^^I=11%
-    #1%
-    \setbox\_hibox=\vbox\bgroup%
-        \kern\_output_indent%
-        \lineskiplimit=0pt%
-        \lineskip=0pt%
-        \parindent=0pt%
-        %\setbox\_outputbox=\hbox\bgroup%
-        \setbox\_outputbox=\vtop\bgroup%
-            \hsize=\dimexpr\hsize - \leftskip - \rightskip - \_output_indent - 15pt - \@numhskip\relax%
-            \hangindent=.5cm\relax \hangafter=1\relax%
-            \raggedright%
-            \tolerance=10000\relax \hbadness=10000\relax%
-            \_tokcount=0\relax%
-            \quitvmode%
-            \_xp\_get_next_tok\_xp{\_xp}%
-}
-
-\def\beginhi{\_getline\_beginhi}
-
-\def\syntax at buf{0cm}
-\def\syntaxbg{rgb{.1 .1 .1}}
-\def\endhi{%
-    \egroup\egroup%\kern\_output_indent\egroup%
-    \par%
-    \vskip\syntax at buf\relax%
-    \hbox to\dimexpr\wd\_hibox + \_output_indent\relax{%
-        {\_xp\_setcolor\_xp{\_xp}\_xp{\syntaxbg}\vrule height\ht\_hibox width\dimexpr\wd\_hibox+\_output_indent\relax depth\dp\_hibox}%
-        \kern-\wd\_hibox\box\_hibox%
-    }%
-    \par%
-    \box\_hibox%
-    \egroup%
-    \vskip\syntax at buf\relax%
-}
-
-\newbox\_outputbox
-\newcount\outputline
-\newif\ifglobcount
-\def\_output_indent{1pt}
-\def\_output_box{%
-    \ifglobcount%
-        \global\advance\outputline by 1%
-    \else%
-        \advance\outputline by 1%
-    \fi%
-    %\hbox to\dimexpr\hsize - \leftskip - \rightskip - \_output_indent\relax{%
-    \hbox{%
-        \_output_line_number{\the\outputline}\strut\box\_outputbox%
-    }%
-    \kern\_output_indent%
-}
-
-\font\eighttt=cmtt8
-\def\@numhskip{1em}
-\def\_output_line_number#1{\hbox to15pt{\eighttt\hfil#1}\hskip\@numhskip}
-
-
-\font\threett=cmtt8 at 5pt
-{\setbox0=\hbox{\tt\ \ \ \ }\xdef\hiindent at width{\the\wd0}}
-{\setbox0=\hbox{\tt\ }\xdef\space at width{\the\wd0}}
-
-\def\hiindent{\quitvmode\hbox to\hiindent at width{\hss$\vcenter{\hbox{\threett>}}$\hss}}
-\def\hiindent{\ \ \ \ \_iffirstchar{\advance\hangindent by\hiindent at width}}
-\def\_syntaxspace{\ \_iffirstchar{\advance\hangindent by\space at width}}
-
-\def\_iffirstchar#1{%
-    \ifnum\_tokcount=1 %
-        \_tokcount=0\relax%
-        #1%
-    \fi%
-}
-

Modified: trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfToolbox.tex
===================================================================
--- trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfToolbox.tex	2025-04-02 20:18:49 UTC (rev 74831)
+++ trunk/Master/texmf-dist/tex/plain/pdftoolbox/pdfToolbox.tex	2025-04-02 20:19:11 UTC (rev 74832)
@@ -7,8 +7,8 @@
 
 \_checkloaded{pdfToolbox}
 
-\def\pdfToolboxversion{0.1}
-\def\pdfToolboxdate{March, 2025}
+\def\pdfToolboxversion{0.2}
+\def\pdfToolboxdate{April, 2025}
 
 \say{This is pdfToolbox, version \pdfToolboxversion (\pdfToolboxdate)}
 

Modified: trunk/Master/texmf-dist/tex/plain/pdftoolbox/ptb-pdfGraphics.tex
===================================================================
--- trunk/Master/texmf-dist/tex/plain/pdftoolbox/ptb-pdfGraphics.tex	2025-04-02 20:18:49 UTC (rev 74831)
+++ trunk/Master/texmf-dist/tex/plain/pdftoolbox/ptb-pdfGraphics.tex	2025-04-02 20:19:11 UTC (rev 74832)
@@ -4,4 +4,5 @@
 \input pdfGraphics/ptb-colors
 \input pdfGraphics/ptb-colorboxes
 \input pdfGraphics/ptb-pdfdraw
-\input pdfGraphics/ptb-syntax-hi
+\input pdfGraphics/ptb-listings
+

Modified: trunk/Master/texmf-dist/tex/plain/pdftoolbox/ptb-utils.tex
===================================================================
--- trunk/Master/texmf-dist/tex/plain/pdftoolbox/ptb-utils.tex	2025-04-02 20:18:49 UTC (rev 74831)
+++ trunk/Master/texmf-dist/tex/plain/pdftoolbox/ptb-utils.tex	2025-04-02 20:19:11 UTC (rev 74832)
@@ -14,6 +14,7 @@
 \let\_xp=\expandafter
 \def\_nul{\_nul}
 \def\_id#1{#1}
+\def\_empty{}
 \long\def\_gobble#1{}
 \long\def\_gobbletilnul#1\_nul{}
 \def\_mstrip{\_xp\_gobble\string}
@@ -205,3 +206,8 @@
     \let#1=\_uregA%
 }
 
+\def\setmacrotolen#1#2{{%
+    \setbox0=\hbox{#2}%
+    \xdef#1{\the\wd0}%
+}}
+



More information about the tex-live-commits mailing list.