1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16\writestatus{loading}{ConTeXt Typesetting Macros Stacking}
17
18\registerctxluafile{typostc}{autosuffix}
19
20\unprotect
21
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\installcorenamespace {stacking}
50
51\installcommandhandler \??stacking {stacking} \??stacking
52
53\definesystemattribute[stacking][global]
54
55\appendtoks
56 \expandafter\setnewconstant\csname\??stacking:\currentstacking\endcsname
57 \clf_newstacking{\currentstacking}{\stackingparameter\c!number}
58 \relax
59 \ifcstok{\stackingparameter\c!define}\v!yes
60 \frozen\instance\protected\edefcsname \currentstacking\endcsname{\typo_stacking{\currentstacking}}
61 \frozen\instance\protected\edefcsname\e!start\currentstacking\endcsname{\typo_stacking_start{\currentstacking}}
62 \frozen\instance\protected\edefcsname\e!stop \currentstacking\endcsname{\typo_stacking_stop}
63 \fi
64\to \everydefinestacking
65
66\def\typo_stacking_set
67 {\c_attr_stacking
68 \ifcsname\??stacking:\currentstacking\endcsname
69 \lastnamedcs
70 \orelse\ifchknum\currentstacking\or
71
72 \currentstacking
73 \else
74 \attributeunsetvalue
75 \fi
76 \relax}
77
78\protected\def\resetstacking
79 {\c_attr_stacking\attributeunsetvalue}
80
81\protected\def\typo_stacking#1#2
82 {\begingroup
83 \cdef\currentstacking{#1}
84 \typo_stacking_set
85 #2
86 \endgroup}
87
88\protected\def\typo_start_stacking#1
89 {\begingroup
90 \cdef\currentstacking{#1}
91 \typo_stacking_set}
92
93\protected\def\typo_stop_stacking
94 {\endgroup}
95
96\permanent\protected\def\stacking [#1]{\typo_stacking{#1}}
97\permanent\protected\def\startstacking[#1]{\typo_start_stacking{#1}}
98\permanent\protected\def\stopstacking {\typo_stop_stacking}
99
100\appendtoks
101 \clf_setstacking{\namedstackingparameter\empty\c!criterium}
102\to \everysetupstacking
103
104
105
106\def\typo_stacking_step#1
107 {\setupstacking[\c!criterium={#1}]
108 \getbuffer[stackingsteps]
109 \page}
110
111\permanent\tolerant\protected\def\startstackingsteps[#1]
112 {\page
113 \begingroup
114 \edef\stackingsteplist{#1}
115 \begingroup
116 \buff_grab_direct[stackingsteps][stackingsteps][startstackingsteps][stopstackingsteps]}
117
118\permanent\protected\def\stopstackingsteps
119 {
120 \processcommacommand[\stackingsteplist]\typo_stacking_step
121 \endgroup}
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144\lettonothing\currenthidestacking
145\lettonothing\currentvidestacking
146
147\def\hidestacking[#1]
148 {\lettonothing\currentvidestacking
149 \cdef\currenthidestacking{#1}}
150
151\def\videstacking[#1]
152 {\lettonothing\currenthidestacking
153 \cdef\currentvidestacking{#1}}
154
155
156
157\def\typo_stacking_hide#1{\ifnum#1=\scratchcounter \c_attr_stacking\zerocount\fi}
158\def\typo_stacking_vide#1{\ifnum#1=\scratchcounter\else\c_attr_stacking\zerocount\fi}
159
160\def\typo_stacking_unstack_hide
161 {\clf_enablestacking
162 \dowithrange\currenthidestacking\typo_stacking_hide}
163
164\def\typo_stacking_unstack_vide
165 {\clf_enablestacking
166 \dowithrange\currentvidestacking\typo_stacking_vide}
167
168\protected\def\typo_stacking_unstack
169 {\ifcase\scratchcounter
170 \c_attr_stacking\attributeunsetvalue
171 \orunless\ifempty\currenthidestacking
172 \typo_stacking_unstack_hide
173 \orunless\ifempty\currentvidestacking
174 \typo_stacking_unstack_vide
175
176
177 \fi}
178
179\permanent\tolerant\protected\def\unstacking[#1]
180 {\groupedcommand
181 {\scratchcounter\ifparameter#1\or#1\else\zerocount\fi\typo_stacking_unstack}
182 \donothing}
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208\protect \endinput
209 |