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