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\permanent\protected\def\setlocationcolorspecified#1
142 {\ifnum#1=\plusone
143 \edef\p_contrastcolor{\interactionparameter\c!contrastcolor}
144 \ifempty\p_contrastcolor
145 \useinteractioncolorparameter\c!color
146 \else
147 \useinteractioncolorparameter\c!contrastcolor
148 \fi
149 \else
150 \useinteractioncolorparameter\c!color
151 \fi}
152
153\permanent\protected\def\setlocationattributesspecified#1
154 {\ifnum#1=\plusone
155 \edef\p_contrastcolor{\interactionparameter\c!contrastcolor}
156 \ifempty\p_contrastcolor
157 \useinteractionstyleandcolor\c!style\c!color
158 \else
159 \useinteractionstyleandcolor\c!style\c!contrastcolor
160 \fi
161 \else
162 \useinteractionstyleandcolor\c!style\c!color
163 \fi}
164
165\permanent\protected\def\setlocationcolorspecspecified#1#2
166 {\ifnum#1=\plusone
167 \edef\p_contrastcolor{#2\c!contrastcolor}
168 \ifempty\p_contrastcolor
169 \colo_helpers_activate{#2\c!color}
170 \else
171 \colo_helpers_activate\p_contrastcolor
172 \fi
173 \else
174 \colo_helpers_activate{#2\c!color}
175 \fi}
176
177\permanent\protected\def\setlocationcolor {\setlocationcolorspecified \referencepagestate}
178\permanent\protected\def\setlocationattributes{\setlocationattributesspecified\referencepagestate}
179\permanent\protected\def\setlocationcolorspec {\setlocationcolorspecspecified \referencepagestate}
180
181\permanent\protected\def\setlocationfont
182 {\useinteractionstyleparameter\c!style}
183
184\setupinteraction
185 [\c!style=\v!bold,
186 \c!color=interactioncolor,
187 \c!contrastcolor=interactioncontrastcolor]
188
189
190
191
192
193
194\def\scrn_identity_get#1
195 {\setidentityvariable{#1}{\prerolltostring{\interactionparameter{#1}}}}
196
197
198
199\def\scrn_identity_document#1#2
200 {\doifdocumentvariable{metadata:#1}{\setupinteraction[#2=\documentvariable{metadata:#1}]}}
201
202\appendtoks
203 \scrn_identity_document {title}\c!title
204 \scrn_identity_document {subject}\c!subtitle
205 \scrn_identity_document{subtitle}\c!subtitle
206 \scrn_identity_document {author}\c!author
207 \scrn_identity_document {authors}\c!author
208 \scrn_identity_document {keyword}\c!keyword
209 \scrn_identity_document{keywords}\c!keyword
210 \scrn_identity_document {date}\c!date
211\to \everystartdocument
212
213\appendtoks
214 \clf_setautoprefix{\interactionparameter\c!prefix}
215\to \everysetupinteraction
216
217\protect \endinput
218 |