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}{}
19
20
21
22
23
24
25
26
27
28
29
30\installcorenamespace{interaction}
31
32\installswitchcommandhandler \??interaction {interaction} \??interaction
33
34\appendtoks
35 \ifx\previousinteraction\empty
36 \checkinteractionstate
37 \else\ifx\currentinteraction\previousinteraction
38 \checkinteractionstate
39 \fi\fi
40\to \everysetupinteraction
41
42\unexpanded\def\checkinteractionstate
43 {\doifelse{\interactionparameter\c!state}\v!start
44 {\locationtrue \setsystemmode \v!interaction}
45 {\locationfalse \resetsystemmode\v!interaction}}
46
47\def\doifelselocation
48 {\iflocation
49 \expandafter\firstoftwoarguments
50 \else
51 \expandafter\secondoftwoarguments
52 \fi}
53
54\let\doiflocationelse\doifelselocation
55
56\setupinteraction
57 [\c!state=\v!stop]
58
59\appendtoks
60 \setupinteraction
61\to \everyjob
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\unexpanded\def\startinteraction[#1]
88 {\pushmacro\currentinteraction
89 \edef\currentinteraction{#1}}
90
91\unexpanded\def\stopinteraction
92 {\popmacro\currentinteraction}
93
94\unexpanded\def\setinteraction[#1]
95 {\def\currentinteraction{#1}}
96
97\defineinteraction
98 [\v!hidden]
99
100\setupinteraction
101 [\v!hidden]
102 [\c!state=\v!start,
103 \c!color=,
104 \c!contrastcolor=,
105 \c!style=,
106 \c!click=\v!off]
107
108
109
110
111
112
113
114
115
116
117
118
119\definecolor [interactioncolor] [r=0, g=.6, b=0]
120\definecolor [interactioncontrastcolor] [r=.8, g=0, b=0]
121
122
123
124
125
126
127
128
129
130\unexpanded\def\setlocationcolorspecified#1
131 {\ifnum#1=\plusone
132 \edef\askedcontrastcolor{\interactionparameter\c!contrastcolor}
133 \ifx\askedcontrastcolor\empty
134 \useinteractioncolorparameter\c!color
135 \else
136 \useinteractioncolorparameter\c!contrastcolor
137 \fi
138 \else
139 \useinteractioncolorparameter\c!color
140 \fi}
141
142\unexpanded\def\setlocationattributesspecified#1
143 {\ifnum#1=\plusone
144 \edef\askedcontrastcolor{\interactionparameter\c!contrastcolor}
145 \ifx\askedcontrastcolor\empty
146 \useinteractionstyleandcolor\c!style\c!color
147 \else
148 \useinteractionstyleandcolor\c!style\c!contrastcolor
149 \fi
150 \else
151 \useinteractionstyleandcolor\c!style\c!color
152 \fi}
153
154\unexpanded\def\setlocationcolorspecspecified#1#2
155 {\ifnum#1=\plusone
156 \edef\askedcontrastcolor{#2\c!contrastcolor}
157 \ifx\askedcontrastcolor\empty
158 \colo_helpers_activate{#2\c!color}
159 \else
160 \colo_helpers_activate\askedcontrastcolor
161 \fi
162 \else
163 \colo_helpers_activate{#2\c!color}
164 \fi}
165
166\unexpanded\def\setlocationcolor {\setlocationcolorspecified \referencepagestate}
167\unexpanded\def\setlocationattributes{\setlocationattributesspecified\referencepagestate}
168\unexpanded\def\setlocationcolorspec {\setlocationcolorspecspecified \referencepagestate}
169
170\unexpanded\def\setlocationfont
171 {\useinteractionstyleparameter\c!style}
172
173\setupinteraction
174 [\c!style=\v!bold,
175 \c!color=interactioncolor,
176 \c!contrastcolor=interactioncontrastcolor]
177
178
179
180
181
182
183
184
185
186
187
188
189
190\newconditional\c_scrn_identity_preroll
191
192\installtexdirective
193 {interaction.identity.preroll}
194 {\settrue \c_scrn_identity_preroll}
195 {\setfalse\c_scrn_identity_preroll}
196
197\def\scrn_identity_prerolled#1
198 {\begingroup
199 \edef\tempstring{\interactionparameter#1}
200 \ifx\tempstring\empty
201 \endgroup
202 \else
203 \the\everypreroll
204 \nodestostring\tempstring{\tempstring}
205 \normalexpanded{\endgroup\setexpandedinteractionparameter{#1}{\tempstring}}
206 \fi}
207
208\def\scrn_identity_synchronize
209 {\begingroup
210 \ifconditional\c_scrn_identity_preroll
211 \scrn_identity_prerolled\c!title
212 \scrn_identity_prerolled\c!subtitle
213 \scrn_identity_prerolled\c!author
214 \scrn_identity_prerolled\c!date
215 \scrn_identity_prerolled\c!keyword
216 \fi
217 \clf_setupidentity
218 title {\interactionparameter\c!title}
219 subtitle {\interactionparameter\c!subtitle}
220 author {\interactionparameter\c!author}
221
222 date {\interactionparameter\c!date}
223 keywords {\interactionparameter\c!keyword}
224 \relax
225 \endgroup}
226
227\appendtoks
228 \scrn_identity_synchronize
229\to \everysetupinteraction
230
231
232
233\def\scrn_identity_document#1#2
234 {\doifdocumentvariable{metadata:#1}{\setupinteraction[#2=\documentvariable{metadata:#1}]}}
235
236\appendtoks
237 \scrn_identity_document {title}\c!title
238 \scrn_identity_document {subject}\c!subtitle
239 \scrn_identity_document{subtitle}\c!subtitle
240 \scrn_identity_document {author}\c!author
241 \scrn_identity_document {authors}\c!author
242 \scrn_identity_document {keyword}\c!keyword
243 \scrn_identity_document{keywords}\c!keyword
244 \scrn_identity_document {date}\c!date
245\to \everystartdocument
246
247\setupinteraction
248 [\c!title=,
249 \c!subtitle=,
250 \c!author=,
251 \c!keyword=,
252 \c!date=]
253
254\protect \endinput
255 |