| 1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2 |
%%% This file is a copy of some part of PGF/Tikz. |
| 3 |
%%% It has been copied here to provide : |
| 4 |
%%% - compatibility with older PGF versions |
| 5 |
%%% - availability of PGF contributions by Christian Feuersaenger |
| 6 |
%%% which are necessary or helpful for pgfplots. |
| 7 |
%%% |
| 8 |
%%% For reasons of simplicity, I have copied the whole file, including own contributions AND |
| 9 |
%%% PGF parts. The copyrights are as they appear in PGF. |
| 10 |
%%% |
| 11 |
%%% Note that pgfplots has compatible licenses. |
| 12 |
%%% |
| 13 |
%%% This copy has been modified in the following ways: |
| 14 |
%%% - nested \input commands have been updated |
| 15 |
%%% |
| 16 |
% |
| 17 |
% Support for the contents of this file will NOT be done by the PGF/TikZ team. |
| 18 |
% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction |
| 19 |
% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything: |
| 20 |
% This file comes without any warranty as the rest of pgfplots; there is no obligation for help. |
| 21 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 22 |
%%% Date of this copy: Di 25. Dez 18:14:20 CET 2012 %%% |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
% Copyright 2007 by Till Tantau |
| 27 |
% |
| 28 |
% This file may be distributed and/or modified |
| 29 |
% |
| 30 |
% 1. under the LaTeX Project Public License and/or |
| 31 |
% 2. under the GNU Public License. |
| 32 |
% |
| 33 |
% See the file doc/generic/pgf/licenses/LICENSE for more details. |
| 34 |
|
| 35 |
|
| 36 |
% The files pgfkeys.code.tex and pgfkeysfiltered.code.tex are |
| 37 |
% perfectly self-contained, except that the catcode of @ |
| 38 |
% should be made a letter. |
| 39 |
|
| 40 |
|
| 41 |
% Guard against reading twice |
| 42 |
\ifx\pgfkeysloaded\undefined |
| 43 |
\let\pgfkeysloaded=\relax |
| 44 |
\else |
| 45 |
\expandafter\endinput |
| 46 |
\fi |
| 47 |
|
| 48 |
% The purpose of this file is to provide a general settings engine that |
| 49 |
% works with all TeX formats and has no save-stack impact |
| 50 |
|
| 51 |
|
| 52 |
% This is useful: |
| 53 |
|
| 54 |
\def\pgfkeys@ifcsname#1\endcsname#2\else#3\fi{\expandafter\ifx\csname#1\endcsname\relax#3\else#2\fi}% |
| 55 |
\ifx\eTeXrevision\undefined% |
| 56 |
\else% |
| 57 |
\expandafter\let\expandafter\pgfkeys@ifcsname\csname ifcsname\endcsname% |
| 58 |
\fi |
| 59 |
|
| 60 |
\def\pgfkeys@empty{} |
| 61 |
|
| 62 |
% This also: |
| 63 |
|
| 64 |
\ifx\PackageError\undefined |
| 65 |
\def\pgfkeys@error#1{\immediate\write-1{Package pgfkeys: Error! #1.}}% |
| 66 |
\else |
| 67 |
\def\pgfkeys@error#1{\PackageError{pgfkeys}{#1}{}}% |
| 68 |
\fi |
| 69 |
|
| 70 |
% Set a key to a value |
| 71 |
% |
| 72 |
% #1 = key |
| 73 |
% #2 = tokens |
| 74 |
% |
| 75 |
% Description: |
| 76 |
% |
| 77 |
% This command sets the key to the given tokens. The tokens are stored as |
| 78 |
% is and can even contain things like #9. |
| 79 |
% |
| 80 |
% Keys are organized hierarchically using something similar to Unix |
| 81 |
% paths. Thus, a typically key might be called "/tikz/length" or |
| 82 |
% "/tikz/length dimension/.@cmd". Some keys starting with a dot are |
| 83 |
% special, so they should not be used as normal key names (they are |
| 84 |
% similar to Unix files starting with a dot -- you can use them, but |
| 85 |
% be careful). |
| 86 |
% |
| 87 |
% Keys are always local to the current TeX group. |
| 88 |
% |
| 89 |
% Example: |
| 90 |
% |
| 91 |
% \pgfkeyssetvalue{/tikz/length}{2cm-3cm} |
| 92 |
% \pgfkeyssetvalue{/algo/swap}{{#2}{#1}} |
| 93 |
|
| 94 |
\long\def\pgfkeyssetvalue#1#2{% |
| 95 |
\pgfkeys@temptoks{#2}\expandafter\edef\csname pgfk@#1\endcsname{\the\pgfkeys@temptoks}% |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
% Add text to a key at the end |
| 101 |
% |
| 102 |
% #1 = key |
| 103 |
% #2 = a value to be added at the beginning |
| 104 |
% #3 = a value to be added at the end |
| 105 |
% |
| 106 |
% Description: |
| 107 |
% |
| 108 |
% This command adds #2 to the definition of the key. The key should |
| 109 |
% have been set previously using \pgfkeyssetvalue. |
| 110 |
% |
| 111 |
% Example: |
| 112 |
% |
| 113 |
% \pgfkeysaddvalue{/tikz/length}{}{-3cm} |
| 114 |
|
| 115 |
\long\def\pgfkeysaddvalue#1#2#3{% |
| 116 |
{% |
| 117 |
\toks0{#2}% |
| 118 |
\pgfkeysifdefined{#1} |
| 119 |
{\pgfkeys@temptoks\expandafter\expandafter\expandafter{\csname pgfk@#1\endcsname}}% |
| 120 |
{\pgfkeys@temptoks{}}% |
| 121 |
\toks1{#3}% |
| 122 |
\xdef\pgfkeys@global@temp{\the\toks0 \the\pgfkeys@temptoks \the\toks1}% believe or don't: the spaces are important |
| 123 |
}% |
| 124 |
\pgfkeyslet{#1}\pgfkeys@global@temp% |
| 125 |
} |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
% Makes a key equal a given code |
| 130 |
% |
| 131 |
% #1 = key |
| 132 |
% #2 = a code name |
| 133 |
% |
| 134 |
% Description: |
| 135 |
% |
| 136 |
% This command executes a \let command so that a key gets the same |
| 137 |
% value as the parameter #2. |
| 138 |
% |
| 139 |
% Keys are always local to the current TeX group. |
| 140 |
% |
| 141 |
% Example: |
| 142 |
% |
| 143 |
% \pgfkeyslet{/algo/swap}{\myswap} |
| 144 |
|
| 145 |
\def\pgfkeyslet#1#2{% |
| 146 |
\expandafter\let\csname pgfk@#1\endcsname#2% |
| 147 |
} |
| 148 |
|
| 149 |
|
| 150 |
% Retrieve the code stored in a key into a code |
| 151 |
% |
| 152 |
% #1 = key |
| 153 |
% #2 = code |
| 154 |
% |
| 155 |
% Description: |
| 156 |
% |
| 157 |
% This command will set #2 to "point" to the value stored in the key. |
| 158 |
% |
| 159 |
% Example: |
| 160 |
% |
| 161 |
% \pgfkeysgetvalue{/tikz/swap}{\myswap} |
| 162 |
|
| 163 |
\def\pgfkeysgetvalue#1#2{\expandafter\let\expandafter#2\csname pgfk@#1\endcsname} |
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
% Retrieve the value stored in a key |
| 168 |
% |
| 169 |
% #1 = key |
| 170 |
% |
| 171 |
% Description: |
| 172 |
% |
| 173 |
% This command will expand to the value stored in the key. The key |
| 174 |
% should previously have been set using \pgfkeyasetkey or \pgfkeyslet. |
| 175 |
% |
| 176 |
% Example: |
| 177 |
% |
| 178 |
% The length is \pgfkeysvalue{/tikz/length}. |
| 179 |
|
| 180 |
\def\pgfkeysvalueof#1{\csname pgfk@#1\endcsname} |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
% If for testing whether a key exists |
| 185 |
% |
| 186 |
% #1 = key |
| 187 |
% #2 = if-case |
| 188 |
% #3 = else-case |
| 189 |
% |
| 190 |
% Description: |
| 191 |
% |
| 192 |
% This if will be executed if the key exists. In eTeX mode this works |
| 193 |
% like a normal if, in normal TeX mode you need to provide an \else. |
| 194 |
% |
| 195 |
% Example: |
| 196 |
% |
| 197 |
% \pgfkeysifdefined{/tikz/length}{key exists}{does not exist} |
| 198 |
|
| 199 |
\long\def\pgfkeysifdefined#1#2#3{\pgfkeys@ifcsname pgfk@#1\endcsname#2\else#3\fi} |
| 200 |
|
| 201 |
% Tests whether a key is assignable. For standard keys which just |
| 202 |
% store their value, this is identical to \pgfkeysifdefined. |
| 203 |
% |
| 204 |
% But \pgfkeysifassignable is true for command keys as well (but not |
| 205 |
% for handled keys). |
| 206 |
\long\def\pgfkeysifassignable#1#2#3{% |
| 207 |
\pgfkeysifdefined{#1}% |
| 208 |
{#2} |
| 209 |
{\pgfkeysifdefined{#1/.@cmd}% |
| 210 |
{#2}% |
| 211 |
{#3}}% |
| 212 |
}% |
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
% Execute settings |
| 217 |
% |
| 218 |
% #1 = list of settings |
| 219 |
% |
| 220 |
% Description: |
| 221 |
% |
| 222 |
% The list of settings should contain comma-separated settings. Each |
| 223 |
% setting has the following form: |
| 224 |
% |
| 225 |
% /path/key=value |
| 226 |
% |
| 227 |
% The parts "/path/" and "=value" are optional. When the path is not |
| 228 |
% specified, the value of the token register "\pgfkeypath" is used. If |
| 229 |
% "=value" is missing, the value of the setting "/path/key/.@def" is used |
| 230 |
% instead. If this key is set to "\pgfvaluerequired", the key |
| 231 |
% "/errors/value required/.@cmd" is executed. Theis error handler, |
| 232 |
% like all other error handlers, will get the current key as its first |
| 233 |
% parameter (unexpanded) and the current value as its second value |
| 234 |
% (also unexpanded). |
| 235 |
% |
| 236 |
% Any spaces at the beginning and at the end and around the |
| 237 |
% equals-sign are removed. The key with the complete path is set to |
| 238 |
% the code \pgfcurrentkey. |
| 239 |
% |
| 240 |
% The setting is then processed according to the following rules: |
| 241 |
% |
| 242 |
% 1) If the key /path/key/.@cmd" is present, its code is executed |
| 243 |
% with the value computed above, followed by \pgfeov (end of |
| 244 |
% value). So, to handle |
| 245 |
% |
| 246 |
% "/stuff/height= 1.5 ," |
| 247 |
% |
| 248 |
% /stuff/height/.@cmd should be set to some code, that can |
| 249 |
% handle the parameter |
| 250 |
% |
| 251 |
% "1.5\pgfeov" |
| 252 |
% |
| 253 |
% For instance, saying |
| 254 |
% |
| 255 |
% \pgfkeys{/stuff/height/.@cmd}{#1\pgfeov}{\def\myheight{#1}} |
| 256 |
% |
| 257 |
% will do nicely. |
| 258 |
% |
| 259 |
% 2) Otherwise, if the key /path/key is present, this key is |
| 260 |
% set to the value computed above. |
| 261 |
% |
| 262 |
% 3) Otherwise, if the key /handlers/key/.@cmd is present, it is executed |
| 263 |
% with the same parameters as in 1). Additionally, the |
| 264 |
% token register \pgfcurrentkeypath will be set to "/path/" and the |
| 265 |
% macor \pgfcurrentkeywithoutpath to "key". So, in the above |
| 266 |
% example if neither "/stuff/height/.@cmd" nor |
| 267 |
% "/stuff/height" is present, but "/handlers/height" is, |
| 268 |
% then "/handlers/height" is executed with the parameters: |
| 269 |
% |
| 270 |
% "1.5\pgfeov" |
| 271 |
% |
| 272 |
% and \pgfcurrentkey is set to "/stuff/height" and \pgfcurrentkeypath |
| 273 |
% is set to "/stuff/" and \pgfcurrentkeywithoutpath to "height". |
| 274 |
% |
| 275 |
% 4) Otherwise, if the key "/path/.unknown/.@cmd" is present, its code is |
| 276 |
% executed with the same parameters as in 3). |
| 277 |
% |
| 278 |
% 5) Otherwise, the key "/handlers/.unknown/.@cmd" is executed with the same |
| 279 |
% parameters as in 1). |
| 280 |
% |
| 281 |
% After all settings have been processed, the value of the token |
| 282 |
% register \pgfdefaultkeypath is set to its original value. Thus, any local |
| 283 |
% change of this token register has no effect outside the call. |
| 284 |
% |
| 285 |
% Example: |
| 286 |
% |
| 287 |
% \pgfkeys{/tikz/.is family} |
| 288 |
% \pgfkeys{/tikz/line width/.cd, |
| 289 |
% .def=\pgfsetlinewidth{##1}, |
| 290 |
% .set default=.4pt} |
| 291 |
% \pgfkeys{tikz,line width=1pt} |
| 292 |
|
| 293 |
\newtoks\pgfkeys@pathtoks |
| 294 |
\def\pgfkeyscurrentpath{\the\pgfkeys@pathtoks} |
| 295 |
\newtoks\pgfkeys@temptoks |
| 296 |
|
| 297 |
\def\pgfkeys@root{/} |
| 298 |
\let\pgfkeysdefaultpath\pgfkeys@root |
| 299 |
|
| 300 |
\def\pgfkeys{\expandafter\pgfkeys@@set\expandafter{\pgfkeysdefaultpath}}% |
| 301 |
\long\def\pgfkeys@@set#1#2{% |
| 302 |
\let\pgfkeysdefaultpath\pgfkeys@root% |
| 303 |
\pgfkeys@parse#2,\pgfkeys@mainstop% |
| 304 |
\def\pgfkeysdefaultpath{#1}} |
| 305 |
|
| 306 |
\def\pgfkeys@parse{\futurelet\pgfkeys@possiblerelax\pgfkeys@parse@main} |
| 307 |
\def\pgfkeys@parse@main{% |
| 308 |
\ifx\pgfkeys@possiblerelax\pgfkeys@mainstop% |
| 309 |
\expandafter\pgfkeys@cleanup% |
| 310 |
\else% |
| 311 |
\expandafter\pgfkeys@normal% |
| 312 |
\fi% |
| 313 |
} |
| 314 |
\newif\ifpgfkeys@syntax@handlers |
| 315 |
\def\pgfkeys@normal{% |
| 316 |
\ifpgfkeys@syntax@handlers% |
| 317 |
\expandafter\pgfkeys@syntax@handlers% |
| 318 |
\else% |
| 319 |
\expandafter\pgfkeys@@normal% |
| 320 |
\fi% |
| 321 |
} |
| 322 |
\def\pgfkeys@syntax@handlers{\pgfutil@ifnextchar\relax\pgfkeys@syntax@@handlers\pgfkeys@syntax@@handlers}%get rid of spaces |
| 323 |
\def\pgfkeys@syntax@@handlers{\futurelet\pgfkeys@first@char\pgfkeys@syntax@handlers@test} |
| 324 |
\def\pgfkeys@syntax@handlers@test{% |
| 325 |
\pgfkeysgetvalue{/handlers/first char syntax/\meaning\pgfkeys@first@char}\pgfkeys@the@handler% |
| 326 |
\ifx\pgfkeys@the@handler\relax% |
| 327 |
\expandafter\pgfkeys@@normal% |
| 328 |
\else% |
| 329 |
\expandafter\pgfkeys@use@handler% |
| 330 |
\fi% |
| 331 |
} |
| 332 |
\long\def\pgfkeys@use@handler#1,{% |
| 333 |
\pgfkeys@the@handler{#1}% |
| 334 |
\pgfkeys@parse% |
| 335 |
} |
| 336 |
|
| 337 |
\long\def\pgfkeys@@normal#1,{% |
| 338 |
\pgfkeys@unpack#1=\pgfkeysnovalue=\pgfkeys@stop% |
| 339 |
\pgfkeys@parse% |
| 340 |
} |
| 341 |
\def\pgfkeys@cleanup\pgfkeys@mainstop{} |
| 342 |
|
| 343 |
\def\pgfkeys@mainstop{\pgfkeys@mainstop} % equals only itself |
| 344 |
\def\pgfkeys@novalue{} % equals only itself |
| 345 |
\def\pgfkeysnovalue{\pgfkeys@novalue} % equals only itself |
| 346 |
\def\pgfkeysnovalue@text{\pgfkeysnovalue} |
| 347 |
\def\pgfkeysvaluerequired{\pgfkeysvaluerequired} % equals only itself |
| 348 |
|
| 349 |
\long\def\pgfkeys@unpack#1=#2=#3\pgfkeys@stop{% |
| 350 |
\pgfkeys@spdef\pgfkeyscurrentkey{#1}% |
| 351 |
\edef\pgfkeyscurrentkey{\pgfkeyscurrentkey}% |
| 352 |
\ifx\pgfkeyscurrentkey\pgfkeys@empty% |
| 353 |
% Skip |
| 354 |
\else% |
| 355 |
\pgfkeys@add@path@as@needed% |
| 356 |
\pgfkeys@spdef\pgfkeyscurrentvalue{#2}% |
| 357 |
\ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% Hmm... no value |
| 358 |
\pgfkeysifdefined{\pgfkeyscurrentkey/.@def}% |
| 359 |
{\pgfkeysgetvalue{\pgfkeyscurrentkey/.@def}{\pgfkeyscurrentvalue}} |
| 360 |
{}% no default, so leave it |
| 361 |
\fi% |
| 362 |
\ifx\pgfkeyscurrentvalue\pgfkeysvaluerequired% |
| 363 |
\pgfkeysvalueof{/errors/value required/.@cmd}\pgfkeyscurrentkey\pgfkeyscurrentvalue\pgfeov% |
| 364 |
\else% |
| 365 |
\pgfkeys@case@one% |
| 366 |
\fi% |
| 367 |
\fi} |
| 368 |
|
| 369 |
\def\pgfkeys@case@one{% |
| 370 |
\pgfkeysifdefined{\pgfkeyscurrentkey/.@cmd}% |
| 371 |
{\pgfkeysgetvalue{\pgfkeyscurrentkey/.@cmd}{\pgfkeys@code}% |
| 372 |
\expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov} |
| 373 |
{\pgfkeys@case@two}% |
| 374 |
} |
| 375 |
|
| 376 |
\def\pgfkeys@case@two{% |
| 377 |
\pgfkeysifdefined{\pgfkeyscurrentkey}% |
| 378 |
{\pgfkeys@case@two@extern}% |
| 379 |
{\pgfkeys@case@three}% |
| 380 |
} |
| 381 |
|
| 382 |
\def\pgfkeys@case@two@extern{% |
| 383 |
\ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% |
| 384 |
\pgfkeysvalueof{\pgfkeyscurrentkey}% |
| 385 |
\else% |
| 386 |
\pgfkeyslet{\pgfkeyscurrentkey}\pgfkeyscurrentvalue% |
| 387 |
\fi% |
| 388 |
} |
| 389 |
|
| 390 |
|
| 391 |
% either handled key or unknown. |
| 392 |
% |
| 393 |
% This macro will be replaced by the /handler config/handle only existing |
| 394 |
% configuration, see below. |
| 395 |
\def\pgfkeys@case@three{% |
| 396 |
\pgfkeys@split@path% |
| 397 |
\pgfkeysifdefined{/handlers/\pgfkeyscurrentname/.@cmd}% |
| 398 |
{\pgfkeysgetvalue{/handlers/\pgfkeyscurrentname/.@cmd}{\pgfkeys@code}% |
| 399 |
\expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov} |
| 400 |
{\pgfkeys@unknown}% |
| 401 |
} |
| 402 |
\let\pgfkeys@case@three@handleall=\pgfkeys@case@three |
| 403 |
\def\pgfkeys@case@three@handle@restricted{% |
| 404 |
\pgfkeys@split@path% |
| 405 |
\pgfkeysifdefined{/handlers/\pgfkeyscurrentname/.@cmd}{% |
| 406 |
\pgfkeys@ifexecutehandler{% |
| 407 |
\pgfkeysgetvalue{/handlers/\pgfkeyscurrentname/.@cmd}{\pgfkeys@code}% |
| 408 |
\expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov |
| 409 |
}{% |
| 410 |
% this here is necessary: /my search path/key/.code |
| 411 |
% won't be called, so \pgfkeyscurrentpath == '/my search path/key' |
| 412 |
% -> it should be one directory higher! We want to invoke the |
| 413 |
% .unknown handler in |
| 414 |
% '/my search path' |
| 415 |
% |
| 416 |
% Idea: |
| 417 |
% set |
| 418 |
% - path := '/my search path' |
| 419 |
% - name := 'key/.code' |
| 420 |
% - key = '/my search path/key/.code' |
| 421 |
\let\pgfkeys@temp=\pgfkeyscurrentkey |
| 422 |
\let\pgfkeys@tempb=\pgfkeyscurrentname |
| 423 |
\edef\pgfkeyscurrentkey{\pgfkeyscurrentpath}% |
| 424 |
\pgfkeys@split@path% |
| 425 |
\let\pgfkeyscurrentkey=\pgfkeys@temp |
| 426 |
\edef\pgfkeyscurrentname{\pgfkeyscurrentname/\pgfkeys@tempb}% |
| 427 |
\pgfkeys@unknown |
| 428 |
}% |
| 429 |
}{% |
| 430 |
\pgfkeys@unknown |
| 431 |
}% |
| 432 |
} |
| 433 |
|
| 434 |
% this macro is to implement the |handly only existing| key in key filtering: |
| 435 |
% #1: the code to invoke IF the key handler shall be executed |
| 436 |
% #2: the code to invoke if it shall not run. |
| 437 |
\def\pgfkeys@ifexecutehandler#1#2{#1}% |
| 438 |
\let\pgfkeys@ifexecutehandler@handleall=\pgfkeys@ifexecutehandler |
| 439 |
\def\pgfkeys@ifexecutehandler@handleonlyexisting#1#2{% |
| 440 |
\pgfkeys@ifcsname pgfk@excpt@\pgfkeyscurrentname\endcsname% |
| 441 |
#1% ok, this particular key handler is known and should be processed in any case (for example .try) |
| 442 |
\else |
| 443 |
% implement the 'only existing' feature here: |
| 444 |
\pgfkeysifdefined{\pgfkeyscurrentpath}{#1}{% |
| 445 |
\pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}{#1}{#2}% |
| 446 |
}{}% |
| 447 |
\fi% |
| 448 |
}% |
| 449 |
\def\pgfkeys@ifexecutehandler@handlefullorexisting#1#2{% |
| 450 |
\ifpgfkeysaddeddefaultpath |
| 451 |
\pgfkeys@ifcsname pgfk@excpt@\pgfkeyscurrentname\endcsname% |
| 452 |
%\message{ifexecutehandler(\pgfkeyscurrentkeyRAW, path \pgfkeysdefaultpath): '\pgfkeyscurrentname' is an exception; processing it (on \pgfkeyscurrentpath).}% |
| 453 |
#1% ok, this particular key handler is known and be processed in any case (for example .try) |
| 454 |
\else |
| 455 |
% implement the 'only existing' feature here: |
| 456 |
\pgfkeysifdefined{\pgfkeyscurrentpath}{% |
| 457 |
%\message{ifexecutehandler(\pgfkeyscurrentkeyRAW, path \pgfkeysdefaultpath): '\pgfkeyscurrentpath' does exist. Executing '\pgfkeyscurrentname'.}% |
| 458 |
#1% |
| 459 |
}{% |
| 460 |
\pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}{% |
| 461 |
%\message{ifexecutehandler(\pgfkeyscurrentkeyRAW, path \pgfkeysdefaultpath): '\pgfkeyscurrentpath/.@cmd' does exist. Executing '\pgfkeyscurrentname'.}% |
| 462 |
#1% |
| 463 |
}{% |
| 464 |
%\message{ifexecutehandler(\pgfkeyscurrentkeyRAW, path \pgfkeysdefaultpath): '\pgfkeyscurrentpath' does NOT exist. Skipping '\pgfkeyscurrentname'.}% |
| 465 |
#2% |
| 466 |
}% |
| 467 |
}% |
| 468 |
\fi% |
| 469 |
\else |
| 470 |
%\message{ifexecutehandler(\pgfkeyscurrentkeyRAW, path \pgfkeysdefaultpath): Fully qualified key provided. Executing '\pgfkeyscurrentname'.}% |
| 471 |
#1% ok, always true if the USER explicitly provided the full key path. |
| 472 |
\fi |
| 473 |
}% |
| 474 |
\def\pgfkeysaddhandleonlyexistingexception#1{\expandafter\def\csname pgfk@excpt@#1\endcsname{1}}% |
| 475 |
|
| 476 |
\def\pgfkeys@unknown{% |
| 477 |
\pgfkeysifdefined{\pgfkeyscurrentpath/.unknown/.@cmd}% |
| 478 |
{% |
| 479 |
\pgfkeysgetvalue{\pgfkeyscurrentpath/.unknown/.@cmd}{\pgfkeys@code}% |
| 480 |
\expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov} |
| 481 |
{% |
| 482 |
\pgfkeysgetvalue{/handlers/.unknown/.@cmd}{\pgfkeys@code}% |
| 483 |
\expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov% |
| 484 |
}% |
| 485 |
} |
| 486 |
|
| 487 |
|
| 488 |
\long\def\pgfkey@argumentisspace#1{% |
| 489 |
\long\def\pgfkeys@spdef##1##2{% |
| 490 |
\futurelet\pgfkeys@possiblespace\pgfkeys@sp@a##2\pgfkeys@stop\pgfkeys@stop#1\pgfkeys@stop\relax##1}% |
| 491 |
\def\pgfkeys@sp@a{% |
| 492 |
\ifx\pgfkeys@possiblespace\pgfkeys@sptoken% |
| 493 |
\expandafter\pgfkeys@sp@b% |
| 494 |
\else% |
| 495 |
\expandafter\pgfkeys@sp@b\expandafter#1% |
| 496 |
\fi}% |
| 497 |
\long\def\pgfkeys@sp@b#1##1 \pgfkeys@stop{\pgfkeys@sp@c##1}% |
| 498 |
} |
| 499 |
\pgfkey@argumentisspace{ } |
| 500 |
\long\def\pgfkeys@sp@c#1\pgfkeys@stop#2\relax#3{\pgfkeys@temptoks{#1}\edef#3{\the\pgfkeys@temptoks}} |
| 501 |
{\def\:{\global\let\pgfkeys@sptoken= } \: } |
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
\def\pgfkeys@add@path@as@needed{% Should add the path if the |
| 506 |
% \pgfkeyscurrentkey does not start with / |
| 507 |
\expandafter\futurelet\expandafter\pgfkeys@possibleslash\expandafter\pgfkeys@check@slash\pgfkeyscurrentkey\relax% |
| 508 |
} |
| 509 |
\newif\ifpgfkeysaddeddefaultpath |
| 510 |
\def\pgfkeys@check@slash{% |
| 511 |
\ifx\pgfkeys@possibleslash/% |
| 512 |
\expandafter\pgfkeys@nevermind% |
| 513 |
\else% |
| 514 |
\expandafter\pgfkeys@addpath% |
| 515 |
\fi% |
| 516 |
} |
| 517 |
|
| 518 |
\def\pgfkeys@nevermind#1\relax{% |
| 519 |
\pgfkeysaddeddefaultpathfalse |
| 520 |
\let\pgfkeyscurrentkeyRAW\pgfkeyscurrentkey |
| 521 |
} |
| 522 |
\def\pgfkeys@addpath#1\relax{% |
| 523 |
\pgfkeysaddeddefaultpathtrue |
| 524 |
\def\pgfkeyscurrentkeyRAW{#1}% |
| 525 |
\edef\pgfkeyscurrentkey{\pgfkeysdefaultpath#1}% |
| 526 |
} |
| 527 |
|
| 528 |
|
| 529 |
\def\pgfkeys@split@path{% Should assign the two codes |
| 530 |
% \pgfkeyscurrentname and \pgfcurrentlkeypath |
| 531 |
\pgfkeys@pathtoks{}% |
| 532 |
\expandafter\pgfkeys@splitter\pgfkeyscurrentkey//% |
| 533 |
} |
| 534 |
\def\pgfkeys@splitter#1/#2/{% |
| 535 |
\def\pgfkeys@temp{#2}% |
| 536 |
\ifx\pgfkeys@temp\pgfkeys@empty% |
| 537 |
% Ah. done |
| 538 |
\def\pgfkeyscurrentname{#1}% |
| 539 |
\expandafter\pgfkeys@gobbletoslash% |
| 540 |
\else% |
| 541 |
\expandafter\pgfkeys@pathtoks\expandafter{\the\pgfkeys@pathtoks#1/}% |
| 542 |
\fi% |
| 543 |
\pgfkeys@splitter#2/% |
| 544 |
} |
| 545 |
\def\pgfkeys@gobbletoslash\pgfkeys@splitter/{\expandafter\pgfkeys@remove@slash\the\pgfkeys@pathtoks\relax}% |
| 546 |
\def\pgfkeys@remove@slash#1/\relax{\pgfkeys@pathtoks{#1}} |
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
% Quickly set keys |
| 551 |
% |
| 552 |
% #1 = default path |
| 553 |
% #2 = key-value pairs |
| 554 |
% |
| 555 |
% Desscription: |
| 556 |
% |
| 557 |
% This command starts the execution with the default path set to |
| 558 |
% #1. This command should only be used when speed is important (like |
| 559 |
% in a heavily used macro like \tikzset). Normally, keys should be |
| 560 |
% used to set the path. Note that if #1 equals /, then \pgfkeys will |
| 561 |
% actually be quicker! |
| 562 |
% |
| 563 |
% Example: |
| 564 |
% |
| 565 |
% \pgfqkeys{/tikz}{myother length/.code=\def\myotherlength{#1}\pgfkeysalso{length=#1}} |
| 566 |
|
| 567 |
\def\pgfqkeys{\expandafter\pgfkeys@@qset\expandafter{\pgfkeysdefaultpath}}% |
| 568 |
\long\def\pgfkeys@@qset#1#2#3{\def\pgfkeysdefaultpath{#2/}\pgfkeys@parse#3,\pgfkeys@mainstop\def\pgfkeysdefaultpath{#1}} |
| 569 |
|
| 570 |
|
| 571 |
% Sets keys while setting keys |
| 572 |
% |
| 573 |
% #1 = key-value pairs |
| 574 |
% |
| 575 |
% Desscription: |
| 576 |
% |
| 577 |
% This code may only be called inside the code that is executed for a |
| 578 |
% key. The #1 should be a list of settings pairs. They will be executed |
| 579 |
% as if they had been given as the argument to the \pgfkeys command. |
| 580 |
% |
| 581 |
% Example: |
| 582 |
% |
| 583 |
% \pgfkeys{tikz,myother length/.code=\def\myotherlength{#1}\pgfkeysalso{length=#1}} |
| 584 |
|
| 585 |
\long\def\pgfkeysalso#1{\pgfkeys@parse#1,\pgfkeys@mainstop} |
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
% Quickly sets keys while setting keys |
| 590 |
% |
| 591 |
% #1 = default path |
| 592 |
% #2 = key-value pairs |
| 593 |
% |
| 594 |
% Desscription: |
| 595 |
% |
| 596 |
% This command executes #2 with the default path set to #1. This |
| 597 |
% command will cause chaos if used incorrectly. The only safe |
| 598 |
% place to use it instead of \pgfkeys is at the beginning of a TeX group. |
| 599 |
% |
| 600 |
% Example: |
| 601 |
% |
| 602 |
% \begingroup |
| 603 |
% \pgfqkeysalso{/tikz}{myother length/.code=\def\myotherlength{#1}\pgfkeysalso{length=#1}} |
| 604 |
|
| 605 |
\long\def\pgfqkeysalso#1#2{\def\pgfkeysdefaultpath{#1/}\pgfkeys@parse#2,\pgfkeys@mainstop} |
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
|
| 610 |
% Now setup the default handelers and keys: |
| 611 |
|
| 612 |
% Define a key macro with one argument (\def or \edef) |
| 613 |
% |
| 614 |
% #1 = key |
| 615 |
% #2 = code |
| 616 |
% |
| 617 |
% Description: |
| 618 |
% |
| 619 |
% This command will setup things so the key/.@cmd contains a macro |
| 620 |
% that takes one parameter and has #2 as its code. |
| 621 |
% |
| 622 |
% Example: |
| 623 |
% |
| 624 |
% \pgfkeysdef{/my key}{\show#1} |
| 625 |
|
| 626 |
\long\def\pgfkeysdef#1#2{% |
| 627 |
\long\def\pgfkeys@temp##1\pgfeov{#2}% |
| 628 |
\pgfkeyslet{#1/.@cmd}{\pgfkeys@temp}% |
| 629 |
} |
| 630 |
\long\def\pgfkeysedef#1#2{% |
| 631 |
\long\edef\pgfkeys@temp##1\pgfeov{#2}% |
| 632 |
\pgfkeyslet{#1/.@cmd}{\pgfkeys@temp}% |
| 633 |
} |
| 634 |
|
| 635 |
|
| 636 |
% Define a key macro with mutliple arguments (\def or \edef) |
| 637 |
% |
| 638 |
% #1 = key |
| 639 |
% #2 = argument pattern |
| 640 |
% #2 = code |
| 641 |
% |
| 642 |
% Description: |
| 643 |
% |
| 644 |
% This command will setup things so the key/.@cmd contains a macro |
| 645 |
% that takes #2 as its parameter pattern and has #3 as its code. |
| 646 |
% |
| 647 |
% Example: |
| 648 |
% |
| 649 |
% \pgfkeysdefargs{/swap}{#1#2}{#2#1} |
| 650 |
|
| 651 |
\long\def\pgfkeysdefargs#1#2#3{% |
| 652 |
\long\def\pgfkeys@temp#2\pgfeov{#3}% |
| 653 |
\pgfkeyslet{#1/.@cmd}{\pgfkeys@temp}% |
| 654 |
\pgfkeyssetvalue{#1/.@args}{#2\pgfeov}% |
| 655 |
\pgfkeyssetvalue{#1/.@body}{#3}% |
| 656 |
} |
| 657 |
\long\def\pgfkeysedefargs#1#2#3{% |
| 658 |
\long\edef\pgfkeys@temp#2\pgfeov{#3}% |
| 659 |
\pgfkeyslet{#1/.@cmd}{\pgfkeys@temp}% |
| 660 |
\pgfkeyssetvalue{#1/.@args}{#2\pgfeov}% |
| 661 |
\pgfkeyssetvalue{#1/.@body}{#3}% |
| 662 |
} |
| 663 |
|
| 664 |
% Like \pgfkeysdefargs, but `#2' is an integer denoting the expected |
| 665 |
% *number* of arguments. |
| 666 |
% |
| 667 |
% There is a subtle difference between the 'args' command, when it |
| 668 |
% comes to spaces: |
| 669 |
% a key defined with defargs{#1#2} must not have spaces between the |
| 670 |
% arguments when it is used. |
| 671 |
% |
| 672 |
% See this: |
| 673 |
% |
| 674 |
%-------------------------------------------------- |
| 675 |
% % defnargs: |
| 676 |
% \pgfkeysdefnargs{/a}{2}{1=`#1', 2=`#2'} |
| 677 |
% \pgfkeys{ |
| 678 |
% /a= |
| 679 |
% {1} |
| 680 |
% {2} |
| 681 |
% } |
| 682 |
% ->defnargs: 1=`1', 2=`2' |
| 683 |
% |
| 684 |
% defargs: |
| 685 |
% \pgfkeysdefargs{/b}{#1#2}{1=`#1', 2=`#2'} |
| 686 |
% \pgfkeys{ |
| 687 |
% /b= |
| 688 |
% {1} |
| 689 |
% {2} |
| 690 |
% } |
| 691 |
% ->defargs: 1=`1', 2=` 2' (note the space!) |
| 692 |
% |
| 693 |
% defargs: |
| 694 |
% \pgfkeysdefargs{/b}{#1#2}{1=`#1', 2=`#2'} |
| 695 |
% \pgfkeys{ |
| 696 |
% /b= |
| 697 |
% {1}% |
| 698 |
% {2} |
| 699 |
% } |
| 700 |
% ->defargs: 1=`1', 2=`2' |
| 701 |
%-------------------------------------------------- |
| 702 |
\long\def\pgfkeysdefnargs#1#2#3{\pgfkeysdefnargs@{#1}{#2}{#3}{\def}}% |
| 703 |
\long\def\pgfkeysedefnargs#1#2#3{\pgfkeysdefnargs@{#1}{#2}{#3}{\edef}}% |
| 704 |
\long\def\pgfkeysdefnargs@#1#2#3#4{% |
| 705 |
\ifcase#2\relax |
| 706 |
\pgfkeyssetvalue{#1/.@args}{}% |
| 707 |
\or |
| 708 |
\pgfkeyssetvalue{#1/.@args}{##1}% |
| 709 |
\or |
| 710 |
\pgfkeyssetvalue{#1/.@args}{##1##2}% |
| 711 |
\or |
| 712 |
\pgfkeyssetvalue{#1/.@args}{##1##2##3}% |
| 713 |
\or |
| 714 |
\pgfkeyssetvalue{#1/.@args}{##1##2##3##4}% |
| 715 |
\or |
| 716 |
\pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5}% |
| 717 |
\or |
| 718 |
\pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6}% |
| 719 |
\or |
| 720 |
\pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6##7}% |
| 721 |
\or |
| 722 |
\pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6##7##8}% |
| 723 |
\or |
| 724 |
\pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6##7##8##9}% |
| 725 |
\else |
| 726 |
\pgfkeys@error{\string\pgfkeysdefnargs: expected <= 9 arguments, got #2}% |
| 727 |
\fi |
| 728 |
\pgfkeysgetvalue{#1/.@args}\pgfkeys@tempargs |
| 729 |
\def\pgfkeys@temp{\expandafter#4\csname pgfk@#1/.@@body\endcsname}% |
| 730 |
\expandafter\pgfkeys@temp\pgfkeys@tempargs{#3}% |
| 731 |
% eliminate the \pgfeov at the end such that TeX gobbles spaces |
| 732 |
% by using |
| 733 |
% \pgfkeysdef{#1}{\pgfkeysvalueof{#1/.@@body}##1} |
| 734 |
% (with expansion of '#1'): |
| 735 |
\edef\pgfkeys@tempargs{\noexpand\pgfkeysvalueof{#1/.@@body}}% |
| 736 |
\def\pgfkeys@temp{\pgfkeysdef{#1}}% |
| 737 |
\expandafter\pgfkeys@temp\expandafter{\pgfkeys@tempargs##1}% |
| 738 |
\pgfkeyssetvalue{#1/.@body}{#3}% |
| 739 |
} |
| 740 |
|
| 741 |
|
| 742 |
|
| 743 |
% Defining a key command |
| 744 |
|
| 745 |
\pgfkeysdef{/handlers/.code}{\pgfkeysdef{\pgfkeyscurrentpath}{#1}} |
| 746 |
\pgfkeysdef{/handlers/.code 2 args}{\pgfkeysdefargs{\pgfkeyscurrentpath}{##1##2}{#1}} |
| 747 |
\pgfkeysdef{/handlers/.ecode}{\pgfkeysedef{\pgfkeyscurrentpath}{#1}} |
| 748 |
\pgfkeysdef{/handlers/.ecode 2 args}{\pgfkeysedefargs{\pgfkeyscurrentpath}{##1##2}{#1}} |
| 749 |
\pgfkeysdefnargs{/handlers/.code args}{2}{\pgfkeysdefargs{\pgfkeyscurrentpath}{#1}{#2}} |
| 750 |
\pgfkeysdefnargs{/handlers/.ecode args}{2}{\pgfkeysedefargs{\pgfkeyscurrentpath}{#1}{#2}} |
| 751 |
\pgfkeysdefnargs{/handlers/.code n args}{2}{\pgfkeysdefnargs{\pgfkeyscurrentpath}{#1}{#2}} |
| 752 |
\pgfkeysdefnargs{/handlers/.ecode n args}{2}{\pgfkeysedefnargs{\pgfkeyscurrentpath}{#1}{#2}} |
| 753 |
|
| 754 |
% Adding to a key command |
| 755 |
|
| 756 |
\pgfkeys{/handlers/.add code/.code 2 args=% |
| 757 |
% Find out, whether with args or not. |
| 758 |
\pgfkeysifdefined{\pgfkeyscurrentpath/.@args}% |
| 759 |
{% Yes, so add to body and reuse args |
| 760 |
\pgfkeysaddvalue{\pgfkeyscurrentpath/.@body}{#1}{#2}% |
| 761 |
% Redefine code |
| 762 |
{% |
| 763 |
\pgfkeysgetvalue{\pgfkeyscurrentpath/.@args}{\pgfkeys@tempargs}% |
| 764 |
\pgfkeysgetvalue{\pgfkeyscurrentpath/.@body}{\pgfkeys@tempbody}% |
| 765 |
\def\pgfkeys@marshal{\expandafter\gdef\expandafter\pgfkeys@global@temp\pgfkeys@tempargs}% |
| 766 |
\expandafter\pgfkeys@marshal\expandafter{\pgfkeys@tempbody}% |
| 767 |
}% |
| 768 |
\pgfkeysifdefined{\pgfkeyscurrentpath/.@@body}{% |
| 769 |
% support for \pgfkeysndefargs: |
| 770 |
\pgfkeyslet{\pgfkeyscurrentpath/.@@body}{\pgfkeys@global@temp}% |
| 771 |
}{% |
| 772 |
% support for \pgfkeysdefargs: |
| 773 |
\pgfkeyslet{\pgfkeyscurrentpath/.@cmd}{\pgfkeys@global@temp}% |
| 774 |
}% |
| 775 |
}% |
| 776 |
{% |
| 777 |
% No, so single argument (simple \pgfkeysdef). Redefine accordingly. |
| 778 |
{% |
| 779 |
\toks0{#1}% |
| 780 |
\pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}% |
| 781 |
{\pgfkeys@temptoks\expandafter\expandafter\expandafter{\csname pgfk@\pgfkeyscurrentpath/.@cmd\endcsname##1\pgfeov}}% |
| 782 |
{\pgfkeys@temptoks{}}% |
| 783 |
\toks1{#2}% |
| 784 |
\xdef\pgfkeys@global@temp{\the\toks0 \the\pgfkeys@temptoks \the\toks1 }% |
| 785 |
}% |
| 786 |
\expandafter\def\expandafter\pgfkeys@temp\expandafter##\expandafter1\expandafter\pgfeov\expandafter{\pgfkeys@global@temp}% |
| 787 |
\pgfkeyslet{\pgfkeyscurrentpath/.@cmd}\pgfkeys@temp% |
| 788 |
}% |
| 789 |
} |
| 790 |
\pgfkeys{/handlers/.prefix code/.code=\pgfkeys{\pgfkeyscurrentpath/.add code={#1}{}}}% |
| 791 |
\pgfkeys{/handlers/.append code/.code=\pgfkeys{\pgfkeyscurrentpath/.add code={}{#1}}}% |
| 792 |
|
| 793 |
|
| 794 |
% Defining a style |
| 795 |
|
| 796 |
\pgfkeys{/handlers/.style/.code=\pgfkeys{\pgfkeyscurrentpath/.code=\pgfkeysalso{#1}}} |
| 797 |
\pgfkeys{/handlers/.estyle/.code=\pgfkeys{\pgfkeyscurrentpath/.ecode=\noexpand\pgfkeysalso{#1}}} |
| 798 |
\pgfkeys{/handlers/.style args/.code 2 args=\pgfkeys{\pgfkeyscurrentpath/.code args={#1}{\pgfkeysalso{#2}}}} |
| 799 |
\pgfkeys{/handlers/.estyle args/.code 2 args=\pgfkeys{\pgfkeyscurrentpath/.ecode args={#1}{\noexpand\pgfkeysalso{#2}}}} |
| 800 |
\pgfkeys{/handlers/.style 2 args/.code=\pgfkeys{\pgfkeyscurrentpath/.code 2 args=\pgfkeysalso{#1}}} |
| 801 |
\pgfkeys{/handlers/.style n args/.code 2 args=\pgfkeys{\pgfkeyscurrentpath/.code n args={#1}{\pgfkeysalso{#2}}}} |
| 802 |
|
| 803 |
% Adding to a style |
| 804 |
|
| 805 |
\pgfkeys{/handlers/.add style/.code 2 args=\pgfkeys{\pgfkeyscurrentpath/.add code={\pgfkeysalso{#1}}{\pgfkeysalso{#2}}}}% |
| 806 |
\pgfkeys{/handlers/.prefix style/.code=\pgfkeys{\pgfkeyscurrentpath/.add code={\pgfkeysalso{#1}}{}}}% |
| 807 |
\pgfkeys{/handlers/.append style/.code=\pgfkeys{\pgfkeyscurrentpath/.add code={}{\pgfkeysalso{#1}}}}% |
| 808 |
|
| 809 |
|
| 810 |
% Defining a value |
| 811 |
|
| 812 |
\pgfkeys{/handlers/.initial/.code=\pgfkeyssetvalue{\pgfkeyscurrentpath}{#1}} |
| 813 |
\pgfkeys{/handlers/.add/.code 2 args=\pgfkeysaddvalue{\pgfkeyscurrentpath}{#1}{#2}} |
| 814 |
\pgfkeys{/handlers/.prefix/.code=\pgfkeysaddvalue{\pgfkeyscurrentpath}{#1}{}} |
| 815 |
\pgfkeys{/handlers/.append/.code=\pgfkeysaddvalue{\pgfkeyscurrentpath}{}{#1}} |
| 816 |
\pgfkeys{/handlers/.get/.code=\pgfkeysgetvalue{\pgfkeyscurrentpath}{#1}} |
| 817 |
\pgfkeys{/handlers/.link/.code=\pgfkeyssetvalue{\pgfkeyscurrentpath}{\pgfkeysvalueof{#1}}} |
| 818 |
|
| 819 |
|
| 820 |
% Defining a default |
| 821 |
|
| 822 |
\pgfkeys{/handlers/.default/.code=\pgfkeyssetvalue{\pgfkeyscurrentpath/.@def}{#1}} |
| 823 |
\pgfkeys{/handlers/.value required/.code=\pgfkeyssetvalue{\pgfkeyscurrentpath/.@def}{\pgfkeysvaluerequired}} |
| 824 |
\pgfkeys{/handlers/.value forbidden/.code=\pgfkeys{\pgfkeyscurrentpath/.add code=% |
| 825 |
{% |
| 826 |
\ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% |
| 827 |
\else% |
| 828 |
\pgfkeysvalueof{/errors/value forbidden/.@cmd}\pgfkeyscurrentkey\pgfkeyscurrentvalue\pgfeov% |
| 829 |
\fi% |
| 830 |
}{}}} |
| 831 |
|
| 832 |
|
| 833 |
% High-level cmds |
| 834 |
|
| 835 |
\pgfkeys{/handlers/.store in/.code=\pgfkeysalso{\pgfkeyscurrentpath/.code=\def#1{##1}}} |
| 836 |
\pgfkeys{/handlers/.estore in/.code=\pgfkeysalso{\pgfkeyscurrentpath/.code=\edef#1{##1}}} |
| 837 |
|
| 838 |
\pgfkeys{/handlers/.is if/.code=\pgfkeysalso{% |
| 839 |
\pgfkeyscurrentpath/.code=\pgfkeys@handle@boolean{#1}{##1}, |
| 840 |
\pgfkeyscurrentpath/.default=true% |
| 841 |
}% |
| 842 |
} |
| 843 |
\def\pgfkeys@handle@boolean#1#2{% |
| 844 |
\pgfkeys@ifcsname#1#2\endcsname% |
| 845 |
\csname#1#2\endcsname% |
| 846 |
\else% |
| 847 |
\pgfkeysvalueof{/errors/boolean expected/.@cmd}\pgfkeyscurrentkey{#2}\pgfeov% |
| 848 |
\fi |
| 849 |
} |
| 850 |
|
| 851 |
\pgfkeys{/handlers/.is choice/.code=% |
| 852 |
\pgfkeys{% |
| 853 |
\pgfkeyscurrentpath/.cd,% |
| 854 |
.code=\expandafter\pgfkeysalso\expandafter{\pgfkeyscurrentkey/##1}, |
| 855 |
.unknown/.style={/errors/unknown choice value=\pgfkeyscurrentkey\pgfkeyscurrentvalue}}} |
| 856 |
|
| 857 |
|
| 858 |
% Repeatedly setting a key |
| 859 |
|
| 860 |
\pgfkeys{/handlers/.list/.code=% |
| 861 |
{% |
| 862 |
% Use foreach to unfold the list |
| 863 |
\let\pgf@keys@temp=\pgfutil@empty% |
| 864 |
\foreach \pgf@keys@key in{#1}% |
| 865 |
{\expandafter\expandafter\expandafter\gdef% |
| 866 |
\expandafter\expandafter\expandafter\pgf@keys@temp% |
| 867 |
\expandafter\expandafter\expandafter{\expandafter\pgf@keys@temp\expandafter{\pgf@keys@key}}}% |
| 868 |
\edef\pgf@keys@list@path{\pgfkeyscurrentpath}% |
| 869 |
\expandafter\expandafter\expandafter\pgf@keys@do@list% |
| 870 |
\expandafter\expandafter\expandafter{\expandafter\pgf@keys@list@path\expandafter}\pgf@keys@temp\pgf@stop% |
| 871 |
}% |
| 872 |
} |
| 873 |
\def\pgf@keys@do@list#1{\pgfutil@ifnextchar\bgroup{\pgf@keys@do@list@item{#1}}\pgfutil@gobble} |
| 874 |
\def\pgf@keys@do@list@item#1#2{\pgfkeysalso{#1={#2}}\pgf@keys@do@list{#1}} |
| 875 |
|
| 876 |
|
| 877 |
% Forwarding |
| 878 |
|
| 879 |
\pgfkeys{/handlers/.forward to/.code=% |
| 880 |
\pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}{}{\pgfkeysdef{\pgfkeyscurrentpath}{}} |
| 881 |
\pgfkeys{\pgfkeyscurrentpath/.add code={}{\pgfkeys{#1={##1}}}} |
| 882 |
} |
| 883 |
|
| 884 |
|
| 885 |
% Inspection handlers |
| 886 |
|
| 887 |
\pgfkeys{/handlers/.show value/.code=\pgfkeysgetvalue{\pgfkeyscurrentpath}{\pgfkeysshower}\show\pgfkeysshower} % inspect the value |
| 888 |
\pgfkeys{/handlers/.show code/.code=\pgfkeysgetvalue{\pgfkeyscurrentpath/.@cmd}{\pgfkeysshower}\show\pgfkeysshower} % inspect the body of the command |
| 889 |
|
| 890 |
|
| 891 |
% First char syntax handlers |
| 892 |
\pgfkeys{/handlers/first char syntax/.is if=pgfkeys@syntax@handlers} |
| 893 |
|
| 894 |
% Path handling |
| 895 |
|
| 896 |
% Prepares the .unknown handler used by '.search also'. |
| 897 |
% It will be stored into \pgfkeys@global@temp. |
| 898 |
\def\pgfkeys@searchalso@prepare@unknown@handler#1{% |
| 899 |
\global\def\pgfkeys@global@temp##1\pgfeov{}% |
| 900 |
\pgfkeys@searchalso@parse#1,\pgfkeys@mainstop |
| 901 |
{% |
| 902 |
\toks0=\expandafter{\pgfkeys@global@temp##1\pgfeov}% |
| 903 |
\toks1={\def\pgfutilnext{\pgfkeysvalueof{/handlers/.unknown/.@cmd}##1\pgfeov}\pgfutilnext}% |
| 904 |
\xdef\pgfkeys@global@temp{% |
| 905 |
\noexpand\ifpgfkeysaddeddefaultpath |
| 906 |
\noexpand\pgfkeyssuccessfalse |
| 907 |
\noexpand\let\noexpand\pgfkeys@searchalso@name=\noexpand\pgfkeyscurrentkeyRAW |
| 908 |
\the\toks0 % one or more /.try things; one for each path. The last element won't have a /.try |
| 909 |
%\noexpand\ifpgfkeyssuccess |
| 910 |
%\noexpand\else |
| 911 |
% \the\toks1 % invoke /handlers/.unknown handler |
| 912 |
%\noexpand\fi |
| 913 |
\noexpand\else |
| 914 |
\the\toks1 % invoke /handlers/.unknown handler |
| 915 |
\noexpand\fi |
| 916 |
}% |
| 917 |
\expandafter\gdef\expandafter\pgfkeys@global@temp\expandafter##\expandafter1\expandafter\pgfeov\expandafter{\pgfkeys@global@temp}% |
| 918 |
}% |
| 919 |
}% |
| 920 |
|
| 921 |
\def\pgfkeys@searchalso@parse{\futurelet\pgfkeys@possiblerelax\pgfkeys@searchalso@parse@main} |
| 922 |
\def\pgfkeys@searchalso@parse@main{% |
| 923 |
\ifx\pgfkeys@possiblerelax\pgfkeys@mainstop% |
| 924 |
\expandafter\pgfkeys@cleanup% |
| 925 |
\else% |
| 926 |
\expandafter\pgfkeys@searchalso@appendentry% |
| 927 |
\fi% |
| 928 |
} |
| 929 |
\def\pgfkeys@searchalso@appendentry#1,#2{% |
| 930 |
\def\pgfkeys@searchalso@nexttok{#2}% |
| 931 |
\pgfkeys@spdef\pgfkeys@temp{#1}% |
| 932 |
{% |
| 933 |
\toks0=\expandafter{\pgfkeys@global@temp##1\pgfeov}% |
| 934 |
\toks1=\expandafter{\pgfkeys@temp}% |
| 935 |
\toks2={##1}% |
| 936 |
\xdef\pgfkeys@global@temp{% |
| 937 |
\the\toks0 % the space is important! |
| 938 |
\noexpand\ifpgfkeyssuccess\noexpand\else |
| 939 |
\noexpand\pgfqkeys{\the\toks1 }{\noexpand\pgfkeys@searchalso@name |
| 940 |
\ifx\pgfkeys@searchalso@nexttok\pgfkeys@mainstop\else/.try\fi={\the\toks2 }}% |
| 941 |
\noexpand\fi}% |
| 942 |
\expandafter\gdef\expandafter\pgfkeys@global@temp\expandafter##\expandafter1\expandafter\pgfeov\expandafter{\pgfkeys@global@temp}% |
| 943 |
}% |
| 944 |
\pgfkeys@searchalso@parse#2% |
| 945 |
} |
| 946 |
\pgfkeys{% |
| 947 |
/handlers/.is family/.code=\pgfkeys{\pgfkeyscurrentpath/.ecode=\edef\noexpand\pgfkeysdefaultpath{\pgfkeyscurrentpath/}},% |
| 948 |
/handlers/.cd/.code=\edef\pgfkeysdefaultpath{\pgfkeyscurrentpath/},% |
| 949 |
/handlers/.search also/.code={% |
| 950 |
\pgfkeys@searchalso@prepare@unknown@handler{#1}% |
| 951 |
%\message{I prepared the '\pgfkeyscurrentpath/.unknown' handler \meaning\pgfkeys@global@temp\space for '#1'.}% |
| 952 |
\pgfkeyslet{\pgfkeyscurrentpath/.unknown/.@cmd}{\pgfkeys@global@temp}% |
| 953 |
} |
| 954 |
}% |
| 955 |
|
| 956 |
|
| 957 |
% Value expansion |
| 958 |
|
| 959 |
\pgfkeys{/handlers/.expand once/.code=\expandafter\pgfkeys@exp@call\expandafter{#1}} |
| 960 |
\pgfkeys{/handlers/.expand twice/.code=\expandafter\expandafter\expandafter\pgfkeys@exp@call\expandafter\expandafter\expandafter{#1}} |
| 961 |
\pgfkeys{/handlers/.expanded/.code=\edef\pgfkeys@temp{#1}\expandafter\pgfkeys@exp@call\expandafter{\pgfkeys@temp}} |
| 962 |
|
| 963 |
\long\def\pgfkeys@exp@call#1{\pgfkeysalso{\pgfkeyscurrentpath={#1}}} |
| 964 |
|
| 965 |
% Try to set a key and do nothing if not define |
| 966 |
|
| 967 |
\newif\ifpgfkeyssuccess |
| 968 |
\pgfkeys{/handlers/.try/.code=\pgfkeys@try} |
| 969 |
\pgfkeys{/handlers/.retry/.code=\ifpgfkeyssuccess\else\pgfkeys@try\fi} |
| 970 |
\def\pgfkeys@try{% |
| 971 |
\edef\pgfkeyscurrentkey{\pgfkeyscurrentpath}% make sure that \pgfkeys@code doesn't know about 'try'. Important for .is choice |
| 972 |
\ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% Hmm... no value |
| 973 |
\pgfkeysifdefined{\pgfkeyscurrentpath/.@def}% |
| 974 |
{\pgfkeysgetvalue{\pgfkeyscurrentpath/.@def}{\pgfkeyscurrentvalue}} |
| 975 |
{}% no default, so leave it |
| 976 |
\fi% |
| 977 |
\pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}% |
| 978 |
{% |
| 979 |
\pgfkeysgetvalue{\pgfkeyscurrentpath/.@cmd}{\pgfkeys@code}% |
| 980 |
\expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov% |
| 981 |
\pgfkeyssuccesstrue% |
| 982 |
}% |
| 983 |
{% |
| 984 |
\pgfkeysifdefined{\pgfkeyscurrentpath}% |
| 985 |
{% |
| 986 |
\ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% |
| 987 |
\pgfkeysvalueof{\pgfkeyscurrentpath}% |
| 988 |
\else% |
| 989 |
\pgfkeyslet{\pgfkeyscurrentpath}\pgfkeyscurrentvalue% |
| 990 |
\fi% |
| 991 |
\pgfkeyssuccesstrue% |
| 992 |
}% |
| 993 |
{% |
| 994 |
\pgfkeys@split@path% |
| 995 |
\pgfkeysifdefined{/handlers/\pgfkeyscurrentname/.@cmd}{% |
| 996 |
% in the standard configuration, this check here is redundand |
| 997 |
% because pgfkeys@ifexecutehandler === true. |
| 998 |
% It is only interesting for 'handle only existing'. |
| 999 |
\pgfkeys@ifexecutehandler{% |
| 1000 |
\pgfkeysgetvalue{/handlers/\pgfkeyscurrentname/.@cmd}{\pgfkeys@code}% |
| 1001 |
\expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov |
| 1002 |
\pgfkeyssuccesstrue% |
| 1003 |
}{% |
| 1004 |
\pgfkeyssuccessfalse |
| 1005 |
}% |
| 1006 |
}{% |
| 1007 |
\pgfkeyssuccessfalse |
| 1008 |
}% |
| 1009 |
}% |
| 1010 |
}% |
| 1011 |
} |
| 1012 |
|
| 1013 |
% Utilities |
| 1014 |
|
| 1015 |
\pgfkeys{/utils/exec/.code=#1} % simply execute the given code directly. |
| 1016 |
|
| 1017 |
|
| 1018 |
% Errors |
| 1019 |
|
| 1020 |
\pgfkeys{/errors/boolean expected/.code 2 args=\pgfkeys@error{% |
| 1021 |
Boolean parameter of key '#1' must be 'true' or 'false', not |
| 1022 |
'#2'. I am going to ignore it}} |
| 1023 |
\pgfkeys{/errors/value required/.code 2 args=\pgfkeys@error{% |
| 1024 |
The key '#1' requires a value. I am going to ignore this key}{}} |
| 1025 |
\pgfkeys{/errors/value forbidden/.code 2 args=\pgfkeys@error{% |
| 1026 |
You may not specify a value for the key '#1'. I am going to ignore |
| 1027 |
the value '#2' that you provided}} |
| 1028 |
\pgfkeys{/errors/unknown choice value/.code 2 args=\pgfkeys@error{% |
| 1029 |
Choice '\pgfkeyscurrentname' unknown in key |
| 1030 |
'\pgfkeyscurrentpath'. I am going to ignore this key}} |
| 1031 |
\pgfkeys{/errors/unknown key/.code 2 args=\pgfkeys@error{% |
| 1032 |
I do not know the key '#1' and I am going to ignore it. Perhaps |
| 1033 |
you misspelled it}} |
| 1034 |
|
| 1035 |
\pgfkeys{/handlers/.unknown/.code=% |
| 1036 |
{% |
| 1037 |
\let\pgfkeys@orig@key=\pgfkeyscurrentkey% |
| 1038 |
\pgfkeysalso{/errors/unknown key=\pgfkeys@orig@key{}}% |
| 1039 |
} |
| 1040 |
} |
| 1041 |
|
| 1042 |
\pgfkeys{ |
| 1043 |
/handler config/.is choice, |
| 1044 |
/handler config/all/.code={% |
| 1045 |
\let\pgfkeys@case@three=\pgfkeys@case@three@handleall |
| 1046 |
\let\pgfkeys@ifexecutehandler=\pgfkeys@ifexecutehandler@handleall |
| 1047 |
}, |
| 1048 |
/handler config/only existing/.code={% |
| 1049 |
\let\pgfkeys@case@three=\pgfkeys@case@three@handle@restricted |
| 1050 |
\let\pgfkeys@ifexecutehandler=\pgfkeys@ifexecutehandler@handleonlyexisting |
| 1051 |
}, |
| 1052 |
/handler config/full or existing/.code={% |
| 1053 |
\let\pgfkeys@case@three=\pgfkeys@case@three@handle@restricted |
| 1054 |
\let\pgfkeys@ifexecutehandler=\pgfkeys@ifexecutehandler@handlefullorexisting |
| 1055 |
}, |
| 1056 |
/handler config/only existing/add exception/.code={\pgfkeysaddhandleonlyexistingexception{#1}}, |
| 1057 |
}% |
| 1058 |
\pgfkeysaddhandleonlyexistingexception{.cd}% |
| 1059 |
\pgfkeysaddhandleonlyexistingexception{.try}% |
| 1060 |
\pgfkeysaddhandleonlyexistingexception{.retry}% |
| 1061 |
\pgfkeysaddhandleonlyexistingexception{.lastretry}% |
| 1062 |
\pgfkeysaddhandleonlyexistingexception{.unknown}% |
| 1063 |
|
| 1064 |
|
| 1065 |
\input pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex |
| 1066 |
|
| 1067 |
\endinput |