scrn-wid.mkvi /size: 25 Kb    last modification: 2021-10-28 13:50
1
%D \module
2
%D [ file=scrn-int,
3
%D version=2011.02.27, % moved from scrn-int
4
%D title=\CONTEXT\ Core Macros,
5
%D subtitle=Widgets,
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
/
Widgets
}
15 16
\registerctxluafile
{
scrn
-
wid
}
{
}
17 18
% todo: expansion in comments (default is expanded)
19
% todo: check renderings ... acrobat crashes too easily on missing one
20 21
\unprotect
22 23
%D Attachments (mkiv upgraded):
24
%D
25
%D As usual in \CONTEXT\ we separate the general definition (frontend)
26
%D and the rendering (backend).
27 28
% hack: x\footnote{x\inleftmargin[scope=local]{\attachment[location=high,file=i-context.pdf]}}x
29 30
% old but stil valid method:
31
%
32
% \useattachment[test.tex]
33
% \useattachment[whatever][test.tex]
34
% \useattachment[whatever][newname][test.tex]
35
% \useattachment[whatever][title][newname][test.tex]
36
%
37
% new method:
38
%
39
% \registerattachment[sometag][specification] % name file author title subtitle
40
%
41
% \attachment[sometag][extra specs]
42
% \attachment[test.tex]
43
% \attachment[file=test.tex]
44
% \attachment[file=test.tex,method=hidden]
45
% \attachment[name=newname,file=test.tex]
46
% \attachment[title=mytitle,name=newname,file=test.tex]
47
%
48
% indirect
49
%
50
% \defineattachment[whatever5][file=test.tex] \attachment[whatever5][method=hidden]
51
% \defineattachment[whatever5][file=test.tex,method=hidden] \attachment[whatever5]
52
%
53
% direct (no definitions)
54
%
55
% \attachment[test][file=oeps.tex,title=Oeps,author=Hans,subtitle=TeX File,method=hidden]
56
% \attachment[label=test,file=oeps.tex,title=Oeps,author=Hans,subtitle=TeX File,method=hidden]
57
%
58
% autolabel:
59
%
60
% \attachment[file=oeps.tex,title=Oeps,author=Hans,subtitle=TeX File,method=hidden]
61
%
62
% % \setupattachments[\c!symbol={symbol-normal,symbol-down}]
63 64
% startattachment -> temp file
65 66
\newbox
\b_scrn_attachment_collect
67
\newbox
\b_scrn_attachment_link
68
\newbox
\b_scrn_attachment_symbol
69 70
\installcorenamespace
{
attachment
}
71
\installcorenamespace
{
attachmentlocation
}
72
\installcorenamespace
{
attachmentmethod
}
73 74
\installcommandhandler
\??attachment
{
attachment
}
\??attachment
75 76
\let
\setupattachments
\setupattachment
% convenience and compatibility
77 78
\setupattachment
79
[
\c!state
=
\v!start
,
80
\c!color
=
\interactionparameter
\c!color
,
81
%\c!textlayer=,
82
%\c!symbol=,
83
%\c!title=,
84
%\c!subtitle=,
85
%\c!file=, % input filename
86
%\c!name=, % new filename
87
%\c!author=,
88
%\c!method=, % \v!hidden = not in menu
89
%\c!buffer=
90
\c!symbol
=
,
91
\c!distance
=
\emwidth
,
92
\c!width
=
\v!fit
,
93
\c!height
=
\v!fit
,
94
\c!depth
=
\v!fit
,
95
\c!location
=
\v!high
]
96 97
\unexpanded
\def
\registerattachment
98
{
\dodoubleempty
\scrn_attachment_register
}
99 100
\def
\scrn_attachment_register
[
#
tag
]
[
#
settings
]
% we save (globally) at the lua end
101
{
\ifsecondargument
102
\begingroup
103
\def
\currentattachment
{
_
}
%
104
\setupcurrentattachment
[
#
settings
,
\s!parent
=
\??attachment
]
%
105
\clf_registerattachment
106
tag
{
#
tag
}
%
107
registered
{
#
tag
}
%
108
title
{
\attachmentparameter
\c!title
}
%
109
subtitle
{
\attachmentparameter
\c!subtitle
}
%
110
author
{
\attachmentparameter
\c!author
}
%
111
file
{
\attachmentparameter
\c!file
}
%
112
name
{
\attachmentparameter
\c!name
}
%
113
buffer
{
\attachmentparameter
\c!buffer
}
%
114
mimetype
{
\attachmentparameter
\c!type
}
%
115
\relax
116
\endgroup
117
\else
118
% todo
119
\fi
}
120 121
\appendtoks
122
\setuevalue
\currentattachment
{
\scrn_attachment_direct
{
\currentattachment
}
}
%
123
\setuevalue
{
\e!start
\currentattachment
}
{
\scrn_attachment_start
{
\currentattachment
}
}
%
124
\setuevalue
{
\e!stop
\currentattachment
}
{
\scrn_attachment_stop
}
%
125
\to
\everydefineattachment
126 127
\unexpanded
\def
\scrn_attachment_direct
#
tag
%
128
{
\edef
\currentattachment
{
#
tag
}
%
129
\doifelselocation
130
{
\dodoubleempty
\scrn_attachment_direct_status
}
131
{
\dodoubleempty
\scrn_attachment_direct_ignore
}
}
132 133
\def
\scrn_attachment_direct_status
134
{
\doifelse
{
\attachmentparameter
\c!state
}
\v!start
135
\scrn_attachment_direct_indeed
136
\scrn_attachment_direct_ignore
}
137 138
\def
\scrn_attachment_direct_indeed
[
#
registered
]
[
#
settings
]
%
139
{
\bgroup
140
\doifelsenothing
{
#
registered
}
141
{
\scrn_attachment_inject
[
\v!auto
]
[
]
}
142
{
\doifelseassignment
{
#
registered
}
143
{
\scrn_attachment_inject
[
\v!auto
]
[
#
registered
]
}
144
{
\scrn_attachment_inject
[
#
registered
]
[
#
settings
]
}
}
%
145
\egroup
}
146 147
\def
\scrn_attachment_direct_ignore
[
#
tag
]
[
#
settings
]
%
148
{
}
149 150
\unexpanded
\def
\scrn_attachment_start
#
tag
%
151
{
\edef
\currentattachment
{
#
tag
}
%
152
\doifelselocation
153
{
\dodoubleempty
\scrn_attachment_start_indeed
}
154
{
\dodoubleempty
\scrn_attachment_start_ignore
}
}
155 156
\unexpanded
\def
\scrn_attachment_stop
157
{
}
158 159
\def
\scrn_attachment_start_indeed
160
{
\doif
{
\attachmentparameter
\c!state
}
\v!start
161
{
\scrn_attachment_start_indeed
}
162
{
\scrn_attachment_start_ignore
}
}
163 164
\def
\scrn_attachment_start_indeed
[
#
registered
]
[
#
settings
]
%
165
{
\bgroup
166
\doifelsenothing
{
#
registered
}
167
{
\def
\scrn_attachment_stop
{
\scrn_attachment_inject
[
\v!auto
]
[
\c!buffer
=
\v!attachment
]
\egroup
}
}
%
168
{
\doifelseassignment
{
#
registered
}
169
{
\def
\scrn_attachment_stop
{
\scrn_attachment_inject
[
\v!auto
]
[
\c!buffer
=
\v!attachment
,
#
registered
]
\egroup
}
}
%
170
{
\def
\scrn_attachment_stop
{
\scrn_attachment_inject
[
#
registered
]
[
\c!buffer
=
\v!attachment
,
#
settings
]
\egroup
}
}
}
%
171
\grabbufferdatadirect
\v!attachment
{
\e!start
\currentattachment
}
{
\e!stop
\currentattachment
}
}
172 173
\def
\scrn_attachment_start_ignore
174
{
\expandafter
\gobbleuntil
\csname
\e!stop
\currentattachment
\endcsname
}
175 176
\def
\scrn_attachment_inject
[
#
registered
]
[
#
settings
]
%
177
{
\edef
\currentattachmentregistered
{
#
registered
}
%
178
\setupattachment
[
\currentattachment
]
[
#
settings
]
%
179
\expandnamespaceparameter
\??attachmentmethod
\attachmentparameter
\c!method
\v!normal
}
180 181
\setvalue
{
\??attachmentmethod
\v!normal
}
%
182
{
\edef
\currentattachmentsymbol
{
\attachmentparameter
\c!symbol
}
%
183
\edef
\currentattachmentwidth
{
\attachmentparameter
\c!width
}
%
184
\edef
\currentattachmentheight
{
\attachmentparameter
\c!height
}
%
185
\edef
\currentattachmentdepth
{
\attachmentparameter
\c!depth
}
%
186
\ifx
\currentattachmentsymbol
\empty
187
\ifx
\currentattachmentwidth
\v!fit
\edef
\currentattachmentwidth
{
.
5
\emwidth
}
\fi
188
\ifx
\currentattachmentheight
\v!fit
\edef
\currentattachmentheight
{
.
5
\emwidth
}
\fi
189
\ifx
\currentattachmentdepth
\v!fit
\let
\currentattachmentdepth
\zeropoint
\fi
190
\else
191
\clf_presetsymbollist
{
\attachmentparameter
\c!symbol
}
%
192
% we cannot yet ask for the wd/ht/dp of an xform else we could use those
193
\setbox
\b_scrn_attachment_symbol
\hbox
{
\symbol
[
\lastpredefinedsymbol
]
}
%
194
\ifx
\currentattachmentwidth
\v!fit
\edef
\currentattachmentwidth
{
\wd
\b_scrn_attachment_symbol
}
\fi
195
\ifx
\currentattachmentheight
\v!fit
\edef
\currentattachmentheight
{
\ht
\b_scrn_attachment_symbol
}
\fi
196
\ifx
\currentattachmentdepth
\v!fit
\edef
\currentattachmentdepth
{
\dp
\b_scrn_attachment_symbol
}
\fi
197
\fi
198
\clf_insertattachment
199
tag
{
\currentattachment
}
%
200
registered
{
\currentattachmentregistered
}
%
201
width
\dimexpr
\currentattachmentwidth
\relax
202
height
\dimexpr
\currentattachmentheight
\relax
203
depth
\dimexpr
\currentattachmentdepth
\relax
204
color
{
\attachmentparameter
\c!color
}
%
205
colormodel
\c_attr_colormodel
206
colorvalue
\numexpr
\thecolorattribute
{
\attachmentparameter
\c!color
}
\relax
% or are these chardefs
207
transparencyvalue
\numexpr
\thetransparencyattribute
{
\attachmentparameter
\c!color
}
\relax
% or are these chardefs
208
symbol
{
\currentattachmentsymbol
}
%
209
layer
{
\attachmentparameter
\c!textlayer
}
%
210
% these will be overloaded by registered when available
211
title
{
\attachmentparameter
\c!title
}
%
212
subtitle
{
\attachmentparameter
\c!subtitle
}
%
213
author
{
\attachmentparameter
\c!author
}
%
214
file
{
\attachmentparameter
\c!file
}
%
215
name
{
\attachmentparameter
\c!name
}
%
216
buffer
{
\attachmentparameter
\c!buffer
}
%
217
mimetype
{
\attachmentparameter
\c!type
}
%
218
\relax
219
\wd
\b_scrn_attachment_link
\currentattachmentwidth
220
\ht
\b_scrn_attachment_link
\currentattachmentheight
221
\dp
\b_scrn_attachment_link
\currentattachmentdepth
222
\expandnamespaceparameter
\??attachmentlocation
\attachmentparameter
\c!location
\s!unknown
}
223 224
\setvalue
{
\??attachmentmethod
\v!hidden
}
%
225
{
\clf_insertattachment
226
tag
{
\currentattachment
}
%
227
registered
{
\currentattachmentregistered
}
%
228
method
{
\v!hidden
}
%
229
title
{
\attachmentparameter
\c!title
}
%
230
subtitle
{
\attachmentparameter
\c!subtitle
}
%
231
author
{
\attachmentparameter
\c!author
}
%
232
file
{
\attachmentparameter
\c!file
}
%
233
name
{
\attachmentparameter
\c!name
}
%
234
buffer
{
\attachmentparameter
\c!buffer
}
%
235
mimetype
{
\attachmentparameter
\c!type
}
%
236
\relax
}
237 238
\unexpanded
\def
\scrn_attachment_flush_traced
239
{
\hpack
\bgroup
240
\blackrule
% can be a fast one
241
[
\c!color
=
trace
:
r
,
242
\c!width
=
\wd
\b_scrn_attachment_link
,
243
\c!height
=
\ht
\b_scrn_attachment_link
,
244
\c!depth
=
\dp
\b_scrn_attachment_link
]
%
245
\kern
-
\wd
\b_scrn_attachment_link
246
\box
\b_scrn_attachment_link
247
\egroup
}
248 249
\unexpanded
\def
\scrn_attachment_flush_normal
250
{
\box
\b_scrn_attachment_link
}
251 252
\installtextracker
253
{
attachments
.
anchors
}
254
{
\let
\scrn_attachment_flush
\scrn_attachment_flush_traced
}
255
{
\let
\scrn_attachment_flush
\scrn_attachment_flush_normal
}
256 257
\let
\scrn_attachment_flush
\scrn_attachment_flush_normal
258 259
\setvalue
{
\??attachmentlocation
\v!inmargin
}
{
\inmargin
{
\scrn_attachment_flush
}
}
260
\setvalue
{
\??attachmentlocation
\v!leftedge
}
{
\inleftedge
{
\scrn_attachment_flush
}
}
261
\setvalue
{
\??attachmentlocation
\v!rightedge
}
{
\inrightedge
{
\scrn_attachment_flush
}
}
262
\setvalue
{
\??attachmentlocation
\v!leftmargin
}
{
\inleftmargin
{
\scrn_attachment_flush
}
}
263
\setvalue
{
\??attachmentlocation
\v!rightmargin
}
{
\inrightmargin
{
\scrn_attachment_flush
}
}
264
\setvalue
{
\??attachmentlocation
\v!high
}
{
\high
{
\scrn_attachment_flush
}
}
265 266
\setvalue
{
\??attachmentlocation
\v!none
}
%
267
{
\global
\setbox
\b_scrn_attachment_collect
\hbox
\bgroup
268
\ifvoid
\b_scrn_attachment_collect
\else
269
\box
\b_scrn_attachment_collect
270
\hskip
\attachmentparameter
\c!distance
\relax
271
\fi
272
\scrn_attachment_flush
273
\egroup
}
274 275
\setvalue
{
\??attachmentlocation
\s!unknown
}
%
276
{
\ifvoid
\b_scrn_attachment_collect
\else
277
\box
\b_scrn_attachment_collect
278
\fi
}
279 280
\unexpanded
\def
\placeattachments
281
{
\ifvoid
\b_scrn_attachment_collect
\else
282
\box
\b_scrn_attachment_collect
283
\fi
}
284 285
\defineattachment
[
attachment
]
286 287
% \ifx\currentinterface\defaultinterface \else
288
% \defineattachment[\v!attachment]
289
% \fi
290 291
% backward compatible:
292 293
\unexpanded
\def
\useattachment
294
{
\doquadrupleempty
\scrn_attachment_use
}
295 296
\def
\scrn_attachment_use
[
#
tag
]
[
#
title
]
[
#
name
]
[
#
file
]
%
297
{
\iffourthargument
298
\registerattachment
[
#
tag
]
[
title
=
#
title
,
name
=
#
name
,
file
=
#
file
]
%
299
\else
\ifthirdargument
300
\registerattachment
[
#
tag
]
[
title
=
#
title
,
name
=
#
title
,
file
=
#
name
]
%
301
\else
\ifsecondargument
302
\registerattachment
[
#
tag
]
[
title
=
#
title
,
name
=
#
title
,
file
=
#
title
]
%
303
\else
304
\registerattachment
[
#
tag
]
[
title
=
#
tag
,
name
=
#
tag
,
file
=
#
tag
]
%
305
\fi
\fi
\fi
}
306 307
%D Comments:
308 309
% test
310
%
311
% \startcomment
312
% hello beautiful\\world
313
% \stopcomment
314
%
315
% test
316
%
317
% \startcomment[hello]
318
% hello << eerste >>
319
% beautiful
320
% world
321
% \stopcomment
322
%
323
% test
324
%
325
% \startcomment[hello][color=green,width=10cm,height=3cm]
326
% hello
327
% beautiful
328
% world
329
% \stopcomment
330
%
331
% test
332
%
333
% \startcomment[hello][color=red,width=4cm,height=3cm]
334
% hello
335
%
336
% beautiful
337
%
338
% world
339
% \stopcomment
340
%
341
% test
342
%
343
% \startcomment[symbol=Help]
344
% Do we want this kind of rubish?
345
% \stopcomment
346
%
347
% test
348
%
349
% \definesymbol [comment-normal][{\externalfigure[cow.pdf]}]
350
% \definesymbol [comment-down] [{\externalfigure[cow.pdf]}]
351
%
352
% \def\CowSymbol#1#2%
353
% {\scale
354
% [\c!height=#1]
355
% {\startMPcode
356
% loadfigure "koe.mp" number 1 ;
357
% refill currentpicture withcolor #2 ;
358
% \stopMPcode}}
359
%
360
% \definesymbol [comment-normal]
361
% [\CowSymbol{4ex}{red}]
362
%
363
% \definesymbol [comment-down]
364
% [\CowSymbol{4ex}{green}]
365
%
366
% \setupcomment
367
% [\c!symbol={comment-normal,comment-down},
368
% \c!option=\v!buffer]
369
%
370
% \startcomment[hello]
371
% oeps
372
% \stopcomment
373
%
374
% test
375
%
376
% \setupcomment
377
% [\c!symbol=normal,
378
% \c!option=max,width=10cm]
379
%
380
% \startcomment[hello]
381
% oeps
382
% \stopcomment
383
%
384
% test
385 386
%D The implementation is mostly the same as for attachments but sharing code
387
%D will not make it cleaner.
388 389
\installcorenamespace
{
comment
}
390
\installcorenamespace
{
commentlocation
}
391 392
\installcommandhandler
\??comment
{
comment
}
\??comment
393 394
\newbox
\b_scrn_comment_collect
395
\newbox
\b_scrn_comment_rendering
396
\newbox
\b_scrn_comment_link
397
\newbox
\b_scrn_comment_symbol
398 399
\setupcomment
400
[
\c!state
=
\v!start
,
401
\c!distance
=
\emwidth
,
402
\c!color
=
\interactionparameter
\c!color
,
403
\c!space
=
\v!no
,
404
\c!symbol
=
,
405
%\c!title=,
406
%\c!option=,
407
%\c!textlayer=,
408
\c!width
=
\v!fit
,
409
\c!height
=
\v!fit
,
410
\c!depth
=
\v!fit
,
411
\c!nx
=
4
0
,
412
\c!ny
=
1
0
,
413
\c!buffer
=
\v!comment
,
414
\c!location
=
\v!high
]
415 416
\appendtoks
417
\setuevalue
\currentcomment
{
\scrn_comment_argument
{
\currentcomment
}
}
%
418
\setuevalue
{
\e!start
\currentcomment
}
{
\scrn_comment_start
{
\currentcomment
}
}
%
419
\setuevalue
{
\e!stop
\currentcomment
}
{
\scrn_comment_stop
}
%
420
\to
\everydefinecomment
421 422
\unexpanded
\def
\scrn_comment_argument
#
category
%
423
{
\def
\currentcomment
{
#
category
}
%
424
\doifelselocation
425
{
\dodoubleempty
\scrn_comment_argument_status
}
426
{
\dodoubleempty
\scrn_comment_argument_ignore
}
}
427 428
\def
\scrn_comment_argument_status
429
{
\doifelse
{
\commentparameter
\c!state
}
\v!start
430
\scrn_comment_argument_indeed
431
\scrn_comment_argument_ignore
}
432 433
\def
\scrn_comment_argument_indeed
[
#
title
]
[
#
settings
]
#
text
%
434
{
\doifelseassignment
{
#
title
}
435
{
\setupcurrentcomment
[
#
title
]
}
436
{
\setupcurrentcomment
[
\c!title
=
#
title
,
#
settings
]
}
%
437
\clf_assignbuffer
{
\v!comment
}
{
#
text
}
\catcodetable
\relax
% todo: expansion control, but expanded by default (xml)
438
\scrn_comment_inject
439
\ignorespaces
}
440 441
\def
\scrn_comment_argument_ignore
[
#
title
]
[
#
settings
]
#
text
%
442
{
\ignorespaces
}
443 444
\unexpanded
\def
\scrn_comment_start
#
category
%
445
{
\def
\currentcomment
{
#
category
}
%
446
\doifelselocation
447
{
\dodoubleempty
\scrn_comment_start_status
}
448
{
\dodoubleempty
\scrn_comment_start_ignore
}
}
449 450
\def
\scrn_comment_start_status
451
{
\doifelse
{
\commentparameter
\c!state
}
\v!start
452
{
\scrn_comment_start_indeed
}
453
{
\scrn_comment_start_ignore
}
}
454 455
\def
\scrn_comment_start_indeed
[
#
title
]
[
#
settings
]
%
456
{
\bgroup
457
\doifelseassignment
{
#
title
}
458
{
\setupcurrentcomment
[
#
title
]
}
459
{
\setupcurrentcomment
[
\c!title
=
#
title
,
#
settings
]
}
%
460
\unexpanded
\def
\scrn_comment_stop
{
\scrn_comment_inject
\egroup
}
%
461
\grabbufferdatadirect
\v!comment
{
\e!start
\currentcomment
}
{
\e!stop
\currentcomment
}
}
462 463
\def
\scrn_comment_start_ignore
464
{
\expandafter
\gobbleuntil
\csname
\e!stop
\currentcomment
\endcsname
}
465 466
\unexpanded
\def
\scrn_comment_stop
467
{
}
468 469
\installcorenamespace
{
commentmethods
}
470 471
\unexpanded
\def
\scrn_comment_inject
472
{
\expandnamespaceparameter
\??commentmethods
\commentparameter
\c!method
\v!normal
}
473 474
%D Beware: comments symbols don't scale in acrobat (cf. spec but somewhat
475
%D weird, esp because for instance attachment symbols do scale).
476 477
\setvalue
{
\??commentmethods
\v!normal
}
%
478
{
\edef
\currentcommentsymbol
{
\commentparameter
\c!symbol
}
%
479
\edef
\currentcommentwidth
{
\commentparameter
\c!width
}
%
480
\edef
\currentcommentheight
{
\commentparameter
\c!height
}
%
481
\edef
\currentcommentdepth
{
\commentparameter
\c!depth
}
%
482
\ifx
\currentcommentsymbol
\empty
483
\ifx
\currentcommentwidth
\v!fit
\edef
\currentcommentwidth
{
.
5
\emwidth
}
\fi
484
\ifx
\currentcommentheight
\v!fit
\edef
\currentcommentheight
{
.
5
\emwidth
}
\fi
485
\ifx
\currentcommentdepth
\v!fit
\let
\currentcommentdepth
\zeropoint
\fi
486
\else
487
\clf_presetsymbollist
{
\commentparameter
\c!symbol
}
%
488
% we cannot yet ask for the wd/ht/dp of an xform else we could use those
489
\setbox
\b_scrn_comment_symbol
\hbox
{
\symbol
[
\lastpredefinedsymbol
]
}
%
490
\ifx
\currentcommentwidth
\v!fit
\edef
\currentcommentwidth
{
\wd
\b_scrn_comment_symbol
}
\fi
491
\ifx
\currentcommentheight
\v!fit
\edef
\currentcommentheight
{
\ht
\b_scrn_comment_symbol
}
\fi
492
\ifx
\currentcommentdepth
\v!fit
\edef
\currentcommentdepth
{
\dp
\b_scrn_comment_symbol
}
\fi
493
\fi
494
\clf_insertcomment
495
tag
{
\currentcomment
}
%
496
title
{
\commentparameter
\c!title
}
%
497
subtitle
{
\commentparameter
\c!subtitle
}
%
498
author
{
\commentparameter
\c!author
}
%
499
width
\dimexpr
\currentcommentwidth
\relax
500
height
\dimexpr
\currentcommentheight
\relax
501
depth
\dimexpr
\currentcommentdepth
\relax
502
nx
{
\commentparameter
\c!nx
}
%
503
ny
{
\commentparameter
\c!ny
}
%
504
colormodel
\c_attr_colormodel
505
colorvalue
\numexpr
\thecolorattribute
{
\commentparameter
\c!color
}
\relax
506
transparencyvalue
\numexpr
\thetransparencyattribute
{
\commentparameter
\c!color
}
\relax
507
option
{
\commentparameter
\c!option
}
% % todo
508
symbol
{
\commentparameter
\c!symbol
}
%
509
buffer
{
\commentparameter
\c!buffer
}
% {\v!comment}%
510
layer
{
\commentparameter
\c!textlayer
}
%
511
space
{
\commentparameter
\c!space
}
%
512
\relax
513
\wd
\b_scrn_comment_link
\currentcommentwidth
514
\ht
\b_scrn_comment_link
\currentcommentheight
515
\dp
\b_scrn_comment_link
\currentcommentdepth
516
\expandnamespaceparameter
\??commentlocation
\commentparameter
\c!location
\s!unknown
}
517 518
\letvalue
{
\??commentmethods
\v!hidden
}
\donothing
519 520
\unexpanded
\def
\scrn_comment_flush_traced
521
{
\hpack
\bgroup
522
\blackrule
% can be a fast one
523
[
\c!color
=
trace
:
y
,
524
\c!width
=
\wd
\b_scrn_comment_link
,
525
\c!height
=
\ht
\b_scrn_comment_link
,
526
\c!depth
=
\dp
\b_scrn_comment_link
]
%
527
\kern
-
\wd
\b_scrn_comment_link
528
\box
\b_scrn_comment_link
529
\egroup
}
530 531
\unexpanded
\def
\scrn_comment_flush_normal
532
{
\box
\b_scrn_comment_link
}
533 534
\installtextracker
535
{
comments
.
anchors
}
536
{
\let
\scrn_comment_flush
\scrn_comment_flush_traced
}
537
{
\let
\scrn_comment_flush
\scrn_comment_flush_normal
}
538 539
\let
\scrn_comment_flush
\scrn_comment_flush_normal
540 541
% todo: dedicated margin classes
542 543
\setvalue
{
\??commentlocation
\v!inmargin
}
{
\inmargin
{
\scrn_comment_flush
}
}
544
\setvalue
{
\??commentlocation
\v!leftedge
}
{
\inleftedge
{
\scrn_comment_flush
}
}
545
\setvalue
{
\??commentlocation
\v!rightedge
}
{
\inrightedge
{
\scrn_comment_flush
}
}
546
\setvalue
{
\??commentlocation
\v!leftmargin
}
{
\inleftmargin
{
\scrn_comment_flush
}
}
547
\setvalue
{
\??commentlocation
\v!rightmargin
}
{
\inrightmargin
{
\scrn_comment_flush
}
}
548
\setvalue
{
\??commentlocation
\v!high
}
{
\high
{
\scrn_comment_flush
}
}
549 550
\setvalue
{
\??commentlocation
\v!none
}
%
551
{
\global
\setbox
\b_scrn_comment_collect
\hbox
\bgroup
552
\ifvoid
\b_scrn_comment_collect
\else
553
\box
\b_scrn_comment_collect
554
\hskip
\commentparameter
\c!distance
\relax
555
\fi
556
\scrn_comment_flush
557
\egroup
}
558 559
\setvalue
{
\??commentlocation
\s!unknown
}
%
560
{
\ifvoid
\b_scrn_comment_collect
\else
561
\box
\b_scrn_comment_collect
562
\fi
}
563 564
\unexpanded
\def
\placecomments
565
{
\ifvoid
\b_scrn_comment_collect
\else
566
\box
\b_scrn_comment_collect
567
\fi
}
568 569
\definecomment
[
comment
]
570 571
% \ifx\currentinterface\defaultinterface \else
572
% \definecomment[\v!comment]
573
% \fi
574 575
%D Soundclips:
576
%D
577
%D Defining sound tracks:
578
%D
579
%D \starttyping
580
%D \useexternalsoundtrack[label][file]
581
%D \stoptyping
582
%D
583
%D associated actions: StartSound StopSound PauseSound ResumeSound
584
%D
585
%D Todo: like external figures, also search on path,
586
%D although, they need to be present ar viewing time, so ...
587 588
\installcorenamespace
{
externalsoundtracks
}
589 590
\installsetuponlycommandhandler
\??externalsoundtracks
{
externalsoundtracks
}
591 592
\setupexternalsoundtracks
593
[
\c!option
=
]
594 595
\unexpanded
\def
\useexternalsoundtrack
596
{
\dodoubleargument
\scrn_soundtrack_indeed
}
597 598
\def
\scrn_soundtrack_indeed
[
#
tag
]
[
#
filename
]
%
599
{
\clf_registersoundclip
600
tag
{
#
tag
}
%
601
file
{
#
filename
}
%
602
\relax
}
603 604
\def
\checksoundtrack
#
tag
% yet untested in mkiv (also move management to lua)
605
{
\iflocation
606
\clf_insertsoundclip
607
tag
{
#
tag
}
%
608
repeat
{
\directexternalsoundtracksparameter
\c!option
}
%
609
\relax
610
\fi
}
611 612
%D Renderings (not yet tested in mkvi):
613 614
% Todo: multiple instances and inheritance .. will be done when
615
% needed i.e. when I see usage.
616 617
\let
\currentrendering
\empty
618 619
\definereference
[
StartCurrentRendering
]
[
\v!StartRendering
{
\currentrendering
}
]
620
\definereference
[
StopCurrentRendering
]
[
\v!StopRendering
{
\currentrendering
}
]
621
\definereference
[
PauseCurrentRendering
]
[
\v!PauseRendering
{
\currentrendering
}
]
622
\definereference
[
ResumeCurrentRendering
]
[
\v!ResumeRendering
{
\currentrendering
}
]
623 624
\unexpanded
\def
\useexternalrendering
{
\doquadrupleempty
\scrn_rendering_use
}
625
\unexpanded
\def
\setinternalrendering
{
\dodoubleempty
\scrn_rendering_set
}
626 627
\def
\scrn_rendering_use
[
#
tag
]
[
#
mime
]
[
#
file
]
[
#
option
]
%
628
{
\clf_registerrendering
629
type
{
external
}
%
630
label
{
#
tag
}
%
631
mime
{
#
mime
}
%
632
filename
{
#
file
}
%
633
option
{
#
option
}
%
634
\relax
}
635 636
\def
\scrn_rendering_set
[
#
tag
]
[
#
option
]
% {content} % crappy
637
{
\bgroup
638
\dowithnextbox
639
{
\clf_registerrendering
640
type
{
internal
}
%
641
label
{
#
tag
}
%
642
mime
{
IRO
}
% brrr
643
filename
{
#
tag
}
%
644
option
{
#
option
}
%
645
\relax
646
\let
\objectoffset
\zeropoint
647
\setobject
{
IRO
}
{
#
tag
}
\hpack
{
\box
\nextbox
}
%
648
\egroup
}
%
649
\hbox
}
650 651
\def
\renderingtype
#
tag
{
\clf_renderingvar
{
#
tag
}
{
type
}
}
652
\def
\renderingoption
#
tag
{
\clf_renderingvar
{
#
tag
}
{
option
}
}
653 654
\newdimen
\d_scrn_rendering_width
\d_scrn_rendering_width
8
cm
655
\newdimen
\d_scrn_rendering_height
\d_scrn_rendering_height
6
cm
656 657
\let
\m_scrn_rendering_page
\!!zerocount
658 659
\installcorenamespace
{
renderingwindow
}
660 661
\installframedcommandhandler
\??renderingwindow
{
renderingwindow
}
\??renderingwindow
662 663
\appendtoks
664
\letrenderingwindowparameter
\c!openpageaction
\empty
665
\letrenderingwindowparameter
\c!closepageaction
\empty
666
\setrenderingwindowparameter
\c!width
{
\d_scrn_rendering_width
}
%
667
\setrenderingwindowparameter
\c!height
{
\d_scrn_rendering_height
}
%
668
\letrenderingwindowparameter
\c!align
\v!flushleft
669
\to
\everypresetrenderingwindow
670 671
\unexpanded
\def
\placerenderingwindow
672
{
\dodoubleempty
\scrn_rendering_place_window
}
673 674
\def
\scrn_rendering_place_window
[
#
window
]
[
#
rendering
]
% do all in lua
675
{
\bgroup
676
\edef
\currentrendering
{
\ifsecondargument
#
rendering
\else
#
window
\fi
}
%
677
% create fall back if needed
678
\edef
\currentrenderingwindow
{
\namedrenderingwindowparameter
{
#
window
}
\c!width
}
% stupid test, we need a proper one here
679
\ifx
\currentrenderingwindow
\empty
680
\let
\currentrenderingwindow
\s!default
681
\definerenderingwindow
[
\currentrenderingwindow
]
% why not global
682
\else
683
\edef
\currentrenderingwindow
{
#
window
}
%
684
\fi
685
\edef
\currentrenderingtype
{
\renderingtype
\currentrendering
}
%
686
\ifx
\currentrenderingtype
\s!internal
687
\getobjectdimensions
{
IRO
}
\currentrendering
688
\d_scrn_rendering_height
\dimexpr
\objectheight
+
\objectdepth
\relax
689
\d_scrn_rendering_width
\objectwidth
\relax
690
\dogetobjectreferencepage
{
IRO
}
\currentrendering
\m_scrn_rendering_page
691
\else
\ifx
\currentrenderingwindow
\s!default
692
\d_scrn_rendering_height
\vsize
693
\d_scrn_rendering_width
\hsize
694
\let
\m_scrn_rendering_page
\realpageno
695
\else
696
\d_scrn_rendering_height
\renderingwindowparameter
\c!height
697
\d_scrn_rendering_width
\renderingwindowparameter
\c!width
698
\let
\m_scrn_rendering_page
\realpageno
699
\fi
\fi
700
% todo:
701
% \handlereferenceactions{\renderingwindowparameter\c!openpageaction }\dosetuprenderingopenpageaction
702
% \handlereferenceactions{\renderingwindowparameter\c!closepageaction}\dosetuprenderingclosepageaction
703
\letrenderingwindowparameter
\c!offset
\v!overlay
704
\inheritedrenderingwindowframed
705
{
\vfilll
706
\dontleavehmode
707
\clf_insertrenderingwindow
708
label
{
\currentrendering
}
%
709
width
\d_scrn_rendering_width
710
height
\d_scrn_rendering_height
711
option
{
\renderingoption
\currentrendering
}
%
712
page
\m_scrn_rendering_page
713
\relax
714
\hfill
}
%
715
\egroup
}
716 717
%D Linkedlists (not tested in mkvi):
718 719
% %D The next mechanism, linked lists, is quite old and
720
% %D is \MKIV'd for completeness. I will finish the
721
% %D configuration part when I need it.
722
% %D
723
% %D \starttyping
724
% %D \setupinteraction[state=start]
725
% %D \definelinkedlist[demo]
726
% %D \dorecurse{10}{\linkedlistelement[demo]{link \recurselevel} \page}
727
% %D \stoptyping
728
%
729
% \definesystemvariable {lk} % LinK
730
%
731
% \installcommandhandler\??lk{linkedlist}\??lk
732
%
733
% \let\setupbutton\setuplinkedlists\setuplinkedlist
734
%
735
% \appendtoks
736
% \clf_definelinkedlist{\currentlinkedlist}%
737
% \to \everydefinelinkedlist
738
%
739
% \def\setlinkedlistproperties#1#2#3#4#5#6%
740
% {\def\currentlink {#1}%
741
% \def\noflinks {#2}%
742
% \def\firstlink {#3}%
743
% \def\previouslink{#4}%
744
% \def\nextlink {#5}%
745
% \def\lastlink {#6}}
746
%
747
% \def\linkedlistelement[#1]#2% currently no view support
748
% {\dontleavehmode\hbox\bgroup
749
% #2%
750
% \iflocation
751
% \edef\currentlinkedlist{#1}%
752
% \ifcsname\??lk\currentlinkedlist\s!parent\endcsname
753
% \hskip\linkedlistparameter\c!distance\relax
754
% \clf_addlinklistelement{\currentlinkedlist}%
755
% \expanded{\ctxlatecommand{enhancelinkedlist("\currentlinkedlist",\currentlink)}}% can also be done at the lua end
756
% \dogotosomepage {\??lk\currentlinkedlist}\gotobegincharacter \firstlink
757
% \ifnum\noflinks>\plustwo
758
% \dogotosomepage{\??lk\currentlinkedlist}\gobackwardcharacter\previouslink
759
% \dogotosomepage{\??lk\currentlinkedlist}\goforwardcharacter \nextlink
760
% \fi
761
% \dogotosomepage {\??lk\currentlinkedlist}\gotoendcharacter \lastlink
762
% \else
763
% \writestatus\m!interactions{no such linked list: \currentlinkedlist}%
764
% \fi
765
% \fi
766
% \egroup}
767
%
768
% \setuplinkedlists
769
% [\c!distance=.25em,
770
% \c!width=\v!fit,
771
% \c!location=\v!low,
772
% \c!color=\interactionparameter\c!color,
773
% \c!frame=\v!off,
774
% \c!background=,
775
% \c!backgroundcolor=]
776 777
\protect
\endinput
778