1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Attribute Macros Viewerlayers}
15
16
17
18
19
20
21
22
23\unprotect
24
25\registerctxluafile{attrlay}{autosuffix}
26
27
28
29\installcorenamespace{viewerlayer}
30
31\installcommandhandler \??viewerlayer {viewerlayer} \??viewerlayer
32
33\setupviewerlayer
34 [\c!state=\v!start,
35 \c!title=,
36 \c!export=\v!yes,
37 \c!printable=\v!yes,
38 \c!scope=\v!local,
39 \c!method=\v!none]
40
41\permanent\def\attr_layoutcomponent_whatever#1
42 {#1
43 tag {\currentviewerlayer}
44 title {\viewerlayerparameter\c!title}
45 visible {\viewerlayerparameter\c!state}
46 editable {\v!yes}
47 export {\viewerlayerparameter\c!export}
48 printable {\viewerlayerparameter\c!printable}
49 scope {\viewerlayerparameter\c!scope}
50 \relax}
51
52\appendtoks
53 \attr_layoutcomponent_whatever\clf_defineviewerlayer
54 \ifcstok{\viewerlayerparameter\c!method}\v!command
55 \frozen\protected\instance\xdefcsname\e!start\currentviewerlayer\endcsname{\startviewerlayer[\currentviewerlayer]}
56 \else
57 \frozen\protected\instance\xdefcsname\e!stop \currentviewerlayer\endcsname{\stopviewerlayer}
58 \fi
59\to \everydefineviewerlayer
60
61\appendtoks
62 \attr_layoutcomponent_whatever\clf_setupviewerlayer
63\to \everysetupviewerlayer
64
65
66
67
68\permanent\protected\def\viewerlayer[#1]
69 {\groupedcommand{\startviewerlayer[#1]}{\stopviewerlayer}}
70
71
72
73\newtoks\currentviewerlayertoks
74
75\def\currentviewerlayer{\the\currentviewerlayertoks}
76
77\appendtoks
78 \lettonothing\currentviewerlayer
79\to \everybeforepagebody
80
81
82
83\installcorenamespace{layoutcomponentattribute}
84
85\mutable\lettonothing\layoutcomponentboxattribute
86
87\permanent\def\attr_layoutcomponent_initialize#1
88 {\edef\layoutcomponentboxattribute{\clf_definedlayoutcomponent{#1}}
89 \edef\layoutcomponentboxattribute{attr \viewerlayerattribute \layoutcomponentboxattribute\relax}
90 \gletcsname\??layoutcomponentattribute#1\endcsname\layoutcomponentboxattribute}
91
92\permanent\def\attr_layoutcomponent_set#1
93 {\expandafter\let\expandafter\layoutcomponentboxattribute\csname\??layoutcomponentattribute#1\endcsname
94 \ifrelax\layoutcomponentboxattribute
95 \attr_layoutcomponent_initialize{#1}
96 \fi}
97
98\permanent\def\attr_layoutcomponent_reset
99 {\lettonothing\layoutcomponentboxattribute}
100
101\permanent\let \setlayoutcomponentattribute \gobbleoneargument
102\permanent\let \resetlayoutcomponentattribute\relax
103 \lettonothing\layoutcomponentboxattribute
104
105\permanent\protected\def\showlayoutcomponents
106 {\enforced\let\setlayoutcomponentattribute \attr_layoutcomponent_set
107 \enforced\let\resetlayoutcomponentattribute\attr_layoutcomponent_reset}
108
109\protected\def\attr_layoutcomponent_cleanup
110 {\clf_cleanuplayers}
111
112\appendtoks
113 \attr_layoutcomponent_cleanup
114\to \everyshipout
115
116\protect \endinput
117 |