1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Attribute Macros Initialization}
15
16
17
18
19
20\unprotect
21
22\registerctxluafile{attrini}{}
23
24\installcorenamespace{attributecount}
25\installcorenamespace{attributeid}
26\installcorenamespace{attributestack}
27\installcorenamespace{attributepickup}
28
29\unexpanded\def\pushattribute#1
30 {\global\advance\csname\??attributestack\string#1\endcsname\plusone
31 \expandafter\xdef\csname\??attributestack\string#1:\number\csname\??attributestack\string#1\endcsname\endcsname{\number\attribute#1}}
32
33\unexpanded\def\popattribute#1
34 {\attribute#1\csname\??attributestack\string#1:\number\csname\??attributestack\string#1\endcsname\endcsname\relax
35 \global\advance\csname\??attributestack\string#1\endcsname\minusone}
36
37\unexpanded\def\installattributestack#1
38 {\ifcsname\??attributestack\string#1\endcsname \else
39 \expandafter\newcount\csname\??attributestack\string#1\endcsname
40 \fi}
41
42\newtoks \t_attr_list_global
43\newtoks \t_attr_list_local
44\newtoks \t_attr_list_pickup
45\newtoks \t_attr_list_nomath
46
47\ifdefined \s!global \else \def\s!global {global} \fi
48\ifdefined \s!public \else \def\s!public {public} \fi
49\ifdefined \s!private \else \def\s!private {private} \fi
50\ifdefined \s!attribute \else \def\s!attribute{attribute} \fi
51\ifdefined \s!pickup \else \def\s!pickup {pickup} \fi
52\ifdefined \s!forget \else \def\s!forget {forget} \fi
53
54\unexpanded\def\defineattribute {\dodoubleempty\attr_basics_define}
55\unexpanded\def\definesystemattribute{\dodoubleempty\attr_basics_define_system}
56
57\def\attr_basics_define {\attr_basics_define_indeed\s!public}
58\def\attr_basics_define_system{\attr_basics_define_indeed\s!private}
59
60
61
62
63
64
65\def\attr_prefix{cattr}
66
67\def\attr_basics_define_indeed#1[#2][#3]
68 {\ifcsname\attr_prefix#2\endcsname\else
69 \scratchcounter\clf_defineattribute{#2}{#1}\relax
70
71 \global\expandafter\attributedef\csname\attr_prefix#2\endcsname\scratchcounter
72 \global\expandafter\newconstant \csname\??attributeid#2\endcsname
73 \global\csname\??attributeid#2\endcsname\scratchcounter
74
75 \doifelseinset\s!global{#3}
76 {\xtoksapp\t_attr_list_global{\csname\attr_prefix#2\endcsname\attributeunsetvalue}}
77 {\xtoksapp\t_attr_list_local {\csname\attr_prefix#2\endcsname\attributeunsetvalue}}
78 \doifinset\s!nomath{#3}
79 {\xtoksapp\t_attr_list_nomath{\csname\attr_prefix#2\endcsname\attributeunsetvalue}}
80 \doifinset\s!public{#3}
81 {\expandafter\glet\csname#2\s!attribute\expandafter\endcsname\csname\??attributeid#2\endcsname}
82 \doifinset\s!pickup{#3}
83 {\global\expandafter\newconstant\csname\??attributepickup#2\endcsname
84 \global\csname\??attributepickup#2\endcsname\attributeunsetvalue
85 \xtoksapp\t_attr_list_pickup{\csname\attr_prefix#2\endcsname\csname\??attributepickup#2\endcsname}
86 \ifcsname#2\s!attribute\endcsname
87 \expandafter\xdef\csname\s!pickup#2\s!attribute\endcsname
88 {\csname\??attributepickup#2\endcsname\csname\attr_prefix#2\endcsname}
89 \expandafter\xdef\csname\s!forget#2\s!attribute\endcsname
90 {\csname\??attributepickup#2\endcsname\attributeunsetvalue}
91 \fi}
92 \fi}
93
94\unexpanded\def\pickupattributes
95 {\the\t_attr_list_pickup\relax}
96
97
98
99
100
101
102
103
104
105
106
107\unexpanded\def\newattribute#1
108 {\attr_basics_define_indeed\s!public[\csstring#1][]
109 \expandafter\glet\expandafter#1\csname\??attributeid\csstring#1\endcsname}
110
111
112
113\def\dosetattribute#1#2{\csname\attr_prefix#1\endcsname#2\relax}
114\def\doresetattribute#1{\csname\attr_prefix#1\endcsname\attributeunsetvalue}
115\def\dogetattribute #1{\number\csname\attr_prefix#1\endcsname}
116\def\dogetattributeid#1{\number\csname\??attributeid#1\endcsname}
117
118\let\dompattribute\gobbletwoarguments
119
120\ifcase\contextlmtxmode
121 \unexpanded\def\resetglobalattributes{\the\t_attr_list_global\attribute\zerocount\zerocount}
122 \unexpanded\def\resetlocalattributes {\the\t_attr_list_local \attribute\zerocount\zerocount}
123\else
124 \unexpanded\def\resetglobalattributes{\the\t_attr_list_global\glyphdatafield\zerocount\glyphscriptfield\zerocount}
125 \unexpanded\def\resetlocalattributes {\the\t_attr_list_local \glyphdatafield\zerocount\glyphscriptfield\zerocount}
126\fi
127
128\let\resetallattributes\resetlocalattributes
129
130
131
132\unexpanded\def\savecurrentattributes #1{\clf_savecurrentattributes {#1}}
133\unexpanded\def\restorecurrentattributes#1{\clf_restorecurrentattributes{#1}}
134
135
136
137
138
139
140\definesystemattribute [color] [public]
141\definesystemattribute [colormodel] [public,global]
142
143
144\definesystemattribute [transparency] [public]
145\definesystemattribute [reference] [public]
146\definesystemattribute [destination] [public]
147\definesystemattribute [case] [public]
148\definesystemattribute [visual] [public,global]
149\definesystemattribute [viewerlayer] [public]
150\definesystemattribute [background] [public]
151\definesystemattribute [alignbackground] [public]
152\definesystemattribute [colorintent] [public]
153\definesystemattribute [negative] [public]
154\definesystemattribute [effect] [public]
155\definesystemattribute [layoutcomponent] [public]
156\definesystemattribute [internal] [public]
157\definesystemattribute [ruled] [public]
158\definesystemattribute [shifted] [public]
159\definesystemattribute [checkedbreak] [public]
160\definesystemattribute [vboxtohboxseparator] [public]
161
162\unexpanded\def\showattributes{\clf_showattributes}
163
164
165
166
167
168
169
170\protect \endinput
171 |