-
Notifications
You must be signed in to change notification settings - Fork 26
/
pgfkeyslibraryconditionals.code.tex
89 lines (85 loc) · 2.71 KB
/
pgfkeyslibraryconditionals.code.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
\pgfkeys{
/utils/ifname nTF/.code n args={3}{%
\ifcsname if#1\endcsname
\pgfkeys@lib@cond@gobble\if % paired \ifxxx ... (\else ...) \fi to cheat TeX
\csname if#1\endcsname
\expandafter\expandafter\expandafter\@firstoftwo
\else
\expandafter\expandafter\expandafter\@secondoftwo
\fi
\else
\pgfkeys@error{Undefined \pgfkeys@lib@cond@backslashchar if#1 used by
``\pgfkeyscurrentkey=\detokenize{{#1}{#2}{#3}}''.\pgfkeys@lib@cond@messagebreak%
I'll use false branch}%
\expandafter\@secondoftwo
\fi
{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}%
},
/utils/ifxxx nTF/.code n args={3}{%
#1%
\expandafter\pgfkeys@firstoftwo
\else
\expandafter\pgfkeys@secondoftwo
\fi
{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}%
},
/utils/ifnum nNnTF/.style n args={5}{
/utils/ifxxx nTF={\ifnum\numexpr#1\relax#2\numexpr#3\relax}{#4}{#5}
},
/utils/ifdim nNnTF/.style n args= {5}{
/utils/ifxxx nTF={\ifdim\dimexpr#1\relax#2\dimexpr#3\relax}{#4}{#5}
},
/utils/if NNTF/.style n args={4}{
/utils/ifxxx nTF={\if\noexpand#1\noexpand#2}{#3}{#4}
},
/utils/ifcat NNTF/.style n args={4}{
/utils/ifxxx nTF={\ifcat\noexpand#1\noexpand#2}{#3}{#4}
},
/utils/ifx NNTF/.style n args={4}{
/utils/ifxxx nTF={\ifx#1#2}{#3}{#4}
}
}
\ifdefined\PackageError
\def\pgfkeys@lib@cond@messagebreak{\MessageBreak}
\else
\def\pgfkeys@lib@cond@messagebreak{^^J}
\fi
\long\def\pgfkeys@lib@cond@gobble#1{}
\edef\pgfkeys@lib@cond@backslashchar{%
\expandafter\pgfkeys@lib@cond@gobble\string\\}
% similar to \pgfsys@strcmp defined in pgfsys.code.tex
\ifdefined\pdfstrcmp
\let\pgfkeys@lib@cond@strcmp=\pdfstrcmp
\else\ifdefined\strcmp
\let\pgfkeys@lib@cond@strcmp=\strcmp
\else\ifdefined\directlua
\directlua{
local lft = lua.get_functions_table()
lft[\string#lft+1] = function()
local lhs = token.scan_string()
local rhs = token.scan_string()
if lhs < rhs then
tex.sprint(-2, "-1")
elseif lhs == rhs then
tex.sprint(-2, "0")
else
tex.sprint(-2, "1")
end
end
token.set_lua("pgfkeys@lib@cond@strcmp", \string#lft, "global")
}
\fi\fi\fi
\ifdefined\pgfkeys@lib@cond@strcmp
\long\def\pgfkeys@lib@cond@strcmp@do#1#2{%
\pgfkeys@lib@cond@strcmp{\pgfkeys@unexpanded{#1}}{\pgfkeys@unexpanded{#2}}}
\pgfkeys{
/utils/if strcmp nNnTF/.style n args={5}{
/utils/ifxxx nTF={\ifnum\pgfkeys@lib@cond@strcmp@do{#1}{#3}#20\relax}{#4}{#5}
}
}
\pgfkeys@lib@cond@gobble\fi
\else
\pgfkeys@error{%
No primitive \pgfkeys@lib@cond@backslashchar(pdf)strcmp found and I'm not in LuaTeX.\pgfkeys@lib@cond@messagebreak
``/utils/if strcmp nNnTF'' is not provided}
\fi