summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2023-01-15 20:58:27 +0000
committerKarl Berry <karl@freefriends.org>2023-01-15 20:58:27 +0000
commit810d9b451473ebe8e27c3f691bf001e01864e6fb (patch)
tree5151b6e2e4cef114dd6f4154f2d602312c40f0cf /Master/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
parentbf5bd6f0c1fa2b7dac8b2b7b8d4b52bf6a1518f0 (diff)
pgf (15jan23)
git-svn-id: svn://tug.org/texlive/trunk@65553 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex')
-rw-r--r--Master/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex118
1 files changed, 95 insertions, 23 deletions
diff --git a/Master/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex b/Master/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
index 184506a1851..f24557f8424 100644
--- a/Master/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
+++ b/Master/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
@@ -26,6 +26,13 @@
\def\pgfkeys@empty{}
\long\def\pgfkeys@firstoftwo#1#2{#1}
\long\def\pgfkeys@secondoftwo#1#2{#2}
+\long\def\pgfkeys@ifcsname#1{%
+ \ifcsname#1\endcsname
+ \expandafter\pgfkeys@firstoftwo
+ \else
+ \expandafter\pgfkeys@secondoftwo
+ \fi
+}
% This is useful:
@@ -55,6 +62,17 @@
\let\pgfkeys@unexpanded \normalunexpanded
\fi
+\begingroup
+ \edef\pgfkeys@tmpa{\string\expanded}
+ \edef\pgfkeys@tmpb{\meaning\pgfkeys@expanded}
+ \expandafter
+\endgroup
+\ifx\pgfkeys@tmpa\pgfkeys@tmpb
+\else
+ \pgfkeys@error{PGF requires the \noexpand\expanded primitive}
+ \csname @@end\expandafter\endcsname\expandafter\end%
+\fi
+
% Set a key to a value
%
@@ -134,7 +152,7 @@
%
% \pgfkeyslet{/algo/swap}{\myswap}
-\def\pgfkeyslet#1#2{%
+\long\def\pgfkeyslet#1#2{%
\expandafter\let\csname pgfk@#1\endcsname#2%
}
@@ -152,7 +170,10 @@
%
% \pgfkeysgetvalue{/tikz/swap}{\myswap}
-\def\pgfkeysgetvalue#1#2{\expandafter\let\expandafter#2\csname pgfk@#1\endcsname}
+\long\def\pgfkeysgetvalue#1#2{%
+ \pgfkeys@ifcsname{pgfk@#1}%
+ {\expandafter\let\expandafter#2\csname pgfk@#1\endcsname}%
+ {\let#2\relax}}
@@ -169,7 +190,8 @@
%
% The length is \pgfkeysvalue{/tikz/length}.
-\def\pgfkeysvalueof#1{\csname pgfk@#1\endcsname}
+\let\pgfkeys@relax\relax
+\long\def\pgfkeysvalueof#1{\csname\pgfkeys@ifcsname{pgfk@#1}{pgfk@#1}{pgfkeys@relax}\endcsname}
@@ -368,7 +390,9 @@
\def\pgfkeys@case@one{%
\pgfkeysifdefined{\pgfkeyscurrentkey/.@cmd}%
{\pgfkeysgetvalue{\pgfkeyscurrentkey/.@cmd}{\pgfkeys@code}%
- \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov}
+ \ifx\pgfkeys@code\relax\expandafter\pgfkeys@firstoftwo\else\expandafter\pgfkeys@secondoftwo\fi
+ {\pgfkeys@unknown}%
+ {\expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov}}
{\pgfkeys@case@two}%
}
@@ -436,20 +460,20 @@
\def\pgfkeys@ifexecutehandler#1#2{#1}%
\let\pgfkeys@ifexecutehandler@handleall=\pgfkeys@ifexecutehandler
\def\pgfkeys@ifexecutehandler@handleonlyexisting#1#2{%
- \ifcsname pgfk@excpt@\pgfkeyscurrentname\endcsname%
+ \pgfkeys@ifcsname{pgfk@excpt@\pgfkeyscurrentname}{%
#1% ok, this particular key handler is known and should be processed in any case (for example .try)
- \else
+ }{%
% implement the 'only existing' feature here:
\pgfkeysifdefined{\pgfkeyscurrentpath}{#1}{%
\pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}{#1}{#2}%
}{}%
- \fi%
+ }%
}%
\def\pgfkeys@ifexecutehandler@handlefullorexisting#1#2{%
\ifpgfkeysaddeddefaultpath
- \ifcsname pgfk@excpt@\pgfkeyscurrentname\endcsname%
+ \pgfkeys@ifcsname{pgfk@excpt@\pgfkeyscurrentname}{%
#1% ok, this particular key handler is known and be processed in any case (for example .try)
- \else
+ }{%
% implement the 'only existing' feature here:
\pgfkeysifdefined{\pgfkeyscurrentpath}{%
#1%
@@ -460,7 +484,7 @@
#2%
}%
}%
- \fi%
+ }%
\else
#1% ok, always true if the USER explicitly provided the full key path.
\fi
@@ -560,7 +584,7 @@
%
% Example:
%
-% \pgfqkeys{/tikz}{myother length/.code=\def\myotherlength{#1}\pgfkeysalso{length=#1}}
+% \pgfqkeys{/tikz}{myother length/.code=\def\myotherlength{#1}\pgfkeysalso{length={#1}}}
\def\pgfqkeys{\expandafter\pgfkeys@@qset\expandafter{\pgfkeysdefaultpath}}%
\long\def\pgfkeys@@qset#1#2#3{\def\pgfkeysdefaultpath{#2/}\pgfkeys@parse#3,\pgfkeys@mainstop\def\pgfkeysdefaultpath{#1}}
@@ -578,7 +602,7 @@
%
% Example:
%
-% \pgfkeys{tikz,myother length/.code=\def\myotherlength{#1}\pgfkeysalso{length=#1}}
+% \pgfkeys{tikz,myother length/.code=\def\myotherlength{#1}\pgfkeysalso{length={#1}}}
\long\def\pgfkeysalso#1{\pgfkeys@parse#1,\pgfkeys@mainstop}
@@ -598,7 +622,7 @@
% Example:
%
% \begingroup
-% \pgfqkeysalso{/tikz}{myother length/.code=\def\myotherlength{#1}\pgfkeysalso{length=#1}}
+% \pgfqkeysalso{/tikz}{myother length/.code=\def\myotherlength{#1}\pgfkeysalso{length={#1}}}
\long\def\pgfqkeysalso#1#2{\def\pgfkeysdefaultpath{#1/}\pgfkeys@parse#2,\pgfkeys@mainstop}
@@ -848,12 +872,12 @@
}%
}
\def\pgfkeys@handle@boolean#1#2{%
- \ifcsname#1#2\endcsname%
+ \pgfkeys@ifcsname{#1#2}{%
\csname#1#2\endcsname%
- \else%
+ }{%
\def\pgf@marshal{\pgfkeysvalueof{/errors/boolean expected/.@cmd}}%
\expandafter\pgf@marshal\expandafter{\pgfkeyscurrentkey}{#2}\pgfeov%
- \fi
+ }%
}
\pgfkeys{/handlers/.is choice/.code=%
@@ -985,12 +1009,12 @@
\long\def\pgfkeys@exp@call#1{\pgfkeysalso{\pgfkeyscurrentpath={#1}}}
\def\pgfkeys@mathparse{%
- \ifcsname pgfmathparse\endcsname
- \expandafter\pgfmathparse
- \else
+ \pgfkeys@ifcsname{pgfmathparse}{%
+ \pgfmathparse
+ }{%
\pgfkeys@error{You have to load `pgfmath' to use \string\pgfmathparse}%
- \expandafter\def\expandafter\pgfmathresult
- \fi
+ \def\pgfmathresult
+ }%
}
\pgfkeys{/handlers/.evaluated/.code=\pgfkeys@mathparse{#1}\expandafter\pgfkeys@exp@call\expandafter{\pgfmathresult}}
@@ -1044,7 +1068,7 @@
% Utilities
-\pgfkeys{/utils/exec/.code=#1} % simply execute the given code directly.
+\pgfkeys{/utils/exec/.code={#1}} % simply execute the given code directly.
% Errors
@@ -1154,7 +1178,55 @@
\def\:{\pgf@keys@utilxifnch} \expandafter\gdef\: {\futurelet\pgf@keys@utillet@token\pgf@keys@utilifnch}
}
+\chardef\pgfkeys@inputcheck0
+\def\pgfkeys@IfFileExists#1{%
+ \openin\pgfkeys@inputcheck=#1
+ \ifeof\pgfkeys@inputcheck
+ \expandafter\closein\expandafter\pgfkeys@inputcheck
+ \expandafter\pgfkeys@secondoftwo
+ \else
+ \expandafter\closein\expandafter\pgfkeys@inputcheck
+ \expandafter\pgfkeys@firstoftwo
+ \fi
+}
+
+% Library system for pgfkeys
+\def\usepgfkeyslibrary{\pgf@keys@utilifnextchar[{\pgfkeys@@uselibrary}{\pgfkeys@uselibrary}}
+\def\pgfkeys@@uselibrary[#1]{\pgfkeys@uselibrary{#1}}
+\def\pgfkeys@uselibrary#1{\pgfkeys@uselibrary@parse#1,\pgfkeys@mainstop}
+\def\pgfkeys@uselibrary@parse{%
+ \pgf@keys@utilifnextchar\pgfkeys@mainstop{\pgfkeys@cleanup}{\pgfkeys@uselibrary@normal}%
+}%
+\def\pgfkeys@uselibrary@normal#1,{%
+ \pgfkeys@uselibrary@load{#1}%
+ \pgfkeys@uselibrary@parse
+}
+\def\pgfkeys@uselibrary@load#1{%
+ \expandafter\pgfkeys@spdef\expandafter\pgf@temp\expandafter{#1}%
+ \ifx\pgf@temp\pgfkeys@empty\expandafter\pgfkeys@firstoftwo\else\expandafter\pgfkeys@secondoftwo\fi{}{%
+ \pgfkeys@ifcsname{pgfkeys@library@\pgf@temp @loaded}{}{%
+ \expandafter\let\csname pgfkeys@library@\pgf@temp @loaded\endcsname=\pgfkeys@empty
+ \expandafter\edef\csname pgfkeys@library@#1@atcode\endcsname{\the\catcode`\@}%
+ \expandafter\edef\csname pgfkeys@library@#1@barcode\endcsname{\the\catcode`\|}%
+ \expandafter\edef\csname pgfkeys@library@#1@dollarcode\endcsname{\the\catcode`\$}%
+ \catcode`\@=11
+ \catcode`\|=12
+ \catcode`\$=3
+ \pgfkeys@IfFileExists{pgfkeyslibrary\pgf@temp.code.tex}{%
+ \input pgfkeyslibrary\pgf@temp.code.tex
+ }{%
+ \pgfkeys@error{I did not find the pgfkeys library '\pgf@temp'. I looked for the
+ file named pgfkeyslibrary\pgf@temp.code.tex, but could not find it in the
+ current texmf trees.}%
+ }%
+ \catcode`\@=\csname pgfkeys@library@#1@atcode\endcsname
+ \catcode`\|=\csname pgfkeys@library@#1@barcode\endcsname
+ \catcode`\$=\csname pgfkeys@library@#1@dollarcode\endcsname
+ }%
+ }%
+}
-\input pgfkeysfiltered.code.tex
+\let\pgfkeys@library@filtered@loaded\pgfkeys@empty
+\input pgfkeyslibraryfiltered.code.tex
\endinput