1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Core Macros Multipass Datasets}
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33\unprotect
34
35\registerctxluafile{coredat}{}
36
37\installcorenamespace{dataset}
38
39\installcommandhandler \??dataset {dataset} \??dataset
40
41\unexpanded\def\setdataset
42 {\dotripleempty\syst_datasets_set}
43
44\def\syst_datasets_set
45 {\ifthirdargument
46 \expandafter\syst_datasets_set_named
47 \else
48 \expandafter\syst_datasets_set_indexed
49 \fi}
50
51\def\syst_datasets_set_named[#1][#2][#3]
52 {\begingroup
53 \edef\currentdataset{#1}
54 \clf_setdataset
55 name {\currentdataset}
56 tag {#2}
57 delay {\datasetparameter\c!delay}
58 data {#3}
59 \relax
60 \endgroup}
61
62\def\syst_datasets_set_indexed[#1][#2][#3]
63 {\begingroup
64 \edef\currentdataset{#1}
65 \clf_setdataset
66 name {\currentdataset}
67 delay {\datasetparameter\c!delay}
68 data {#2}
69 \relax
70 \endgroup}
71
72\def\datasetvariable#1#2#3
73 {\clf_datasetvariable{#1}{#2}{#3}}
74
75\installcorenamespace{pagestate}
76\installcorenamespace{pagestatecounter}
77
78\installcommandhandler \??pagestate {pagestate} \??pagestate
79
80
81
82
83
84\def\syst_pagestates_allocate
85 {\expandafter\newcount\csname\??pagestatecounter\currentpagestate\endcsname}
86
87\appendtoks
88 \syst_pagestates_allocate
89\to \everydefinepagestate
90
91\setuppagestate
92 [\c!delay=\v!yes]
93
94\unexpanded\def\setpagestate
95 {\dodoubleempty\syst_pagestates_set}
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114\def\syst_pagestates_set[#1][#2]
115 {\begingroup
116 \edef\currentpagestate{#1}
117 \ifcsname\??pagestatecounter\currentpagestate\endcsname
118 \scratchcounter\lastnamedcs
119 \advance\scratchcounter\plusone
120 \else
121 \scratchcounter\plusone
122 \syst_pagestates_allocate
123 \fi
124 \global\csname\??pagestatecounter\currentpagestate\endcsname\scratchcounter
125 \clf_setpagestate
126 name {\currentpagestate}
127 tag {\ifsecondargument#2\else\number\scratchcounter\fi}
128 delay {\pagestateparameter\c!delay}
129 \relax
130 \endgroup}
131
132\unexpanded\def\autosetpagestate#1
133 {\secondargumentfalse\syst_pagestates_set[#1]}
134
135\def\autopagestatenumber#1{\begincsname\??pagestatecounter#1\endcsname}
136
137\def\pagestaterealpage #1#2{\clf_pagestaterealpage {#1}{#2}}
138\def\setpagestaterealpageno#1#2{\clf_setpagestaterealpageno{#1}{#2}}
139\def\pagestaterealpageorder#1#2{\clf_pagestaterealpageorder{#1}#2\relax}
140
141\def\autopagestaterealpage #1{\clf_pagestaterealpage {#1}{\number\autopagestatenumber{#1}}}
142\def\setautopagestaterealpageno#1{\clf_setpagestaterealpageno{#1}{\number\autopagestatenumber{#1}}}
143\def\autopagestaterealpageorder#1{\clf_pagestaterealpageorder{#1}\numexpr\autopagestatenumber{#1}\relax}
144
145\protect
146 |