| 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: Sa 7. Dez 20:58:23 CET 2013 %%% |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
%-------------------------------------------- |
| 27 |
% |
| 28 |
% Package pgfplots |
| 29 |
% |
| 30 |
% Provides a user-friendly interface to create function plots (normal |
| 31 |
% plots, semi-logplots and double-logplots). |
| 32 |
% |
| 33 |
% It is based on Till Tantau's PGF package. |
| 34 |
% |
| 35 |
% Copyright 2007/2008/2009 by Christian Feuersänger. |
| 36 |
% |
| 37 |
% This program is free software: you can redistribute it and/or modify |
| 38 |
% it under the terms of the GNU General Public License as published by |
| 39 |
% the Free Software Foundation, either version 3 of the License, or |
| 40 |
% (at your option) any later version. |
| 41 |
% |
| 42 |
% This program is distributed in the hope that it will be useful, |
| 43 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 44 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 45 |
% GNU General Public License for more details. |
| 46 |
% |
| 47 |
% You should have received a copy of the GNU General Public License |
| 48 |
% along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 49 |
% |
| 50 |
%-------------------------------------------- |
| 51 |
|
| 52 |
% this is some kind of "plug-in" for pgfmanual-en-macros.tex which |
| 53 |
% provides pretty printing of the code lines in 'codeexample'. |
| 54 |
% |
| 55 |
% It requires to be invoked with \pgfmanualprettyprintcode{#1} at the |
| 56 |
% right place. |
| 57 |
% |
| 58 |
% ATTENTION: |
| 59 |
% this is NOT a sophisticated syntax highlighter like lstlistings! |
| 60 |
% It has rather strict assumptions about how to use it (the input must |
| 61 |
% have been read verbatim, for example). |
| 62 |
|
| 63 |
% Special code for syntax highlighting: |
| 64 |
% |
| 65 |
% |
| 66 |
% USER INTERFACE |
| 67 |
\pgfkeys{% |
| 68 |
% this is the public hook into |
| 69 |
% \begin{codeexample}...\end{codeexample} which triggers pretty |
| 70 |
% printing: |
| 71 |
/codeexample/typeset listing/.code= {\pgfmanualprettyprintcode{#1}}, |
| 72 |
% |
| 73 |
% this key will be invoked whenever a key in key-value context has been identified. |
| 74 |
% |
| 75 |
% It won't be invoked for handled keys like |my style/.style=....|, see below. |
| 76 |
% |
| 77 |
% #1 will be the keys name. |
| 78 |
/codeexample/prettyprint/key name/.code={#1}, |
| 79 |
% |
| 80 |
% A variant which will be used instead of |key name| if the key |
| 81 |
% has a key handler. For example, when the pretty printer finds |
| 82 |
% |my style/.style|, it will call |
| 83 |
% |key name with handler={my style}{.style}. |
| 84 |
/codeexample/prettyprint/key name with handler/.code 2 args={#1/#2}, |
| 85 |
% |
| 86 |
% Will be invoked whenever the value of a key has been found. |
| 87 |
% It will be invoked AFTER 'key name' and not at all if there was |
| 88 |
% no value. |
| 89 |
% |
| 90 |
% #1: the key's name |
| 91 |
% #2: the key's value. |
| 92 |
% |
| 93 |
% The default implementation checks if there is a special handler |
| 94 |
% for the key name '#1', in |
| 95 |
% /codeexample/prettyprint/key value/#1. |
| 96 |
% For example: |
| 97 |
% /codeexample/prettyprint/key value/my key/.code 2 args={name=#1, value =#2} |
| 98 |
% If such a key exists, it will be invoked with {#1}{#2} as |
| 99 |
% arguments. Otherwise, the generic method |
| 100 |
% /codeexample/prettyprint/key value with style detection={#1}{#2} |
| 101 |
% will be invoked. |
| 102 |
/codeexample/prettyprint/key value/.code 2 args={% |
| 103 |
\pgfkeysifdefined{/codeexample/prettyprint/key value/#1}{% |
| 104 |
\pgfkeysalso{/codeexample/prettyprint/key value/#1={#1}{#2}}% |
| 105 |
}{% |
| 106 |
\pgfkeysalso{/codeexample/prettyprint/key value with style detection={#1}{#2}}% |
| 107 |
}% |
| 108 |
}, |
| 109 |
% A helper macro for the default 'key value' implementation. |
| 110 |
/codeexample/prettyprint/key value with style detection/.code 2 args={% |
| 111 |
\pgfutil@in@{style}{#1}% |
| 112 |
\ifpgfutil@in@ |
| 113 |
\pgfmanualprettyprintpgfkeys{#2}% |
| 114 |
\else |
| 115 |
\pgfkeysalso{/codeexample/prettyprint/key value display only={#2}}% |
| 116 |
\fi |
| 117 |
},% |
| 118 |
% |
| 119 |
% Will be invoked by the default 'key value' implementation to |
| 120 |
% typeset the value as such. |
| 121 |
/codeexample/prettyprint/key value display only/.code={#1}, |
| 122 |
% |
| 123 |
% Used to typeset a single word. A word is something which has not |
| 124 |
% been identified in any other context; a maximal sequence of |
| 125 |
% non-white-space tokens. |
| 126 |
/codeexample/prettyprint/word/.code={#1}, |
| 127 |
% |
| 128 |
% A two-argument code key which invokes '#1' if spaces shall |
| 129 |
% delimit words and '#2' if not. |
| 130 |
% This may be useless. Handle with care! |
| 131 |
/codeexample/prettyprint/if space is word delim/.code 2 args={% |
| 132 |
#1% |
| 133 |
},% |
| 134 |
% |
| 135 |
% A three-argument code key which should invoke '#2' if the single |
| 136 |
% token '#1' is a word delimiter and '#3' if that is not the case. |
| 137 |
% Note that '#1' doesn't have the usual catcodes (see the |
| 138 |
% \pgfmanual@pretty@** macros)! |
| 139 |
% Furthermore, white spaces are treated separately. |
| 140 |
/codeexample/prettyprint/if is word delim/.code args={#1#2#3}{% |
| 141 |
\edef\pgfmanual@check{,;().;\pgfmanual@pretty@lbrace\pgfmanual@pretty@rbrace}% |
| 142 |
\def\pgfmanual@check@{\pgfutil@in@{#1}}% |
| 143 |
\expandafter\pgfmanual@check@\expandafter{\pgfmanual@check}% |
| 144 |
\ifpgfutil@in@ #2\else #3\fi |
| 145 |
},% |
| 146 |
% |
| 147 |
% Used to typeset a single control sequence. |
| 148 |
% #1 is the control sequence's name as a sequence of catcode 12 |
| 149 |
% tokens. |
| 150 |
/codeexample/prettyprint/cs/.code={#1}, |
| 151 |
% |
| 152 |
% Used to typeset a single control sequence together with one or |
| 153 |
% more arguments. |
| 154 |
% |
| 155 |
% #1 is the control sequence's name (including the backslash as |
| 156 |
% literal string) and |
| 157 |
% #2,#3,...,#9 are the arguments. The number of arguments depends |
| 158 |
% on the 'cs arguments/<CS NAME>' key; it contains the integer |
| 159 |
% number. |
| 160 |
% |
| 161 |
% For example, if |
| 162 |
% |cs arguments/pgfkeys/.initial=1|, |
| 163 |
% the pretty printer invokes |
| 164 |
% |cs with args={\pgfkeys}{<argument>}. |
| 165 |
% |
| 166 |
% If |
| 167 |
% |cs arguments/mycommand/.initial=2|, |
| 168 |
% the pretty printer invokes |
| 169 |
% |cs with args={\pgfkeys}{<argument1>}{<argument2>}. |
| 170 |
% In this case, 'cs with args' needs to be defined in a way which |
| 171 |
% allows to deal with 3 arguments. |
| 172 |
% |
| 173 |
% Please note that the value do not contain braces! The braces |
| 174 |
% need to be inserted manually. |
| 175 |
% |
| 176 |
% Special cases: |
| 177 |
% 1. If end-of-input is encountered BEFORE the expected number of |
| 178 |
% arguments has been found, the following happens: |
| 179 |
% - if not even one (partial) argument has been found, the |
| 180 |
% /codeexample/prettyprint/cs/.@cmd key will be used instead. |
| 181 |
% - the \ifpgfmanualprettyprinterarghasunmatchedbraces boolean |
| 182 |
% indicates if the trailing brace is missing. |
| 183 |
/codeexample/prettyprint/cs with args/.code 2 args={#1\{#2\pgfmanualclosebrace}, |
| 184 |
% |
| 185 |
% For every identified control sequence, the key |
| 186 |
% /codeexample/prettyprint/cs arguments/<CSNAME> |
| 187 |
% will be checked. If it exists, it contains an integer with the |
| 188 |
% number of arguments it takes. |
| 189 |
% The <CSNAME> must not contain the '\'. |
| 190 |
/codeexample/prettyprint/cs arguments/pgfkeys/.initial=1, |
| 191 |
% |
| 192 |
% For every identified control sequence, the key |
| 193 |
% /codeexample/prettyprint/cs/<CSNAME>/.@cmd |
| 194 |
% will be checked. If it exists, it will be used instead of |
| 195 |
% 'cs with args' (with the same special case restrictions for |
| 196 |
% early end-of-input). |
| 197 |
% |
| 198 |
% The <CSNAME> must not contain the '\'. |
| 199 |
% |
| 200 |
% This allows special treatment for special |
| 201 |
% commands like \pgfkeys: |
| 202 |
/codeexample/prettyprint/cs/pgfkeys/.code 2 args={#1\{\pgfmanualprettyprintpgfkeys{#2}\pgfmanualclosebrace}, |
| 203 |
% |
| 204 |
% recognise environments: |
| 205 |
/codeexample/prettyprint/cs arguments/begin/.initial=1, |
| 206 |
/codeexample/prettyprint/cs/begin/.code 2 args={#1\{#2\pgfmanualclosebrace}, |
| 207 |
/codeexample/prettyprint/cs arguments/end/.initial=1, |
| 208 |
/codeexample/prettyprint/cs/end/.code 2 args={#1\{#2\pgfmanualclosebrace}, |
| 209 |
% |
| 210 |
% a point coordinate (#1) |
| 211 |
% Note that '#1' will contain the braces (if there was one), |
| 212 |
/codeexample/prettyprint/point/.code={#1},% |
| 213 |
% |
| 214 |
% a point coordinate with explicit coordinate system: (#1:#2) |
| 215 |
% Note that '#2' will contain the terminating brace (if there was one) |
| 216 |
% #1: the coordinate system name (*without* the leading brace). |
| 217 |
% The leading brace must be re-inserted by this style. |
| 218 |
/codeexample/prettyprint/point with cs/.code 2 args={(#1:#2},% |
| 219 |
% the same with specialised code: |
| 220 |
%/codeexample/prettyprint/point with cs/<CS NAME>/.code 2 args={(#1:#2},% |
| 221 |
% |
| 222 |
% |
| 223 |
% A predefined style which colors every identified token. It's |
| 224 |
% purpose is only debugging. |
| 225 |
/codeexample/prettyprint/colored/.style={% |
| 226 |
/codeexample/prettyprint/key name/.code={\textcolor{red!75!black}{##1}}, |
| 227 |
/codeexample/prettyprint/key name with handler/.code 2 args={\textcolor{red!75!black}{##1}/\textcolor{red!90!black}{##2}}, |
| 228 |
/codeexample/prettyprint/key value display only/.code={\textcolor{yellow}{##1}}, |
| 229 |
/codeexample/prettyprint/cs/.code={\textcolor{green}{##1}}, |
| 230 |
/codeexample/prettyprint/cs with args/.code 2 args={\textcolor{green}{##1}\{\textcolor{orange}{##2}\pgfmanualclosebrace}, |
| 231 |
/codeexample/prettyprint/cs arguments/pgfkeys/.initial=1, |
| 232 |
/codeexample/prettyprint/cs/pgfkeys/.code 2 args={\textcolor{green}{##1}\{\pgfmanualprettyprintpgfkeys{##2}\pgfmanualclosebrace}, |
| 233 |
/codeexample/prettyprint/cs arguments/begin/.initial=1, |
| 234 |
/codeexample/prettyprint/cs/begin/.code 2 args={\textcolor{green}{##1}\{\textcolor{orange}{##2}\pgfmanualclosebrace}, |
| 235 |
/codeexample/prettyprint/cs arguments/end/.initial=1, |
| 236 |
/codeexample/prettyprint/cs/end/.code 2 args={\textcolor{green}{##1}\{\textcolor{orange}{##2}\pgfmanualclosebrace}, |
| 237 |
/codeexample/prettyprint/word/.code={\textcolor{brown}{##1}}, |
| 238 |
/codeexample/prettyprint/point/.code={\textcolor{red}{##1}},% |
| 239 |
/codeexample/prettyprint/point with cs/.code 2 args={(\textcolor{green}{##1}:\textcolor{red}{##2}},% |
| 240 |
},% |
| 241 |
% A further debuggin helper. |
| 242 |
/codeexample/prettyprint/colored and verbose/.style={% |
| 243 |
/codeexample/prettyprint/colored, |
| 244 |
/codeexample/prettyprint/key name/.code={\message{[key name=##1]}\textcolor{red!75!black}{##1}}, |
| 245 |
/codeexample/prettyprint/key name with handler/.code 2 args={\message{[key name with handler=##1/##2]}\textcolor{red!75!black}{##1}/\textcolor{red!90!black}{##2}}, |
| 246 |
/codeexample/prettyprint/key value display only/.code={\def\temp{##1}\message{[key value=\meaning\temp]}\textcolor{yellow}{##1}}, |
| 247 |
/codeexample/prettyprint/cs/.code={\message{[cs=##1]}\textcolor{green}{##1}}, |
| 248 |
/codeexample/prettyprint/cs with args/.code 2 args={\def\temp{##2}\message{[cs with args={##1}{\meaning\temp}]}\textcolor{green}{##1}\{\textcolor{orange}{##2}\pgfmanualclosebrace}, |
| 249 |
/codeexample/prettyprint/word/.code={\message{[word=##1]}\textcolor{brown}{##1}}, |
| 250 |
/codeexample/prettyprint/point/.code={\message{[point=##1]}\textcolor{red}{##1}},% |
| 251 |
/codeexample/prettyprint/point with cs/.code 2 args={\message{[point with cs={##1}{##2}]}(\textcolor{green}{##1}:\textcolor{red}{##2}},% |
| 252 |
},% |
| 253 |
%/codeexample/prettyprint/colored, |
| 254 |
%/codeexample/prettyprint/colored and verbose, |
| 255 |
}% |
| 256 |
|
| 257 |
\newif\ifpgfmanualprettyenabled |
| 258 |
\pgfmanualprettyenabledtrue |
| 259 |
|
| 260 |
% User interface command to handle unmatched braces: |
| 261 |
% |
| 262 |
% It expands to '\}' unless the preceding argument had unmatched braces. |
| 263 |
\def\pgfmanualclosebrace{% |
| 264 |
\ifpgfmanualprettyprinterarghasunmatchedbraces |
| 265 |
\else |
| 266 |
\}% |
| 267 |
\fi |
| 268 |
}% |
| 269 |
|
| 270 |
|
| 271 |
% Typesets '#1', possibly using some sort of pretty printer. |
| 272 |
% |
| 273 |
% The argument '#1' is expected to be a long token list in which |
| 274 |
% 1. all characters have catcode 11 or 12 (normal letters), |
| 275 |
% 2. white spaces, tabs and newlines have catcode 13 (are active). |
| 276 |
% |
| 277 |
% @see \pgfmanualprettyprintpgfkeys |
| 278 |
\long\def\pgfmanualprettyprintcode#1{% |
| 279 |
%\def\temp{#1}\message{STARTING PRETTY PRINTING for \meaning\temp}% |
| 280 |
\ifpgfmanualprettyenabled |
| 281 |
\begingroup |
| 282 |
\pgfmanualprettyprintstyles |
| 283 |
\pgfmanual@pretty@mainloop#1\pgfmanual@EOI |
| 284 |
\endgroup |
| 285 |
\else |
| 286 |
#1% |
| 287 |
\fi |
| 288 |
}% |
| 289 |
% DISABLE: |
| 290 |
%\long\def\pgfmanualprettyprintcode#1{#1}% |
| 291 |
|
| 292 |
\def\pgfmanualprettyprintstyles{% |
| 293 |
%\tracingmacros=2 \tracingcommands=2 \message{PRETTYPRINT INIT}% |
| 294 |
\def\{{\pgfmanual@pretty@lbrace}% |
| 295 |
\def\}{\pgfmanual@pretty@rbrace}% |
| 296 |
\pgfmanual@pretty@installcommenthandler |
| 297 |
\let\pgfmanualprettyprintstyles=\relax |
| 298 |
}% |
| 299 |
|
| 300 |
|
| 301 |
\newif\ifpgfmanualprettycommentactive |
| 302 |
|
| 303 |
% we can't use the \@typeset@till@return method for comments because |
| 304 |
% the pretty printer needs full control over the token list. |
| 305 |
% |
| 306 |
% We try a replacement here. |
| 307 |
% |
| 308 |
% FIXME |
| 309 |
% THIS INTRODUCES A NEW GROUP! Does that hurt the pretty printer?? |
| 310 |
% |
| 311 |
\def\pgfmanual@pretty@installcommenthandler{% |
| 312 |
\expandafter\def\pgfmanual@pretty@activepercent{% |
| 313 |
\begingroup |
| 314 |
\pgfmanualprettycommentactivetrue |
| 315 |
\expandafter\let\pgfmanual@pretty@activenl=\pgfmanual@pretty@recoveraftercomment |
| 316 |
\expandafter\def\pgfmanual@pretty@activepercent{\%}% |
| 317 |
%\tt |
| 318 |
\% % |
| 319 |
}% |
| 320 |
}% |
| 321 |
\def\pgfmanual@pretty@recoveraftercomment{% |
| 322 |
\endgroup |
| 323 |
\pgfmanual@pretty@activenl |
| 324 |
}% |
| 325 |
|
| 326 |
\def\pgfmanual@EOI{\pgfmanual@EOI}% |
| 327 |
|
| 328 |
{ |
| 329 |
\catcode`\[=0 |
| 330 |
\catcode`\\=12 |
| 331 |
[gdef[pgfmanual@pretty@backslash{\}% |
| 332 |
} |
| 333 |
\begingroup |
| 334 |
\catcode`\:=12 |
| 335 |
\catcode`\(=12 |
| 336 |
\catcode`\)=12 |
| 337 |
\gdef\pgfmanual@pretty@colon{:}% |
| 338 |
\gdef\pgfmanual@pretty@lroundbrace{(}% |
| 339 |
\gdef\pgfmanual@pretty@rroundbrace{)}% |
| 340 |
\catcode`\[=1 |
| 341 |
\catcode`\]=2 |
| 342 |
\catcode`\{=12 |
| 343 |
\catcode`\}=12 |
| 344 |
\gdef\pgfmanual@pretty@lbrace[{]% |
| 345 |
\gdef\pgfmanual@pretty@rbrace[}]% |
| 346 |
\catcode`\{=1 |
| 347 |
\catcode`\}=2 |
| 348 |
\catcode`\[=12 |
| 349 |
\catcode`\]=12 |
| 350 |
\catcode`\,=12 |
| 351 |
\catcode`\ =10\relax\gdef\pgfmanual@pretty@space{ }% |
| 352 |
\gdef\pgfmanual@pretty@lbracket{[}% |
| 353 |
\gdef\pgfmanual@pretty@rbracket{]}% |
| 354 |
\gdef\pgfmanual@pretty@comma{,}% |
| 355 |
\catcode`\==12 |
| 356 |
\gdef\pgfmanual@pretty@eq{=}% |
| 357 |
\endgroup |
| 358 |
\begingroup |
| 359 |
\catcode`\%=12 |
| 360 |
\gdef\pgfmanual@pretty@percent{%} |
| 361 |
\catcode`\%=13 |
| 362 |
\gdef\pgfmanual@pretty@activepercent{%} |
| 363 |
\catcode`\^^M=13 |
| 364 |
\gdef\pgfmanual@pretty@activenl{^^M}\endgroup |
| 365 |
\begingroup |
| 366 |
\catcode`\^^I=13\relax\gdef\pgfmanual@pretty@activetab{^^I}% |
| 367 |
\catcode`\ =13\relax\gdef\pgfmanual@pretty@activespace{ }\endgroup |
| 368 |
|
| 369 |
% loops through all tokens. |
| 370 |
% #1 is a single token. |
| 371 |
\def\pgfmanual@pretty@mainloop{% |
| 372 |
\def\pgfmanual@pretty@mainloop@currentword{}% |
| 373 |
\pgfmanual@pretty@mainloop@ |
| 374 |
}% |
| 375 |
\long\def\pgfmanual@pretty@mainloop@#1{% |
| 376 |
\def\pgfmanual@loc@TMPa{#1}% |
| 377 |
\let\pgfmanual@pretty@mainloop@NEXT=\pgfmanual@pretty@mainloop@ |
| 378 |
\ifx\pgfmanual@loc@TMPa\pgfmanual@EOI |
| 379 |
% stop iteration. |
| 380 |
\pgfmanual@pretty@mainloop@finishword |
| 381 |
\let\pgfmanual@pretty@mainloop@NEXT=\relax |
| 382 |
\else |
| 383 |
\ifpgfmanualprettycommentactive |
| 384 |
#1% |
| 385 |
\else |
| 386 |
\ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@lbracket% |
| 387 |
% we found the start of OPTIONS '[ ... ]'. |
| 388 |
\pgfmanual@pretty@mainloop@finishword |
| 389 |
% Attempt syntax highlighting for pgfkeys: |
| 390 |
\let\pgfmanual@pretty@mainloop@NEXT=\pgfmanual@pretty@pgfkeys |
| 391 |
\else |
| 392 |
\ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@backslash |
| 393 |
% we found the start of a control sequence '\command' |
| 394 |
\pgfmanual@pretty@mainloop@finishword |
| 395 |
% |
| 396 |
% collect the control sequence name into |
| 397 |
% \pgfmanual@loc@TMPa, but without the backslash: |
| 398 |
\let\pgfmanual@loc@TMPa=\pgfutil@empty |
| 399 |
\let\pgfmanual@pretty@mainloop@NEXT=\pgfmanual@pretty@collectcs@loop |
| 400 |
\else |
| 401 |
\ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@lroundbrace% |
| 402 |
\pgfmanual@pretty@mainloop@finishword |
| 403 |
\let\pgfmanual@pretty@mainloop@NEXT=\pgfmanual@pretty@collectpoint |
| 404 |
\else |
| 405 |
\def\pgfmanual@isspace{0}% |
| 406 |
\ifnum13=\catcode`#1 |
| 407 |
% we found a white space (space, TAB or NL) or comment |
| 408 |
\def\pgfmanual@isspace{1}% |
| 409 |
\else |
| 410 |
\ifnum10=\catcode`#1 |
| 411 |
\def\pgfmanual@isspace{1}% |
| 412 |
\fi |
| 413 |
\fi |
| 414 |
\if\pgfmanual@isspace1% |
| 415 |
\pgfkeysvalueof{/codeexample/prettyprint/if space is word delim/.@cmd}{% |
| 416 |
\pgfmanual@pretty@mainloop@finishword |
| 417 |
#1% ok, show it. |
| 418 |
}{% |
| 419 |
% collect the word. |
| 420 |
\expandafter\def\expandafter\pgfmanual@pretty@mainloop@currentword\expandafter{\pgfmanual@pretty@mainloop@currentword #1}% |
| 421 |
}% |
| 422 |
\else |
| 423 |
\pgfkeysvalueof{/codeexample/prettyprint/if is word delim/.@cmd}{#1}{% |
| 424 |
\pgfmanual@pretty@mainloop@finishword |
| 425 |
#1% ok, show the delimiter. |
| 426 |
}{% |
| 427 |
% collect the word. |
| 428 |
\expandafter\def\expandafter\pgfmanual@pretty@mainloop@currentword\expandafter{\pgfmanual@pretty@mainloop@currentword #1}% |
| 429 |
}\pgfeov% |
| 430 |
\fi |
| 431 |
\fi |
| 432 |
\fi |
| 433 |
\fi |
| 434 |
\fi |
| 435 |
\fi |
| 436 |
\pgfmanual@pretty@mainloop@NEXT |
| 437 |
}% |
| 438 |
|
| 439 |
\def\pgfmanual@pretty@mainloop@finishword{% |
| 440 |
\ifx\pgfmanual@pretty@mainloop@currentword\pgfutil@empty |
| 441 |
\else |
| 442 |
\def\pgfmanual@loc@TMPa{\pgfkeysvalueof{/codeexample/prettyprint/word/.@cmd}}% |
| 443 |
\expandafter\pgfmanual@loc@TMPa\pgfmanual@pretty@mainloop@currentword\pgfeov |
| 444 |
\let\pgfmanual@pretty@mainloop@currentword=\pgfutil@empty |
| 445 |
\fi |
| 446 |
}% |
| 447 |
|
| 448 |
\def\pgfmanual@pretty@collectpoint{% |
| 449 |
\let\pgfmanualprettyprinterhandlecollectedargs=\pgfmanual@pretty@collectargs@finish@collectpoint |
| 450 |
\expandafter\pgfmanualprettyprintercollectupto\pgfmanual@pretty@rroundbrace |
| 451 |
{\afterpgfmanual@pretty@collectpoint}% |
| 452 |
} |
| 453 |
|
| 454 |
{ |
| 455 |
\catcode`\:=12 |
| 456 |
\gdef\pgfmanual@pretty@collectargs@finish@collectpoint#1{% |
| 457 |
\expandafter\pgfutil@in@\pgfmanual@pretty@colon{#1}% |
| 458 |
\ifpgfutil@in@ |
| 459 |
\def\pgfmanual@pretty@collectpoint@getcoordsystem##1:##2\relax{% |
| 460 |
\begingroup |
| 461 |
\pgfmanual@pretty@restorespaces |
| 462 |
% remove active spaces from ##1: |
| 463 |
\xdef\pgfmanual@pretty@glob@TMPa{##1}% |
| 464 |
\endgroup |
| 465 |
\pgfkeysifdefined{/codeexample/prettyprint/point with cs/\pgfmanual@pretty@glob@TMPa/.@cmd}{% |
| 466 |
\def\pgfmanual@loc@TMPb{\pgfkeysvalueof{/codeexample/prettyprint/point with cs/\pgfmanual@pretty@glob@TMPa/.@cmd}}% |
| 467 |
}{% |
| 468 |
\def\pgfmanual@loc@TMPb{\pgfkeysvalueof{/codeexample/prettyprint/point with cs/.@cmd}}% |
| 469 |
}% |
| 470 |
\expandafter\def\expandafter\pgfmanual@loc@TMPa\expandafter{\expandafter{\pgfmanual@pretty@glob@TMPa}{##2}}% |
| 471 |
\expandafter\pgfmanual@loc@TMPb\pgfmanual@loc@TMPa\pgfeov |
| 472 |
}% |
| 473 |
\ifpgfmanualprettyprinterfoundterminator |
| 474 |
\pgfmanual@pretty@collectpoint@getcoordsystem#1)\relax |
| 475 |
\else |
| 476 |
\pgfmanual@pretty@collectpoint@getcoordsystem#1\relax |
| 477 |
\fi |
| 478 |
\else |
| 479 |
\def\pgfmanual@loc@TMPb{\pgfkeysvalueof{/codeexample/prettyprint/point/.@cmd}}% |
| 480 |
\ifpgfmanualprettyprinterfoundterminator |
| 481 |
\pgfmanual@loc@TMPb(#1)\pgfeov |
| 482 |
\else |
| 483 |
\pgfmanual@loc@TMPb(#1\pgfeov |
| 484 |
\fi |
| 485 |
\fi |
| 486 |
}% |
| 487 |
} |
| 488 |
\def\afterpgfmanual@pretty@collectpoint{\pgfmanual@pretty@mainloop}% |
| 489 |
|
| 490 |
% loops through all tokens, assembling the cs name as it goes. |
| 491 |
% #1 is a single token. |
| 492 |
\def\pgfmanual@pretty@collectcs@loop#1{% |
| 493 |
\let\pgfmanual@pretty@collectcs@loop@NEXT=\pgfmanual@pretty@collectcs@loop |
| 494 |
\def\pgfmanual@loc@TMPb{#1}% |
| 495 |
\ifx\pgfmanual@loc@TMPb\pgfmanual@EOI |
| 496 |
\def\pgfmanual@pretty@collectcs@loop@NEXT{\pgfmanual@pretty@collectcs@loop@END #1}% |
| 497 |
\else |
| 498 |
% a csname may only use letters. And: only letters have a |
| 499 |
% positive lcccode! |
| 500 |
\ifnum\lccode`#1=0 |
| 501 |
\ifx\pgfmanual@loc@TMPb @% |
| 502 |
% ok, we may also accept an `@': |
| 503 |
\edef\pgfmanual@loc@TMPa{\pgfmanual@loc@TMPa #1}% |
| 504 |
\else |
| 505 |
% This here is the first non-letter. |
| 506 |
\def\pgfmanual@pretty@collectcs@loop@NEXT{\pgfmanual@pretty@collectcs@loop@END #1}% |
| 507 |
\fi |
| 508 |
\else |
| 509 |
% continue iterating and assemble the csname... |
| 510 |
\edef\pgfmanual@loc@TMPa{\pgfmanual@loc@TMPa #1}% |
| 511 |
\fi |
| 512 |
\fi |
| 513 |
\pgfmanual@pretty@collectcs@loop@NEXT |
| 514 |
}% |
| 515 |
\def\afterpgfmanual@pretty@cs{\pgfmanual@pretty@mainloop}% |
| 516 |
|
| 517 |
\def\pgfmanual@pretty@collectcs@loop@END{% |
| 518 |
\pgfkeysifdefined{/codeexample/prettyprint/cs arguments/\pgfmanual@loc@TMPa}{% |
| 519 |
% oh. The collected control sequence expects arguments. That |
| 520 |
% means a lot of work since there are no nestable braces in |
| 521 |
% the token list! All of them have catcode 12... we need to do |
| 522 |
% that manually. |
| 523 |
\let\pgfmanualprettyprinterhandlecollectedargs=\pgfmanual@pretty@collectargs@finish@cs |
| 524 |
\def\pgfmanual@pretty@collectcs@loop@END@next{% |
| 525 |
\pgfmanualprettyprintercollectargcount |
| 526 |
{\pgfkeysvalueof{/codeexample/prettyprint/cs arguments/\pgfmanual@loc@TMPa}}% |
| 527 |
{\afterpgfmanual@pretty@cs}% |
| 528 |
}% |
| 529 |
}{% |
| 530 |
% re-insert the backslash: |
| 531 |
\edef\pgfmanual@loc@TMPa{\pgfmanual@pretty@backslash \pgfmanual@loc@TMPa}% |
| 532 |
% ok, report the macro and continue with the main loop. |
| 533 |
\def\pgfmanual@loc@TMPb{\pgfkeysvalueof{/codeexample/prettyprint/cs/.@cmd}}% |
| 534 |
\expandafter\pgfmanual@loc@TMPb\pgfmanual@loc@TMPa\pgfeov |
| 535 |
\let\pgfmanual@pretty@collectcs@loop@END@next=\afterpgfmanual@pretty@cs |
| 536 |
}% |
| 537 |
\pgfmanual@pretty@collectcs@loop@END@next |
| 538 |
}% |
| 539 |
|
| 540 |
\newif\ifpgfmanualprettyprinterarghasunmatchedbraces |
| 541 |
|
| 542 |
% Collects arguments inside of a token list, dealing with nested |
| 543 |
% catcode-12-braces. |
| 544 |
% |
| 545 |
% #1: is the NUMBER of arguments to collect. |
| 546 |
% #2: is TeX code which shall be invoked after |
| 547 |
% \pgfmanualprettyprinterhandlecollectedargs has been invoked (see |
| 548 |
% below). |
| 549 |
% |
| 550 |
% PRECONDITION: |
| 551 |
% there is a large token list following |
| 552 |
% \pgfmanualprettyprintercollectargcount with balanced braces. The braces |
| 553 |
% have \catcode 12. |
| 554 |
% POSTCONDITION: |
| 555 |
% 1. the arguments will be collected as |
| 556 |
% '<result> := {<first arg>}{<second arg>}', |
| 557 |
% 2.1 the macro \pgfmanualprettyprinternumcollectedargs will contain |
| 558 |
% the *actual* number of *completely* collected arguments, |
| 559 |
% 2.2 the if \ifpgfmanualprettyprinterarghasunmatchedbraces will be |
| 560 |
% set to \c true if the last found argument had an unmatched brace, |
| 561 |
% 3. then, \pgfmanualprettyprinterhandlecollectedargs{<result>} will be |
| 562 |
% invoked. Just define \pgfmanualprettyprinterhandlecollectedargs |
| 563 |
% properly. |
| 564 |
% Afterwards, #2 will be invoked to recover from the argument |
| 565 |
% collection. |
| 566 |
% |
| 567 |
% |
| 568 |
% Example: |
| 569 |
% \pgfmanualprettyprintercollectargcount{2}{\donnextstep} |
| 570 |
% {_12 first argument }_12 {_12 second argument }_12 next tokens% |
| 571 |
% |
| 572 |
% will result in the expansion |
| 573 |
% \pgfmanualprettyprinterhandlecollectedargs{{_1 first argument }_2 {_1 second argument }_2 } |
| 574 |
% \donnextstep |
| 575 |
% next tokens |
| 576 |
% |
| 577 |
% |
| 578 |
% |
| 579 |
% ATTENTION: |
| 580 |
% \pgfmanualprettyprinterhandlecollectedargs will be invoked with a SINGLE |
| 581 |
% argument. The argument as such will contain extra braces, one pair |
| 582 |
% of braces for each of the #1 arguments. These braces will have |
| 583 |
% catcode 1 and 2, i.e. they can *really* be used in TeX. Thus, the |
| 584 |
% finish routine will be invoked with |
| 585 |
% \pgfmanualprettyprinterhandlecollectedargs{{<arg>}} |
| 586 |
% for one argument and with |
| 587 |
% \pgfmanualprettyprinterhandlecollectedargs{{<first arg>}{<second arg>}} |
| 588 |
% for two and more arguments. Note the extra set of braces for one |
| 589 |
% arg. |
| 590 |
% It might happen that not all arguments have been found if |
| 591 |
% end-of-input occured before. The |
| 592 |
% \pgfmanualprettyprinterhandlecollectedargs routine has to check |
| 593 |
% this using the macro \pgfmanualprettyprinternumcollectedargs which |
| 594 |
% contains the actual number of collected args. |
| 595 |
% |
| 596 |
% @remark This macro checks for the end-of-input indicator, \pgfmanual@EOI. In case it encounters |
| 597 |
% \pgfmanual@EOI, it |
| 598 |
% 1. stops collecting, leaving the \pgfmanual@EOI as next token to be read, |
| 599 |
% 2. sets \ifpgfmanualprettyprinterarghasunmatchedbraces to \iftrue if necessary, |
| 600 |
% 3. assigns \pgfmanualprettyprinternumcollectedargs |
| 601 |
% 4. invokes the finish routine. |
| 602 |
% The \pgfmanual@EOI needs to be collected by following routines in |
| 603 |
% this case. You can also use \pgfutil@ifnextchar\pgfmanual@EOI{}{} in |
| 604 |
% following routines to check for \pgfmanual@EOI. |
| 605 |
\def\pgfmanualprettyprintercollectargcount#1#2{% |
| 606 |
\pgfmanualprettyprinterarghasunmatchedbracesfalse |
| 607 |
\begingroup |
| 608 |
\edef\pgfmanual@loc@csargcount{#1}% |
| 609 |
\toksdef\t@afterpgfmanualprettyprinterhandlecollected=10 |
| 610 |
\t@afterpgfmanualprettyprinterhandlecollected={#2}% |
| 611 |
\let\c@pgfmanual@pretty@openbracecount=\c@pgf@counta |
| 612 |
\let\c@pgfmanual@pretty@curargcount=\c@pgf@countb |
| 613 |
% I will track open braces and the number of completely |
| 614 |
% collected arguments here: |
| 615 |
\c@pgfmanual@pretty@openbracecount=0 |
| 616 |
\c@pgfmanual@pretty@curargcount=0 |
| 617 |
% |
| 618 |
% and I will accumulate the argument token lists as such here: |
| 619 |
\toksdef\t@pgfmanual@currentarg=0 |
| 620 |
\toksdef\t@pgfmanual@allargs=1 |
| 621 |
\t@pgfmanual@currentarg={}% |
| 622 |
\t@pgfmanual@allargs={}% |
| 623 |
% |
| 624 |
\pgfmanual@pretty@collectargs@loop |
| 625 |
}% |
| 626 |
|
| 627 |
% loops through all tokens, collecting the required number of |
| 628 |
% arguments. This involves to track nested braces manually. |
| 629 |
% #1 is a single token. |
| 630 |
\def\pgfmanual@pretty@collectargs@loop#1{% |
| 631 |
\let\pgfmanual@pretty@collectargs@loop@NEXT=\pgfmanual@pretty@collectargs@loop |
| 632 |
\def\pgfmanual@loc@TMPc{#1}% |
| 633 |
\ifx\pgfmanual@loc@TMPc\pgfmanual@EOI |
| 634 |
\ifnum\c@pgfmanual@pretty@openbracecount>0 |
| 635 |
\ifpgfmanualpdfwarnings |
| 636 |
\pgfplots@warning{The pretty printer did not found the closing curly brace!? This will potentially lead to display errors}% |
| 637 |
\fi |
| 638 |
\fi |
| 639 |
\edef\pgfmanual@pretty@collectargs@loop@NEXT{% |
| 640 |
\noexpand\endgroup |
| 641 |
\ifnum\c@pgfmanual@pretty@openbracecount>0 |
| 642 |
\noexpand\pgfmanualprettyprinterarghasunmatchedbracestrue |
| 643 |
\fi |
| 644 |
\noexpand\def\noexpand\pgfmanualprettyprinternumcollectedargs{\the\c@pgfmanual@pretty@curargcount}% |
| 645 |
\noexpand\pgfmanualprettyprinterhandlecollectedargs{\the\t@pgfmanual@allargs\the\t@pgfmanual@currentarg}% |
| 646 |
\the\t@afterpgfmanualprettyprinterhandlecollected |
| 647 |
\noexpand\pgfmanual@EOI% <- put this token back into token list! |
| 648 |
}% |
| 649 |
\else |
| 650 |
\ifpgfmanualprettycommentactive |
| 651 |
\t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% |
| 652 |
\ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@activenl |
| 653 |
\pgfmanualprettycommentactivefalse |
| 654 |
\fi |
| 655 |
\else |
| 656 |
\ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@activepercent |
| 657 |
\t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% |
| 658 |
\pgfmanualprettycommentactivetrue |
| 659 |
\else |
| 660 |
\ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@lbrace |
| 661 |
\advance\c@pgfmanual@pretty@openbracecount by1 |
| 662 |
\ifnum\c@pgfmanual@pretty@openbracecount>1 |
| 663 |
\t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% |
| 664 |
\fi |
| 665 |
\else |
| 666 |
\ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@rbrace |
| 667 |
\advance\c@pgfmanual@pretty@openbracecount by-1 |
| 668 |
\ifnum\c@pgfmanual@pretty@openbracecount=0 |
| 669 |
% we have one complete argument ready! |
| 670 |
% append it -- with REAL braces if needed: |
| 671 |
\edef\pgfmanual@loc@TMPc{\the\t@pgfmanual@allargs{\the\t@pgfmanual@currentarg}}% |
| 672 |
\t@pgfmanual@allargs=\expandafter{\pgfmanual@loc@TMPc}% |
| 673 |
\t@pgfmanual@currentarg={}% |
| 674 |
% |
| 675 |
% check it we need more arguments: |
| 676 |
\advance\c@pgfmanual@pretty@curargcount by1 |
| 677 |
\ifnum\c@pgfmanual@pretty@curargcount=\pgfmanual@loc@csargcount\relax |
| 678 |
\edef\pgfmanual@pretty@collectargs@loop@NEXT{% |
| 679 |
\noexpand\endgroup |
| 680 |
\noexpand\def\noexpand\pgfmanualprettyprinternumcollectedargs{\the\c@pgfmanual@pretty@curargcount}% |
| 681 |
\noexpand\pgfmanualprettyprinterhandlecollectedargs{\the\t@pgfmanual@allargs}% |
| 682 |
\the\t@afterpgfmanualprettyprinterhandlecollected |
| 683 |
}% |
| 684 |
\fi |
| 685 |
\else |
| 686 |
\t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% |
| 687 |
\fi |
| 688 |
\else |
| 689 |
\ifnum13=\catcode`#1 |
| 690 |
% we found a white space (space, TAB or NL) or comment |
| 691 |
\t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% |
| 692 |
\else |
| 693 |
\ifnum10=\catcode`#1 |
| 694 |
% we found a white space (space, TAB |
| 695 |
% or NL) with unexpected catcode |
| 696 |
\t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% |
| 697 |
\else |
| 698 |
\ifnum\c@pgfmanual@pretty@openbracecount=0 |
| 699 |
\ifpgfmanualpdfwarnings |
| 700 |
\begingroup |
| 701 |
\toks4{#1}% |
| 702 |
\pgfplots@warning{The pretty printer did not find the expected \pgfmanual@loc@csargcount\space arguments (only token \the\toks4 )}% |
| 703 |
\endgroup |
| 704 |
\fi |
| 705 |
\edef\pgfmanual@pretty@collectargs@loop@NEXT{% |
| 706 |
\noexpand\endgroup |
| 707 |
\noexpand\def\noexpand\pgfmanualprettyprinternumcollectedargs{\the\c@pgfmanual@pretty@curargcount}% |
| 708 |
\noexpand\pgfmanualprettyprinterhandlecollectedargs{\the\t@pgfmanual@allargs\the\t@pgfmanual@currentarg}% |
| 709 |
\the\t@afterpgfmanualprettyprinterhandlecollected |
| 710 |
\noexpand#1% <- put this token back into token list! |
| 711 |
}% |
| 712 |
\else |
| 713 |
\t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% |
| 714 |
\fi |
| 715 |
\fi |
| 716 |
\fi |
| 717 |
\fi |
| 718 |
\fi |
| 719 |
\fi |
| 720 |
\fi |
| 721 |
\fi |
| 722 |
\pgfmanual@pretty@collectargs@loop@NEXT |
| 723 |
}% |
| 724 |
|
| 725 |
\newif\ifpgfmanualprettyprinterfoundterminator |
| 726 |
|
| 727 |
% Collects tokens inside of a token list up to a single delimiting token, dealing with nested |
| 728 |
% catcode-12-braces. |
| 729 |
% |
| 730 |
% #1: is the end token, the delimiter. It won't be collected. |
| 731 |
% #2: is code to invoke after |
| 732 |
% \pgfmanualprettyprinterhandlecollectedargs has been invoked. |
| 733 |
% |
| 734 |
% PRECONDITION: |
| 735 |
% there is a large token list following |
| 736 |
% \pgfmanualprettyprintercollectargcount with balanced braces. The braces |
| 737 |
% have \catcode 12. |
| 738 |
% POSTCONDITION: |
| 739 |
% - the arguments will be collected as |
| 740 |
% '<result> := <token list>' |
| 741 |
% and then, \pgfmanualprettyprinterhandlecollectedargs{<result>} will be |
| 742 |
% invoked. Just define \pgfmanualprettyprinterhandlecollectedargs |
| 743 |
% properly. |
| 744 |
% Then, #2 will be invoked. |
| 745 |
% - The boolean \ifpgfmanualprettyprinterfoundterminator will be set to true if and only if '#1' has been found. |
| 746 |
% |
| 747 |
% @see \pgfmanualprettyprintercollectargcount for more details. |
| 748 |
% |
| 749 |
\def\pgfmanualprettyprintercollectupto#1#2{% |
| 750 |
\pgfmanualprettyprinterarghasunmatchedbracesfalse |
| 751 |
\pgfmanualprettyprinterfoundterminatortrue |
| 752 |
\begingroup |
| 753 |
\def\pgfmanual@loc@delimittoken{#1}% |
| 754 |
\toksdef\t@afterpgfmanualprettyprinterhandlecollected=10 |
| 755 |
\t@afterpgfmanualprettyprinterhandlecollected={#2}% |
| 756 |
% |
| 757 |
\let\c@pgfmanual@pretty@openbracecount=\c@pgf@counta |
| 758 |
% I will track open braces here: |
| 759 |
\c@pgfmanual@pretty@openbracecount=0 |
| 760 |
% |
| 761 |
% and I will accumulate the argument token lists as such here: |
| 762 |
\toksdef\t@pgfmanual@currentarg=0 |
| 763 |
\t@pgfmanual@currentarg={}% |
| 764 |
% |
| 765 |
\pgfmanual@pretty@collectupto@loop |
| 766 |
}% |
| 767 |
|
| 768 |
% loops through all tokens, collecting the required number of |
| 769 |
% arguments. This involves to track nested braces manually. |
| 770 |
% #1 is a single token. |
| 771 |
\def\pgfmanual@pretty@collectupto@loop#1{% |
| 772 |
\let\pgfmanual@pretty@collectupto@loop@NEXT=\pgfmanual@pretty@collectupto@loop |
| 773 |
\def\pgfmanual@loc@TMPc{#1}% |
| 774 |
\ifx\pgfmanual@loc@TMPc\pgfmanual@EOI |
| 775 |
\edef\pgfmanual@pretty@collectupto@loop@NEXT{% |
| 776 |
\noexpand\endgroup |
| 777 |
\ifnum\c@pgfmanual@pretty@openbracecount>0 |
| 778 |
\noexpand\pgfmanualprettyprinterarghasunmatchedbracestrue |
| 779 |
\fi |
| 780 |
\noexpand\pgfmanualprettyprinterfoundterminatorfalse |
| 781 |
\noexpand\pgfmanualprettyprinterhandlecollectedargs{\the\t@pgfmanual@currentarg}% |
| 782 |
\the\t@afterpgfmanualprettyprinterhandlecollected |
| 783 |
\noexpand\pgfmanual@EOI% <- put this token back into token list! |
| 784 |
}% |
| 785 |
\else |
| 786 |
\ifpgfmanualprettycommentactive |
| 787 |
\t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% |
| 788 |
\ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@activenl |
| 789 |
\pgfmanualprettycommentactivefalse |
| 790 |
\fi |
| 791 |
\else |
| 792 |
\ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@activepercent |
| 793 |
\t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% |
| 794 |
\pgfmanualprettycommentactivetrue |
| 795 |
\else |
| 796 |
\ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@lbrace |
| 797 |
\advance\c@pgfmanual@pretty@openbracecount by1 |
| 798 |
\t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% |
| 799 |
\else |
| 800 |
\ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@rbrace |
| 801 |
\advance\c@pgfmanual@pretty@openbracecount by-1 |
| 802 |
\t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% |
| 803 |
\else |
| 804 |
\ifx\pgfmanual@loc@TMPc\pgfmanual@loc@delimittoken |
| 805 |
\ifnum\c@pgfmanual@pretty@openbracecount=0 |
| 806 |
% do NOT include the delimit token. |
| 807 |
\edef\pgfmanual@pretty@collectupto@loop@NEXT{% |
| 808 |
\noexpand\endgroup |
| 809 |
\noexpand\pgfmanualprettyprinterhandlecollectedargs{\the\t@pgfmanual@currentarg}% |
| 810 |
\the\t@afterpgfmanualprettyprinterhandlecollected |
| 811 |
}% |
| 812 |
\else |
| 813 |
\t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% |
| 814 |
\fi |
| 815 |
\else |
| 816 |
\t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% |
| 817 |
\fi |
| 818 |
\fi |
| 819 |
\fi |
| 820 |
\fi |
| 821 |
\fi |
| 822 |
\fi |
| 823 |
\pgfmanual@pretty@collectupto@loop@NEXT |
| 824 |
}% |
| 825 |
|
| 826 |
\def\pgfmanual@pretty@collectargs@finish@cs#1{% |
| 827 |
\def\pgfmanual@pretty@collectargs@finish@cs@hasargs{1}% |
| 828 |
\ifnum\pgfmanualprettyprinternumcollectedargs=0 |
| 829 |
\ifpgfmanualprettyprinterarghasunmatchedbraces |
| 830 |
\else |
| 831 |
\def\pgfmanual@pretty@collectargs@finish@cs@hasargs{0}% |
| 832 |
\fi |
| 833 |
\fi |
| 834 |
\if\pgfmanual@pretty@collectargs@finish@cs@hasargs1% |
| 835 |
% report the macro and its arguments: |
| 836 |
\pgfkeysifdefined{/codeexample/prettyprint/cs/\pgfmanual@loc@TMPa/.@cmd}{% |
| 837 |
% oh, we have a separate routine for this macro! Ok, use it: |
| 838 |
\edef\pgfmanual@loc@TMPb{\noexpand\pgfkeysvalueof{/codeexample/prettyprint/cs/\pgfmanual@loc@TMPa/.@cmd}}% |
| 839 |
}{% |
| 840 |
% use the generic routine: |
| 841 |
\edef\pgfmanual@loc@TMPb{\noexpand\pgfkeysvalueof{/codeexample/prettyprint/cs with args/.@cmd}}% |
| 842 |
}% |
| 843 |
% re-insert the backslash: |
| 844 |
\edef\pgfmanual@loc@TMPa{{\pgfmanual@pretty@backslash\pgfmanual@loc@TMPa}}% |
| 845 |
\expandafter\pgfmanual@loc@TMPb\pgfmanual@loc@TMPa #1\pgfeov |
| 846 |
\else |
| 847 |
% Oh. We probably got |\pgfkeys| instead of |\pgfkeys{arg}| |
| 848 |
% re-insert the backslash: |
| 849 |
\edef\pgfmanual@loc@TMPa{{\pgfmanual@pretty@backslash\pgfmanual@loc@TMPa}}% |
| 850 |
\edef\pgfmanual@loc@TMPb{\noexpand\pgfkeysvalueof{/codeexample/prettyprint/cs/.@cmd}}% |
| 851 |
\expandafter\pgfmanual@loc@TMPb\pgfmanual@loc@TMPa\pgfeov |
| 852 |
#1\relax% simply typeset any encountered tokens after the control sequence. |
| 853 |
\fi |
| 854 |
}% |
| 855 |
|
| 856 |
% A user macro which pretty prints a set of keys. |
| 857 |
% |
| 858 |
% If '#1' is NOT an argument for \pgfkeys, |
| 859 |
% \pgfmanualprettyprintpgfkeys will try to recognise at least control |
| 860 |
% sequences (in the same way as usual). Thus, you can even use this |
| 861 |
% method if there *could* be pgfkeys arguments in an automated pretty |
| 862 |
% printing environment. |
| 863 |
% |
| 864 |
% However, '#1' should only have catcode 12 characters with the |
| 865 |
% exception of catcode 13 for newlines, spaces and comments. |
| 866 |
\long\def\pgfmanualprettyprintpgfkeys#1{% |
| 867 |
\ifpgfmanualprettyenabled |
| 868 |
\begingroup |
| 869 |
\pgfmanualprettyprintstyles |
| 870 |
\pgfmanual@pretty@pgfkeys@loop#1\pgfmanual@EOI |
| 871 |
\endgroup |
| 872 |
\else |
| 873 |
#1% |
| 874 |
\fi |
| 875 |
} |
| 876 |
|
| 877 |
\def\pgfmanual@pretty@pgfkeys{% |
| 878 |
\let\pgfmanualprettyprinterhandlecollectedargs=\pgfmanual@pretty@pgfkeys@start |
| 879 |
\pgfmanualprettyprintercollectupto]{\pgfmanual@pretty@mainloop}%% |
| 880 |
}% |
| 881 |
\long\def\pgfmanual@pretty@pgfkeys@start#1{% |
| 882 |
[% |
| 883 |
\pgfmanual@pretty@pgfkeys@loop#1\pgfmanual@EOI |
| 884 |
]% |
| 885 |
}% |
| 886 |
% iterates through single tokens, detecting key names and values while |
| 887 |
% it goes. |
| 888 |
\long\def\pgfmanual@pretty@pgfkeys@loop#1{% |
| 889 |
\def\pgfmanual@loc@TMPa{#1}% |
| 890 |
\ifx\pgfmanual@loc@TMPa\pgfmanual@EOI |
| 891 |
\def\pgfmanual@pretty@pgfkeys@loop@NEXT{\relax}% |
| 892 |
\else |
| 893 |
\def\pgfmanual@pretty@pgfkeys@loop@NEXT{\pgfmanual@pretty@pgfkeys@loop}% |
| 894 |
\ifpgfmanualprettycommentactive |
| 895 |
#1% |
| 896 |
\else |
| 897 |
\ifnum13=\catcode`#1 |
| 898 |
% we found a white space (space, TAB or NL) or comment |
| 899 |
#1% |
| 900 |
\else |
| 901 |
\ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@comma% |
| 902 |
%\let\pgfmanual@pretty@pgfkeys@loop@NEXT=\pgfmanual@pretty@pgfkeys@checkforEOI |
| 903 |
,% |
| 904 |
\else |
| 905 |
\ifnum10=\catcode`#1 |
| 906 |
% another white space... I thought they'd have |
| 907 |
% catcode 13. doesn't matter. |
| 908 |
#1% |
| 909 |
\else |
| 910 |
\ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@lbrace |
| 911 |
% braces may not occur in the first place - |
| 912 |
% but there are circumstances where it is |
| 913 |
% convenient to deal with them here (when |
| 914 |
% processing arguments of styles) |
| 915 |
% Do it. |
| 916 |
#1% |
| 917 |
\else |
| 918 |
\ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@rbrace |
| 919 |
#1% |
| 920 |
\else |
| 921 |
% found the beginning of a key! |
| 922 |
% We will collect the key name into |
| 923 |
% \toks0. |
| 924 |
\toks0={}% |
| 925 |
% |
| 926 |
% Handle it: |
| 927 |
% FIXME what if we found an opening brace!? |
| 928 |
\def\pgfmanual@pretty@pgfkeys@loop@NEXT{\pgfmanual@pretty@pgfkeys@collectkey #1}% |
| 929 |
\fi |
| 930 |
\fi |
| 931 |
\fi |
| 932 |
\fi |
| 933 |
\fi |
| 934 |
\fi |
| 935 |
\fi |
| 936 |
\pgfmanual@pretty@pgfkeys@loop@NEXT |
| 937 |
}% |
| 938 |
\def\pgfmanual@pretty@pgfkeys@collectkey#1{% |
| 939 |
\def\pgfmanual@loc@TMPb{#1}% |
| 940 |
\def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@pgfkeys@collectkey}% |
| 941 |
\ifx\pgfmanual@loc@TMPb\pgfmanual@EOI |
| 942 |
% finish key name. |
| 943 |
\edef\pgfmanual@loc@TMPb{\the\toks0 }% |
| 944 |
\ifx\pgfmanual@loc@TMPb\pgfutil@empty |
| 945 |
\else |
| 946 |
\expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% |
| 947 |
\fi |
| 948 |
\def\pgfmanual@pretty@pgfkeys@collectkey@next{\relax}% |
| 949 |
\else |
| 950 |
\ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@eq |
| 951 |
% finish key name. |
| 952 |
\expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% |
| 953 |
#1% |
| 954 |
% now, we do the same with the value - we collect it into |
| 955 |
% \toks0. |
| 956 |
\toks0={}% |
| 957 |
\def\pgfmanual@pretty@pgfkeys@collectvalue@hasconsumedspaces{0}% |
| 958 |
\def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@pgfkeys@collectvalue}% |
| 959 |
\else |
| 960 |
\ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@comma |
| 961 |
% finish key name. |
| 962 |
\expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% |
| 963 |
#1% |
| 964 |
\def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@pgfkeys@loop}% |
| 965 |
\else |
| 966 |
\ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@activenl |
| 967 |
% finish key name before newline. This is not |
| 968 |
% necessarily as in TeX, but its simpler here |
| 969 |
% because we don't need special cases for comments |
| 970 |
% and we don't need to gobble following white |
| 971 |
% spaces. |
| 972 |
\expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% |
| 973 |
#1% |
| 974 |
\def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@pgfkeys@loop}% |
| 975 |
\else |
| 976 |
\ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@backslash |
| 977 |
% This is confusing. I simply try to invoke |
| 978 |
% the control sequence code and recover as |
| 979 |
% good as possible. Let's see if that's |
| 980 |
% useful. |
| 981 |
\edef\pgfmanual@loc@TMPb{\the\toks0 }% |
| 982 |
\ifx\pgfmanual@loc@TMPb\pgfutil@empty |
| 983 |
\else |
| 984 |
\expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% |
| 985 |
\fi |
| 986 |
% |
| 987 |
% we found the start of a control sequence '\command': |
| 988 |
% |
| 989 |
% collect the control sequence name into |
| 990 |
% \pgfmanual@loc@TMPa, but without the backslash: |
| 991 |
\begingroup |
| 992 |
\let\pgfmanual@loc@TMPa=\pgfutil@empty |
| 993 |
\def\afterpgfmanual@pretty@cs{% |
| 994 |
\endgroup |
| 995 |
\pgfmanual@pretty@pgfkeys@loop |
| 996 |
}% |
| 997 |
\def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@collectcs@loop}% |
| 998 |
\else |
| 999 |
\ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@lbrace |
| 1000 |
% Braces in key names are allowed (if they |
| 1001 |
% are not the first character of a key |
| 1002 |
% name) |
| 1003 |
\def\pgfmanualprettyprinterhandlecollectedargs##1{% |
| 1004 |
\toks1={##1}% |
| 1005 |
\edef\pgfmanual@loc@TMPc{% |
| 1006 |
\the\toks0 \pgfmanual@pretty@lbrace \the\toks1 |
| 1007 |
\ifpgfmanualprettyprinterarghasunmatchedbraces |
| 1008 |
\else |
| 1009 |
\pgfmanual@pretty@rbrace |
| 1010 |
\fi |
| 1011 |
}% |
| 1012 |
\toks0=\expandafter{\pgfmanual@loc@TMPc}% |
| 1013 |
}% |
| 1014 |
\def\pgfmanual@pretty@pgfkeys@collectkey@next{% |
| 1015 |
\pgfmanualprettyprintercollectargcount{1}{\pgfmanual@pretty@pgfkeys@collectkey}% |
| 1016 |
#1% |
| 1017 |
}% |
| 1018 |
\else |
| 1019 |
\ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@rbrace |
| 1020 |
\expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% |
| 1021 |
#1% |
| 1022 |
\def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@pgfkeys@loop}% |
| 1023 |
\else |
| 1024 |
\toks0=\expandafter{\the\toks0 #1}% |
| 1025 |
\fi |
| 1026 |
\fi |
| 1027 |
\fi |
| 1028 |
\fi |
| 1029 |
\fi |
| 1030 |
\fi |
| 1031 |
\fi |
| 1032 |
\pgfmanual@pretty@pgfkeys@collectkey@next |
| 1033 |
}% |
| 1034 |
\def\pgfmanual@pretty@pgfkeys@collectvalue#1{% |
| 1035 |
\def\pgfmanual@loc@TMPb{#1}% |
| 1036 |
\let\pgfmanual@pretty@pgfkeys@collectvalue@next=\pgfmanual@pretty@pgfkeys@collectvalue |
| 1037 |
\ifx\pgfmanual@loc@TMPb\pgfmanual@EOI |
| 1038 |
% the key value is empty. |
| 1039 |
%\expandafter\pgfmanual@pretty@pgfkeys@processvalue\expandafter{\the\toks0 }% |
| 1040 |
\let\pgfmanual@pretty@pgfkeys@collectvalue@next=\relax |
| 1041 |
\else |
| 1042 |
\def\pgfmanual@pretty@isconsumed{0}% |
| 1043 |
\if\pgfmanual@pretty@pgfkeys@collectvalue@hasconsumedspaces0% |
| 1044 |
\ifnum13=\catcode`#1 |
| 1045 |
% we found a white space (space, TAB or NL) |
| 1046 |
#1% |
| 1047 |
\def\pgfmanual@pretty@isconsumed{1}% |
| 1048 |
\else |
| 1049 |
\ifnum10=\catcode`#1 |
| 1050 |
% another white space... I thought they'd have |
| 1051 |
% catcode 13. doesn't matter. |
| 1052 |
\def\pgfmanual@pretty@isconsumed{1}% |
| 1053 |
#1% |
| 1054 |
\fi |
| 1055 |
\fi |
| 1056 |
\fi |
| 1057 |
\if\pgfmanual@pretty@isconsumed0% |
| 1058 |
\def\pgfmanualprettyprinterhandlecollectedargs##1{\pgfmanual@pretty@pgfkeys@processvalue{##1}}% the braces will be handled separately. |
| 1059 |
\def\pgfmanual@pretty@pgfkeys@collectvalue@next{% |
| 1060 |
\pgfmanualprettyprintercollectupto,{\afterpgfmanual@pretty@collectargs@finish@value}#1% |
| 1061 |
}% |
| 1062 |
\fi |
| 1063 |
\fi |
| 1064 |
\pgfmanual@pretty@pgfkeys@collectvalue@next |
| 1065 |
}% |
| 1066 |
\def\afterpgfmanual@pretty@collectargs@finish@value{% |
| 1067 |
\pgfutil@ifnextchar\pgfmanual@EOI{% |
| 1068 |
\pgfmanual@pretty@pgfkeys@loop |
| 1069 |
}{% |
| 1070 |
\pgfmanual@pretty@pgfkeys@loop,% re-insert the gobbled comma here! |
| 1071 |
}% |
| 1072 |
}% |
| 1073 |
|
| 1074 |
{\catcode`\^^M=13 \catcode`\ =13\relax\catcode`\%=13\relax\gdef\pgfmanual@pretty@restorespaces{\def%{\pgfmanual@pretty@percent}\def^^M{\pgfmanual@pretty@space}\def {\pgfmanual@pretty@space}}} |
| 1075 |
|
| 1076 |
% #1: the key's name |
| 1077 |
\def\pgfmanual@pretty@pgfkeys@processkey#1{% |
| 1078 |
\begingroup |
| 1079 |
\pgfmanual@pretty@restorespaces |
| 1080 |
% remember this key name! It is used when we are dealing with |
| 1081 |
% its value later... (if it has a value) |
| 1082 |
\xdef\pgfmanual@pretty@pgfkeys@collectkey@keyname{#1}% |
| 1083 |
\endgroup |
| 1084 |
% |
| 1085 |
% check if it is a handled key. FIXME: this could be done in a |
| 1086 |
% rigorous way! This here assumes that all key handlers start with |
| 1087 |
% '.' and the '.' occurs never right after a '/' otherwise: |
| 1088 |
\def\pgfmanual@loc@TMPa{\pgfutil@in@{/.}}% |
| 1089 |
\expandafter\pgfmanual@loc@TMPa\expandafter{\pgfmanual@pretty@pgfkeys@collectkey@keyname}% |
| 1090 |
\ifpgfutil@in@ |
| 1091 |
% split into key name and handler name... |
| 1092 |
\def\pgfmanual@pretty@splitit##1/.##2\relax{% |
| 1093 |
\def\pgfmanual@loc@TMPb{{##1}{.##2}}% |
| 1094 |
}% |
| 1095 |
\expandafter\pgfmanual@pretty@splitit\pgfmanual@pretty@pgfkeys@collectkey@keyname\relax |
| 1096 |
% |
| 1097 |
% report key name AND handler: |
| 1098 |
\def\pgfmanual@loc@TMPa{\pgfkeysvalueof{/codeexample/prettyprint/key name with handler/.@cmd}}% |
| 1099 |
\expandafter\pgfmanual@loc@TMPa\pgfmanual@loc@TMPb\pgfeov |
| 1100 |
\else |
| 1101 |
% report key name ... |
| 1102 |
\def\pgfmanual@loc@TMPa{\pgfkeysvalueof{/codeexample/prettyprint/key name/.@cmd}}% |
| 1103 |
\expandafter\pgfmanual@loc@TMPa\pgfmanual@pretty@pgfkeys@collectkey@keyname\pgfeov |
| 1104 |
\fi |
| 1105 |
} |
| 1106 |
\def\pgfmanual@pretty@pgfkeys@processvalue#1{% |
| 1107 |
% report or process the value, depending on the keyname. |
| 1108 |
% After all, it *may* be a style which needs to be pretty printed |
| 1109 |
% as well. |
| 1110 |
\pgfkeysifdefined{/codeexample/prettyprint/key value/\pgfmanual@pretty@pgfkeys@collectkey@keyname/.@cmd}{% |
| 1111 |
% oh, we have a separate routine for this macro! Ok, use it: |
| 1112 |
\edef\pgfmanual@loc@TMPb{\noexpand\pgfkeysvalueof{/codeexample/prettyprint/key value/\pgfmanual@pretty@pgfkeys@collectkey@keyname/.@cmd}}% |
| 1113 |
}{% |
| 1114 |
% use the generic routine: |
| 1115 |
\edef\pgfmanual@loc@TMPb{\noexpand\pgfkeysvalueof{/codeexample/prettyprint/key value/.@cmd}}% |
| 1116 |
}% |
| 1117 |
\edef\pgfmanual@loc@TMPa{{\pgfmanual@pretty@pgfkeys@collectkey@keyname}}% |
| 1118 |
\expandafter\pgfmanual@loc@TMPb\pgfmanual@loc@TMPa{#1}\pgfeov |
| 1119 |
} |