1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Interaction Macros Widgets}
15
16\registerctxluafile{scrnwid}{autosuffix}
17
18
19
20
21\unprotect
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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\aliased\let\setupattachments\setupattachment
77
78\setupattachment
79 [\c!state=\v!start,
80 \c!color=\interactionparameter\c!color,
81
82
83
84
85
86
87
88
89
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\mutable\lettonothing\currentattachmentdepth
98\mutable\lettonothing\currentattachmentheight
99\mutable\lettonothing\currentattachmentregistered
100\mutable\lettonothing\currentattachmentsymbol
101\mutable\lettonothing\currentattachmentwidth
102
103\permanent\tolerant\protected\def\registerattachment[#tag]#spacer[#S#settings]
104 {\ifarguments\else
105 \begingroup
106 \cdef\currentattachment{}
107 \setupcurrentattachment[#settings,\s!parent=\??attachment]
108 \clf_registerattachment
109 tag {#tag}
110 registered {#tag}
111 title {\attachmentparameter\c!title}
112 subtitle {\attachmentparameter\c!subtitle}
113 author {\attachmentparameter\c!author}
114 file {\attachmentparameter\c!file}
115 name {\attachmentparameter\c!name}
116 buffer {\attachmentparameter\c!buffer}
117 mimetype {\attachmentparameter\c!type}
118 \relax
119 \endgroup
120 \fi}
121
122\appendtoks
123 \frozen\instance\protected\edefcsname \currentattachment\endcsname{\scrn_attachment_direct[\currentattachment]}
124 \frozen\instance\protected\edefcsname\e!start\currentattachment\endcsname{\scrn_attachment_start [\currentattachment]}
125 \frozen\instance\protected\edefcsname\e!stop \currentattachment\endcsname{\scrn_attachment_stop }
126\to \everydefineattachment
127
128\permanent\tolerant\protected\def\scrn_attachment_direct[#tag]#spacer[#registered]#spacer[#S#settings]
129 {\iflocation
130 \bgroup
131 \cdef\currentattachment{#tag}
132 \ifcstok{\attachmentparameter\c!state}\v!start
133 \ifempty{#registered}
134 \scrn_attachment_inject[\v!auto][]
135 \orelse\ifhastok={#registered}
136 \scrn_attachment_inject[\v!auto][#registered]
137 \else
138 \scrn_attachment_inject[#registered][#settings]
139 \fi
140 \fi
141 \egroup
142 \fi}
143
144\tolerant\protected\def\scrn_attachment_start[#tag]#spacer[#registered]#spacer[#S#settings]
145 {\cdef\currentattachment{#tag}
146 \unless\iflocation
147 \expandafter\scrn_attachment_start_ignore
148 \orelse\ifcstok{\attachmentparameter\c!state}\v!start
149 \expandafter\scrn_attachment_start_indeed
150 \else
151 \expandafter\scrn_attachment_start_ignore
152 \fi[#registered][#settings]}
153
154\protected\def\scrn_attachment_stop
155 {}
156
157\def\scrn_attachment_start_indeed[#registered][#S#settings]
158 {\bgroup
159 \ifempty{#registered}
160 \def\scrn_attachment_stop{\scrn_attachment_inject[\v!auto][\c!buffer=\v!attachment]\egroup}
161 \else
162 \doifelseassignment{#registered}
163 {\def\scrn_attachment_stop{\scrn_attachment_inject[\v!auto][\c!buffer=\v!attachment,#registered]\egroup}}
164 {\def\scrn_attachment_stop{\scrn_attachment_inject[#registered][\c!buffer=\v!attachment,#settings]\egroup}}
165 \fi
166 \grabbufferdatadirect\v!attachment{\e!start\currentattachment}{\e!stop\currentattachment}}
167
168\def\scrn_attachment_start_ignore
169 {\expandafter\ignoreupto\csname\e!stop\currentattachment\endcsname}
170
171\def\scrn_attachment_inject[#registered][#S#settings]
172 {\edef\currentattachmentregistered{#registered}
173 \setupattachment[\currentattachment][#settings]
174 \expandnamespaceparameter\??attachmentmethod\attachmentparameter\c!method\v!normal}
175
176\defcsname\??attachmentmethod\v!normal\endcsname
177 {\edef\currentattachmentsymbol{\attachmentparameter\c!symbol}
178 \edef\currentattachmentwidth {\attachmentparameter\c!width }
179 \edef\currentattachmentheight{\attachmentparameter\c!height}
180 \edef\currentattachmentdepth {\attachmentparameter\c!depth }
181 \ifempty\currentattachmentsymbol
182 \ifx\currentattachmentwidth \v!fit\edef\currentattachmentwidth {.5\emwidth}\fi
183 \ifx\currentattachmentheight\v!fit\edef\currentattachmentheight{.5\emwidth}\fi
184 \ifx\currentattachmentdepth \v!fit\let \currentattachmentdepth \zeropoint\fi
185 \else
186 \clf_presetsymbollist{\attachmentparameter\c!symbol}
187
188 \setbox\b_scrn_attachment_symbol\hbox{\symbol[\lastpredefinedsymbol]}
189 \ifx\currentattachmentwidth \v!fit\edef\currentattachmentwidth {\wd\b_scrn_attachment_symbol}\fi
190 \ifx\currentattachmentheight\v!fit\edef\currentattachmentheight{\ht\b_scrn_attachment_symbol}\fi
191 \ifx\currentattachmentdepth \v!fit\edef\currentattachmentdepth {\dp\b_scrn_attachment_symbol}\fi
192 \fi
193 \clf_insertattachment
194 tag {\currentattachment}
195 registered {\currentattachmentregistered}
196 width {\currentattachmentwidth}
197 height {\currentattachmentheight}
198 depth {\currentattachmentdepth}
199 color {\attachmentparameter\c!color}
200 colormodel \c_attr_colormodel
201 colorvalue \rawcolorattribute{\attachmentparameter\c!color}
202 transparencyvalue \rawtransparencyattribute{\attachmentparameter\c!color}
203 symbol {\currentattachmentsymbol}
204 layer {\attachmentparameter\c!textlayer}
205
206 title {\attachmentparameter\c!title}
207 subtitle {\attachmentparameter\c!subtitle}
208 author {\attachmentparameter\c!author}
209 file {\attachmentparameter\c!file}
210 name {\attachmentparameter\c!name}
211 buffer {\attachmentparameter\c!buffer}
212 mimetype {\attachmentparameter\c!type}
213 \relax
214 \wd\b_scrn_attachment_link\currentattachmentwidth
215 \ht\b_scrn_attachment_link\currentattachmentheight
216 \dp\b_scrn_attachment_link\currentattachmentdepth
217 \expandnamespaceparameter\??attachmentlocation\attachmentparameter\c!location\s!unknown}
218
219\defcsname\??attachmentmethod\v!hidden\endcsname
220 {\clf_insertattachment
221 tag {\currentattachment}
222 registered {\currentattachmentregistered}
223 method {\v!hidden}
224 title {\attachmentparameter\c!title}
225 subtitle {\attachmentparameter\c!subtitle}
226 author {\attachmentparameter\c!author}
227 file {\attachmentparameter\c!file}
228 name {\attachmentparameter\c!name}
229 buffer {\attachmentparameter\c!buffer}
230 mimetype {\attachmentparameter\c!type}
231 \relax}
232
233\protected\def\scrn_attachment_flush_traced
234 {\hpack\bgroup
235 \blackrule
236 [ \c!color=trace:r,
237 \c!width=\wd\b_scrn_attachment_link,
238 \c!height=\ht\b_scrn_attachment_link,
239 \c!depth=\dp\b_scrn_attachment_link]
240 \kern\wd\b_scrn_attachment_link
241 \box\b_scrn_attachment_link
242 \egroup}
243
244\protected\def\scrn_attachment_flush_normal
245 {\box\b_scrn_attachment_link}
246
247\installtextracker
248 {attachments.anchors}
249 {\let\scrn_attachment_flush\scrn_attachment_flush_traced}
250 {\let\scrn_attachment_flush\scrn_attachment_flush_normal}
251
252\let\scrn_attachment_flush\scrn_attachment_flush_normal
253
254\defcsname\??attachmentlocation\v!inmargin \endcsname{\inmargin {\scrn_attachment_flush}}
255\defcsname\??attachmentlocation\v!leftedge \endcsname{\inleftedge {\scrn_attachment_flush}}
256\defcsname\??attachmentlocation\v!rightedge \endcsname{\inrightedge {\scrn_attachment_flush}}
257\defcsname\??attachmentlocation\v!leftmargin \endcsname{\inleftmargin {\scrn_attachment_flush}}
258\defcsname\??attachmentlocation\v!rightmargin\endcsname{\inrightmargin{\scrn_attachment_flush}}
259\defcsname\??attachmentlocation\v!high \endcsname{\high {\scrn_attachment_flush}}
260
261\defcsname\??attachmentlocation\v!none\endcsname
262 {\global\setbox\b_scrn_attachment_collect\hbox\bgroup
263 \ifvoid\b_scrn_attachment_collect\else
264 \box\b_scrn_attachment_collect
265 \hskip{\attachmentparameter\c!distance}\relax
266 \fi
267 \scrn_attachment_flush
268 \egroup}
269
270\defcsname\??attachmentlocation\s!unknown\endcsname
271 {\ifvoid\b_scrn_attachment_collect\else
272 \box\b_scrn_attachment_collect
273 \fi}
274
275\permanent\protected\def\placeattachments
276 {\ifvoid\b_scrn_attachment_collect\else
277 \box\b_scrn_attachment_collect
278 \fi}
279
280\defineattachment[attachment]
281
282
283
284
285
286
287
288\permanent\tolerant\protected\def\useattachment[#tag]#spacer[#title]#spacer[#name]#spacer[#file]
289 {\ifarguments\or
290 \registerattachment[#tag][title=#tag,name=#tag,file=#tag]
291 \or
292 \registerattachment[#tag][title=#title,name=#title,file=#title]
293 \or
294 \registerattachment[#tag][title=#title,name=#title,file=#name]
295 \or
296 \registerattachment[#tag][title=#title,name=#name,file=#file]
297 \fi}
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381\installcorenamespace{comment}
382\installcorenamespace{commentlocation}
383
384\installcommandhandler \??comment {comment} \??comment
385
386\newbox\b_scrn_comment_collect
387\newbox\b_scrn_comment_rendering
388\newbox\b_scrn_comment_link
389\newbox\b_scrn_comment_symbol
390
391\setupcomment
392 [\c!state=\v!start,
393 \c!distance=\emwidth,
394 \c!color=\interactionparameter\c!color,
395 \c!space=\v!no,
396 \c!symbol=,
397
398
399
400 \c!width=\v!fit,
401 \c!height=\v!fit,
402 \c!depth=\v!fit,
403 \c!nx=40,
404 \c!ny=10,
405 \c!buffer=\v!comment,
406 \c!location=\v!high]
407
408\mutable\lettonothing\currentcommentdepth
409\mutable\lettonothing\currentcommentheight
410\mutable\lettonothing\currentcommentsymbol
411\mutable\lettonothing\currentcommentwidth
412
413\appendtoks
414 \frozen\protected\instance\edefcsname \currentcomment\endcsname{\scrn_comment_argument[\currentcomment]}
415 \frozen\protected\instance\edefcsname\e!start\currentcomment\endcsname{\scrn_comment_start [\currentcomment]}
416 \frozen\protected\instance\edefcsname\e!stop \currentcomment\endcsname{\scrn_comment_stop }
417\to \everydefinecomment
418
419\tolerant\protected\def\scrn_comment_argument[#category]#spacer[#title]#spacer[#S#settings]#:#text
420 {\iflocation
421 \cdef\currentcomment{#category}
422 \ifcstok{\commentparameter\c!state}\v!start
423 \ifhastok={#title}
424 \setupcurrentcomment[#title]
425 \else
426 \setupcurrentcomment[\c!title=#title,#settings]
427 \fi
428 \clf_assignbuffer{\v!comment}{#text}\catcodetable\relax
429 \scrn_comment_inject
430 \fi
431 \fi
432 \ignorespaces}
433
434\tolerant\protected\def\scrn_comment_start[#category]#spacer[#title]#spacer[#S#settings]
435 {\cdef\currentcomment{#category}
436 \unless\iflocation
437 \expandafter\scrn_comment_start_ignore
438 \orelse\ifcstok{\commentparameter\c!state}\v!start
439 \expandafter\scrn_comment_start_indeed
440 \else
441 \expandafter\scrn_comment_start_ignore
442 \fi[#title][#settings]}
443
444\def\scrn_comment_start_indeed[#title][#S#settings]
445 {\bgroup
446 \doifelseassignment{#title}
447 {\setupcurrentcomment[#title]}
448 {\setupcurrentcomment[\c!title=#title,#settings]}
449 \protected\def\scrn_comment_stop{\scrn_comment_inject\egroup}
450 \grabbufferdatadirect\v!comment{\e!start\currentcomment}{\e!stop\currentcomment}}
451
452\def\scrn_comment_start_ignore
453 {\expandafter\ignoreupto\csname\e!stop\currentcomment\endcsname}
454
455\protected\def\scrn_comment_stop
456 {}
457
458\installcorenamespace{commentmethods}
459
460\protected\def\scrn_comment_inject
461 {\expandnamespaceparameter\??commentmethods\commentparameter\c!method\v!normal}
462
463
464
465
466\defcsname\??commentmethods\v!normal\endcsname
467 {\edef\currentcommentsymbol{\commentparameter\c!symbol}
468 \edef\currentcommentwidth {\commentparameter\c!width }
469 \edef\currentcommentheight{\commentparameter\c!height}
470 \edef\currentcommentdepth {\commentparameter\c!depth }
471 \ifempty\currentcommentsymbol
472 \ifx\currentcommentwidth \v!fit\edef\currentcommentwidth {.5\emwidth}\fi
473 \ifx\currentcommentheight\v!fit\edef\currentcommentheight{.5\emwidth}\fi
474 \ifx\currentcommentdepth \v!fit\let \currentcommentdepth \zeropoint\fi
475 \else
476 \clf_presetsymbollist{\commentparameter\c!symbol}
477
478 \setbox\b_scrn_comment_symbol\hbox{\symbol[\lastpredefinedsymbol]}
479 \ifx\currentcommentwidth \v!fit\edef\currentcommentwidth {\wd\b_scrn_comment_symbol}\fi
480 \ifx\currentcommentheight\v!fit\edef\currentcommentheight{\ht\b_scrn_comment_symbol}\fi
481 \ifx\currentcommentdepth \v!fit\edef\currentcommentdepth {\dp\b_scrn_comment_symbol}\fi
482 \fi
483 \clf_insertcomment
484 tag {\currentcomment}
485 title {\commentparameter\c!title}
486 subtitle {\commentparameter\c!subtitle}
487 author {\commentparameter\c!author}
488 width {\currentcommentwidth}
489 height {\currentcommentheight}
490 depth {\currentcommentdepth}
491 nx {\commentparameter\c!nx}
492 ny {\commentparameter\c!ny}
493 colormodel \c_attr_colormodel
494 colorvalue \rawcolorattribute{\commentparameter\c!color}
495 transparencyvalue \rawtransparencyattribute{\commentparameter\c!color}
496 option {\commentparameter\c!option}
497 symbol {\commentparameter\c!symbol}
498 buffer {\commentparameter\c!buffer}
499 layer {\commentparameter\c!textlayer}
500 space {\commentparameter\c!space}
501 \relax
502 \wd\b_scrn_comment_link\currentcommentwidth
503 \ht\b_scrn_comment_link\currentcommentheight
504 \dp\b_scrn_comment_link\currentcommentdepth
505 \expandnamespaceparameter\??commentlocation\commentparameter\c!location\s!unknown}
506
507\aliased\letcsname\??commentmethods\v!hidden\endcsname\donothing
508
509\protected\def\scrn_comment_flush_traced
510 {\hpack\bgroup
511 \blackrule
512 [ \c!color=trace:y,
513 \c!width=\wd\b_scrn_comment_link,
514 \c!height=\ht\b_scrn_comment_link,
515 \c!depth=\dp\b_scrn_comment_link]
516 \kern\wd\b_scrn_comment_link
517 \box\b_scrn_comment_link
518 \egroup}
519
520\protected\def\scrn_comment_flush_normal
521 {\box\b_scrn_comment_link}
522
523\installtextracker
524 {comments.anchors}
525 {\let\scrn_comment_flush\scrn_comment_flush_traced}
526 {\let\scrn_comment_flush\scrn_comment_flush_normal}
527
528\let\scrn_comment_flush\scrn_comment_flush_normal
529
530
531
532\defcsname\??commentlocation\v!inmargin \endcsname{\inmargin {\scrn_comment_flush}}
533\defcsname\??commentlocation\v!leftedge \endcsname{\inleftedge {\scrn_comment_flush}}
534\defcsname\??commentlocation\v!rightedge \endcsname{\inrightedge {\scrn_comment_flush}}
535\defcsname\??commentlocation\v!leftmargin \endcsname{\inleftmargin {\scrn_comment_flush}}
536\defcsname\??commentlocation\v!rightmargin\endcsname{\inrightmargin{\scrn_comment_flush}}
537\defcsname\??commentlocation\v!high \endcsname{\high {\scrn_comment_flush}}
538
539\defcsname\??commentlocation\v!none\endcsname
540 {\global\setbox\b_scrn_comment_collect\hbox\bgroup
541 \ifvoid\b_scrn_comment_collect\else
542 \box\b_scrn_comment_collect
543 \hskip{\commentparameter\c!distance}\relax
544 \fi
545 \scrn_comment_flush
546 \egroup}
547
548\defcsname\??commentlocation\s!unknown\endcsname
549 {\ifvoid\b_scrn_comment_collect\else
550 \box\b_scrn_comment_collect
551 \fi}
552
553\permanent\protected\def\placecomments
554 {\ifvoid\b_scrn_comment_collect\else
555 \box\b_scrn_comment_collect
556 \fi}
557
558\definecomment[comment]
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591\mutable\lettonothing\currentrendering
592\mutable\lettonothing\currentrenderingwindow
593
594\permanent\tolerant\protected\def\userendering[#tag]#spacer[#mime]#spacer[#file]#spacer[#option]
595 {\clf_registerrendering
596 label {#tag}
597 mime {#mime}
598 filename {#file}
599 option {#option}
600 \relax}
601
602\permanent\tolerant\protected\let\useexternalrendering\userendering
603
604\permanent\def\renderingoption#tag{\clf_renderingvar{#tag}{option}}
605
606\newdimension\d_scrn_rendering_width \d_scrn_rendering_width 8cm
607\newdimension\d_scrn_rendering_height \d_scrn_rendering_height 6cm
608
609\let\m_scrn_rendering_page\!!zerocount
610
611
612
613
614
615
616
617\installcorenamespace{renderingwindow}
618
619\installframedcommandhandler \??renderingwindow {renderingwindow} \??renderingwindow
620
621\appendtoks
622 \resetrenderingwindowparameter\c!openpageaction
623 \resetrenderingwindowparameter\c!closepageaction
624 \setrenderingwindowparameter \c!width {\d_scrn_rendering_width }
625 \setrenderingwindowparameter \c!height {\d_scrn_rendering_height}
626 \letrenderingwindowparameter \c!align \v!flushleft
627\to \everypresetrenderingwindow
628
629\permanent\tolerant\protected\def\placerenderingwindow[#window]#spacer[#rendering]
630 {\bgroup
631 \edef\currentrendering{\ifparameter#rendering\or#rendering\else#window\fi}
632
633 \edef\currentrenderingwindow{\namedrenderingwindowparameter{#window}\c!width}
634 \ifempty\currentrenderingwindow
635 \let\currentrenderingwindow\s!default
636 \definerenderingwindow[\currentrenderingwindow]
637 \else
638 \edef\currentrenderingwindow{#window}
639 \fi
640 \ifx\currentrenderingwindow\s!default
641 \d_scrn_rendering_height\vsize
642 \d_scrn_rendering_width \hsize
643 \let\m_scrn_rendering_page\realpageno
644 \else
645 \d_scrn_rendering_height{\renderingwindowparameter\c!height}
646 \d_scrn_rendering_width {\renderingwindowparameter\c!width}
647 \let\m_scrn_rendering_page\realpageno
648 \fi
649 \letrenderingwindowparameter\c!offset\v!overlay
650 \inheritedrenderingwindowframed
651 {\vfilll
652 \dontleavehmode
653 \clf_insertrenderingwindow
654 label {\currentrendering}
655 width \d_scrn_rendering_width
656 height \d_scrn_rendering_height
657 option {\renderingoption\currentrendering}
658 page \m_scrn_rendering_page
659 openpage {\renderingwindowparameter\c!openpageaction}
660 closepage {\renderingwindowparameter\c!closepageaction}
661 \relax
662 \hfill}
663 \egroup}
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725\protect \endinput
726 |