1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Interaction Macros Initialization}
15
16\unprotect
17
18\registerctxluafile{scrnini}{autosuffix}
19
20
21
22
23
24
25
26
27
28
29
30\installcorenamespace{interaction}
31
32\installswitchcommandhandler \??interaction {interaction} \??interaction
33
34\appendtoks
35 \ifempty\previousinteraction
36 \checkinteractionstate
37 \orelse\ifx\currentinteraction\previousinteraction
38 \checkinteractionstate
39 \fi
40\to \everysetupinteraction
41
42\permanent\protected\def\checkinteractionstate
43 {\ifcstok{\interactionparameter\c!state}\v!start
44 \locationtrue
45 \setsystemmode\v!interaction
46 \else
47 \locationfalse
48 \resetsystemmode\v!interaction
49 \fi}
50
51\permanent\def\doifelselocation
52 {\iflocation
53 \expandafter\firstoftwoarguments
54 \else
55 \expandafter\secondoftwoarguments
56 \fi}
57
58\aliased\let\doiflocationelse\doifelselocation
59
60\setupinteraction
61 [\c!state=\v!stop]
62
63\setupinteraction
64 [\c!title=,
65 \c!subtitle=,
66 \c!author=,
67 \c!keyword=,
68 \c!date=]
69
70\appendtoks
71 \setupinteraction
72\to \everyjob
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98\permanent\protected\def\startinteraction[#1]
99 {\pushmacro\currentinteraction
100 \cdef\currentinteraction{#1}}
101
102\permanent\protected\def\stopinteraction
103 {\popmacro\currentinteraction}
104
105\permanent\protected\def\setinteraction[#1]
106 {\cdef\currentinteraction{#1}}
107
108\defineinteraction
109 [\v!hidden]
110
111\setupinteraction
112 [\v!hidden]
113 [\c!state=\v!start,
114 \c!color=,
115 \c!contrastcolor=,
116 \c!style=,
117 \c!click=\v!off]
118
119
120
121
122
123
124
125
126
127
128
129
130\definecolor [interactioncolor] [r=0, g=.6, b=0]
131\definecolor [interactioncontrastcolor] [r=.8, g=0, b=0]
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177\newconditional\c_scrn_interaction_no_style
178\newconditional\c_scrn_interaction_no_color
179\newconditional\c_scrn_interaction_no_contrastcolor
180
181\permanent\protected\def\resetinteractionstyleandcolor
182 {\c_scrn_interaction_no_style\conditionaltrue
183 \c_scrn_interaction_no_color\conditionaltrue
184 \c_scrn_interaction_no_contrastcolor\conditionaltrue}
185
186\permanent\protected\def\resetinteractionstyle
187 {\c_scrn_interaction_no_style\conditionaltrue}
188
189\permanent\protected\def\resetinteractioncolor
190 {\c_scrn_interaction_no_color\conditionaltrue
191 \c_scrn_interaction_no_contrastcolor\conditionaltrue}
192
193\permanent\protected\def\resetinteractioncontrastcolor
194 {\c_scrn_interaction_no_contrastcolor\conditionaltrue}
195
196\permanent\protected\def\restoreinteractionstyleandcolor
197 {\c_scrn_interaction_no_style\conditionalfalse
198 \c_scrn_interaction_no_color\conditionalfalse
199 \c_scrn_interaction_no_contrastcolor\conditionalfalse}
200
201\appendtoks
202 \iflocation
203 \restoreinteractionstyleandcolor
204 \fi
205\to \everybeforepagebody
206
207\permanent\protected\def\setlocationcolorspecified#1
208 {\ifconditional\c_scrn_interaction_no_color
209
210 \orunless\ifconditional\c_scrn_interaction_no_contrastcolor
211 \useinteractioncolorparameter\c!color
212 \orelse\ifnum#1=\plusone
213 \edef\p_contrastcolor{\interactionparameter\c!contrastcolor}
214 \ifempty\p_contrastcolor
215 \useinteractioncolorparameter\c!color
216 \else
217 \useinteractioncolorparameter\c!contrastcolor
218 \fi
219 \else
220 \useinteractioncolorparameter\c!color
221 \fi}
222
223\permanent\protected\def\setlocationattributesspecified#1
224 {\ifconditional\c_scrn_interaction_no_color
225 \ifconditional\c_scrn_interaction_no_style
226 \else
227 \useinteractionstyleparameter\c!style
228 \fi
229 \orelse\ifnum#1=\plusone
230 \edef\p_contrastcolor{\interactionparameter\c!contrastcolor}
231 \ifempty\p_contrastcolor
232 \useinteractionstyleandcolor\c!style\c!color
233 \else
234 \useinteractionstyleandcolor\c!style\c!contrastcolor
235 \fi
236 \else
237 \ifconditional\c_scrn_interaction_no_color
238 \useinteractionstyleparameter\c!style
239 \orelse\ifconditional\c_scrn_interaction_no_style
240 \useinteractioncolorparameter\c!color
241 \else
242 \useinteractionstyleandcolor\c!style\c!color
243 \fi
244 \fi}
245
246\permanent\protected\def\setlocationcolorspecspecified#1#2
247 {\ifconditional\c_scrn_interaction_no_color
248
249 \orunless\ifconditional\c_scrn_interaction_no_contrastcolor
250 \colo_helpers_activate{#2\c!color}
251 \orelse\ifnum#1=\plusone
252 \edef\p_contrastcolor{#2\c!contrastcolor}
253 \ifempty\p_contrastcolor
254 \colo_helpers_activate{#2\c!color}
255 \else
256 \colo_helpers_activate\p_contrastcolor
257 \fi
258 \else
259 \colo_helpers_activate{#2\c!color}
260 \fi}
261
262\permanent\protected\def\setlocationcolor {\setlocationcolorspecified \referencepagestate}
263\permanent\protected\def\setlocationattributes{\setlocationattributesspecified\referencepagestate}
264\permanent\protected\def\setlocationcolorspec {\setlocationcolorspecspecified \referencepagestate}
265
266\permanent\protected\def\setlocationfont
267 {\useinteractionstyleparameter\c!style}
268
269\setupinteraction
270 [\c!style=\v!bold,
271 \c!color=interactioncolor,
272 \c!contrastcolor=interactioncontrastcolor]
273
274
275
276
277
278
279\def\scrn_identity_get#1
280 {\setidentityvariable{#1}{\prerolltostring{\interactionparameter{#1}}}}
281
282
283
284\def\scrn_identity_document#1#2
285 {\doifdocumentvariable{metadata:#1}{\setupinteraction[#2=\documentvariable{metadata:#1}]}}
286
287\appendtoks
288 \scrn_identity_document {title}\c!title
289 \scrn_identity_document {subject}\c!subtitle
290 \scrn_identity_document{subtitle}\c!subtitle
291 \scrn_identity_document {author}\c!author
292 \scrn_identity_document {authors}\c!author
293 \scrn_identity_document {keyword}\c!keyword
294 \scrn_identity_document{keywords}\c!keyword
295 \scrn_identity_document {date}\c!date
296\to \everystartdocument
297
298\appendtoks
299 \clf_setautoprefix{\interactionparameter\c!prefix}
300\to \everysetupinteraction
301
302
303
304
305
306\def\syst_set_metatdata_from_dummy#1
307 {\ifempty{\dummyparameter#1}\else
308 \global\expandafter\letinteractionparameter\expandafter#1\lastnamedcs
309 \fi}
310
311\permanent\protected\def\setupmetadata[#1]
312 {\begingroup
313 \resetdummyparameter\c!title
314 \resetdummyparameter\c!subtitle
315 \resetdummyparameter\c!author
316 \resetdummyparameter\c!keyword
317 \resetdummyparameter\c!date
318 \getdummyparameters[#1]
319 \syst_set_metatdata_from_dummy\c!title
320 \syst_set_metatdata_from_dummy\c!subtitle
321 \syst_set_metatdata_from_dummy\c!author
322 \syst_set_metatdata_from_dummy\c!keyword
323 \syst_set_metatdata_from_dummy\c!date
324 \endgroup}
325
326\protect \endinput
327 |