scrn-ini.mkvi /size: 7681 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=scrn-ini,
3
%D version=2011.02.27,
4
%D title=\CONTEXT\ Interaction Macros,
5
%D subtitle=Initialization,
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
\writestatus
{
loading
}{
ConTeXt
Interaction
Macros
/
Initialization
}
15 16
\unprotect
17 18
\registerctxluafile
{
scrn
-
ini
}{}
19 20
%D There is no interaction at all unless enabled by saying:
21
%D
22
%D \starttyping
23
%D \setupinteraction[state=start]
24
%D \stoptyping
25
%D
26
%D The other settings are:
27
%D
28
%D \showsetup{setupinteraction}
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
% expandable
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
% todo: remember info at the lua end (already possible)
61
\to
\everyjob
62 63
% it makes no sense to create an environment as we will seldom have structured
64
% interactions so a general start-stop will do
65
%
66
% \appendtoks
67
% \setuevalue \currentinteraction {\scrn_interaction_direct{\currentinteraction}}%
68
% \setuevalue{\e!start\currentinteraction}{\scrn_interaction_start {\currentinteraction}}%
69
% \setuevalue{\e!stop \currentinteraction}{\scrn_interaction_stop }%
70
% \to \everydefineinteraction
71
%
72
% \unexpanded\def\scrn_interaction_direct#1%
73
% {\edef\currentinteraction{#1}}
74
%
75
% \unexpanded\def\scrn_interaction_start#1%
76
% {\pushmacro\currentinteraction
77
% \edef\currentinteraction{#1}}
78
%
79
% \unexpanded\def\scrn_interaction_stop
80
% {\popmacro\currentinteraction}
81
%
82
% \unexpanded\def\setinteraction[#1]%
83
% {\def\currentinteraction{#1}}
84
%
85
% \defineinteraction[\v!interaction]
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
% keep it simple
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
%D As long as there a natural feeling of what can be considered
109
%D hyper active or not, we have to tell users where they can
110
%D possibly click. We've already seen a few macros that deal
111
%D with this visualization, something we definitely do not let
112
%D up to the viewer. One way of telling is using a distinctive
113
%D typeface, another way is using color.
114
%D
115
%D There are two colors involved: one for normal hyperlinks,
116
%D and one for those that point to the currentpage, the
117
%D contrast color.
118 119
\definecolor
[
interactioncolor
]
[
r
=
0
,
g
=
.
6
,
b
=
0
]
120
\definecolor
[
interactioncontrastcolor
]
[
r
=
.
8
,
g
=
0
,
b
=
0
]
121 122
%D The next few macros are responsible for highlighting hyper
123
%D links. The first one, \type{\showlocation}, is used in those
124
%D situations where the typeface is handled by the calling
125
%D macro.
126 127
%D When we're dealing with pure page references, contrast
128
%D colors are used when we are already at the page mentioned.
129 130
\unexpanded
\def
\setlocationcolorspecified
#
1
% not grouped !
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
% we could just set and if > 0 set again
139
\useinteractioncolorparameter
\c!color
140
\fi
}
141 142
\unexpanded
\def
\setlocationattributesspecified
#
1
% not grouped !
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
% we could just set and if > 0 set again
151
\useinteractionstyleandcolor
\c!style\c!color
152
\fi
}
153 154
\unexpanded
\def
\setlocationcolorspecspecified
#
1
#
2
% \resolver
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
% not grouped !
171
{
\useinteractionstyleparameter
\c!style
}
172 173
\setupinteraction
174
[
\c!style
=
\v!bold
,
175
\c!color
=
interactioncolor
,
176
\c!contrastcolor
=
interactioncontrastcolor
]
177 178
%D Identity
179 180
% \def\scrn_identity_synchronize
181
% {\clf_setupidentity
182
% title {\interactionparameter\c!title}%
183
% subtitle {\interactionparameter\c!subtitle}%
184
% author {\interactionparameter\c!author}%
185
% % creator {ConTeXt - \contextversion}%
186
% date {\interactionparameter\c!date}%
187
% keywords {\interactionparameter\c!keyword}%
188
% \relax}
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
% creator {ConTeXt - \contextversion}%
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
% this comes before starttext
232 233
\def
\scrn_identity_document
#
1
#
2
%
234
{
\doifvariable
{
document
}{
metadata
:
#
1
}{
\setupinteraction
[#
2
=
\documentvariable
{
metadata
:
#
1
}
]
}}
235 236
\appendtoks
% not interfaced i.e. english
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
\everysetupdocument
246 247
\setupinteraction
248
[
\c!title
=
,
249
\c!subtitle
=
,
250
\c!author
=
,
251
\c!keyword
=
,
252
\c!date
=]
253 254
\protect
\endinput
255