m-tikz.mkiv /size: 4371 b    last modification: 2024-01-16 09:03
1%D \module
2%D   [       file=m-tikz,
3%D        version=2021.07.12,
4%D          title=\CONTEXT\ Extra Modules,
5%D       subtitle=TIKZ support,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14%D A fixed variant of the t-tikz module distributed with tikz. For practical reasons
15%D per 2021 we split the module for \MKIV\ and \LMTX. (Maybe some day I'll optimize
16%D TIKZ a bit.)
17%D
18%D All these t-* modules in the tikz distribution make no sense as we can just load
19%D them here which is way cleaner. There is also some mkii filename mapping going on
20%D that is not needed on todays systems (windows has no 8.3 limitation and on unix
21%D tds finally adopted a case insensitive approach.)
22
23%D Just in case someone does a hard input ...
24
25\ifdefined\pgfdefined    \endinput \fi
26\ifdefined\pgfcoredefined\endinput \fi
27
28%D ... but normally we end up here:
29
30\startmodule[tikz]
31
32\ifdefined\hoffset \else
33    \newdimen\hoffset
34    \newdimen\voffset
35\fi
36
37\ifdefined\pdflastxpos \else
38    \unprotect
39        \unexpanded\def\pdflastxpos{\numexpr\clf_lastxpos\relax}
40        \unexpanded\def\pdflastypos{\numexpr\clf_lastypos\relax}
41    \protect
42\fi
43
44\ifdefined\pdfstrcmp\else
45
46    \startluacode
47        interfaces.implement {
48            name      = "pdfstrcmp",
49            arguments = "2 strings",
50            public    = true,
51            actions   = function(a,b)
52                context((a < b and -1) or (a > b and 1) or 0)
53            end
54        }
55    \stopluacode
56
57\fi
58
59\permanent\protected\def\starttikzinput
60  {\pushcatcodetable
61   \setcatcodetable\texcatcodes
62   \catcode`\@=11\relax
63   \catcode`\|=12\relax
64   \catcode`\!=12\relax
65   \catcode`\~=13\relax
66   \relax}
67
68\permanent\protected\def\stoptikzinput
69  {\relax
70   \popcatcodetable}
71
72\permanent\protected\def\tikzinputfile#1%
73  {\starttikzinput
74   \input{#1}\relax
75   \stoptikzinput}
76
77\permanent\protected\def\tikzerrormessage#1#2#3%
78  {\writestatus{#1}{#2}}
79
80% For now we need this but we need to educate the user to wrap settings in the
81% wrappers. So some day the next line will go. I need to check what commands are
82% possible outside a picture.
83
84\protected\def\starttikzsettings
85  {}
86
87\protected\def\stoptikzsettings
88  {}
89
90\protected\def\starttikzpicture
91  {\dontleavehmode
92   \hbox\bgroup
93   \ifdefined\PackageError\else \let\PackageError\tikzerrormessage \fi
94   \tikzpicture}
95
96\permanent\protected\def\stoptikzpicture
97  {\endtikzpicture
98   \egroup}
99
100\let\pgfdefined    \relax
101\let\pgfcoredefined\relax
102
103\tikzinputfile{pgfutil-common.tex}
104\tikzinputfile{pgfutil-context.def}
105\tikzinputfile{pgfrcs.code.tex}
106\tikzinputfile{pgfsys.code.tex}
107\tikzinputfile{pgfkeys.code.tex}
108\tikzinputfile{pgfsyssoftpath.code.tex}
109\tikzinputfile{pgfsysprotocol.code.tex}
110\tikzinputfile{pgfcore.code.tex}
111\tikzinputfile{pgffor.code.tex}
112\tikzinputfile{pgfmoduleplot.code.tex}
113\tikzinputfile{tikz.code.tex}
114
115\let\startpgfpicture             \pgfpicture              \let\stoppgfpicture            \endpgfpicture
116\let\startpgfscope               \pgfscope                \let\stoppgfscope              \endpgfscope
117\let\startpgflowlevelscope       \pgflowlevelscope        \let\stoppgflowlevelscope      \endpgflowlevelscope
118\let\startpgfinterruptpath       \pgfinterruptpath        \let\stoppgfinterruptpath      \endpgfinterruptpath
119\let\startpgfinterruptpicture    \pgfinterruptpicture     \let\stoppgfinterruptpicture   \endpgfinterruptpicture
120\let\startpgfinterruptboundingbox\pgfinterruptboundinbox  \let\stoppgfinterruptboudingbox\endpgfinterruptboundingbox
121
122\let\normalusepgfmodule \usepgfmodule
123\let\normalusepgflibrary\usepgflibrary
124
125\unexpanded\def\usepgfmodule {\doifelsenextoptional\dousepgfmoduleyes \dousepgfmodulenop }
126\unexpanded\def\usepgflibrary{\doifelsenextoptional\dousepgflibraryyes\dousepgflibrarynop}
127
128\def\dousepgfmodulenop #1{\dousepgfmoduleyes [#1]}
129\def\dousepgflibrarynop#1{\dousepgflibraryyes[#1]}
130
131\def\dousepgfmoduleyes[#1]%
132  {\starttikzinput
133   \normalusepgfmodule[#1]%
134   \stoptikzinput}
135
136\def\dousepgflibraryyes[#1]%
137  {\starttikzinput
138   \normalusepgflibrary[#1]%
139   \stoptikzinput}
140
141\usepgfmodule[shapes]
142\usepgfmodule[plot]
143\usepgfmodule[matrix]
144\usepgfmodule[decorations]
145
146\stopmodule
147