1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Buffer Macros Parallel}
15
16\registerctxluafile{buffpar}{}
17
18
19
20
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
50
51
52
53
54
55\unprotect
56
57\installcorenamespace{parallel}
58\installcorenamespace{parallelhandler}
59
60\installcommandhandler \??parallel {parallel} \??parallel
61
62\setupparallel
63 [\c!setups=parallel:place:default]
64
65\let\buff_parallel_define_saved\defineparallel
66\let\buff_parallel_setup_saved \setupparallel
67
68\unexpanded\overloaded\def\defineparallel{\dodoubleargument\buff_parallel_define}
69\unexpanded\overloaded\def\setupparallel {\dotripleargument\buff_parallel_setup}
70
71\def\buff_parallel_define[#name][#instances]
72 {\buff_parallel_define_saved[#name][\c!list={#instances}]
73 \clf_defineparallel{#name}{#instances}
74 \expandafter\newtoks\csname\??parallelhandler#name\endcsname
75 \processcommacommand[#instances]{\buff_parallel_define_instance{#name}}
76 \setuevalue{\e!start#name}{\buff_parallel_start{#name}}
77 \setuevalue{\e!stop #name}{\buff_parallel_stop}}
78
79\let\buff_process_parallel_instance\relax
80
81\def\buff_process_parallel_instances
82 {\the\csname\??parallelhandler\currentparallel\endcsname}
83
84\def\buff_parallel_define_instance#name#instance
85 {\normalexpanded{\buff_parallel_define_saved[#instance][#name]}
86 \definebuffer[#instance]
87
88 \expandafter\let\expandafter\t_buff_parallel\csname\??parallelhandler#name\endcsname
89 \appendtoks
90 \edef\currentparallelinstance{#instance}
91 \buff_process_parallel_instance\relax
92 \to \t_buff_parallel
93 \setuevalue{\e!stop#instance}{\buff_parallel_save{#instance}}}
94
95\def\buff_parallel_setup[#name][#instances][#setups]
96 {\processcommalist[#instances]{\buff_parallel_setup_instance{#name}{#setups}}}
97
98\def\buff_parallel_setup_instance#name#setups#instance
99 {\buff_parallel_setup_saved[#name:#instance][#setups]}
100
101\unexpanded\def\buff_parallel_start#name
102 {\pushmacro\currentparallel
103 \edef\currentparallel{#name}
104 \clf_nextparallel{\currentparallel}}
105
106\unexpanded\def\buff_parallel_stop
107 {\popmacro\currentparallel}
108
109\unexpanded\def\buff_parallel_save#instance
110 {\clf_saveparallel
111 {\currentparallel}
112 {#instance}
113 {\thedefinedbuffer{#instance}}
114 \relax}
115
116\unexpanded\def\placeparallel
117 {\dotripleempty\buff_parallel_place}
118
119\def\buff_parallel_place[#name][#instance][#settings]
120 {\begingroup
121 \edef\currentparallel{#name}
122 \setupcurrentparallel[#settings]
123 \clf_placeparallel
124 {\currentparallel}
125 {#instance}
126 {
127
128 start {\parallelparameter\c!start}
129 n {\parallelparameter\c!n}
130 criterium {\parallelparameter\c!criterium}
131 }
132 \relax
133 \endgroup}
134
135\def\doflushparallel#instance#status#line#label#content
136 {\begingroup
137 \def\currentparallelinstance{#instance}
138 \def\currentparallelnumber {#status}
139 \def\currentparallelline {#line}
140 \def\currentparallellabel {#label}
141 \def\currentparallelcontent {#content}
142 \ifcase#status\relax
143 \expandafter\buff_parallel_flush_nop
144 \or
145 \expandafter\buff_parallel_flush_yes
146 \fi
147 \endgroup}
148
149\def\buff_parallel_flush_nop
150 {}
151
152\def\buff_parallel_flush_yes
153
154 {\directsetup{\namedparallelparameter{\currentparallelinstance}\c!setups}}
155
156\unexpanded\def\doifelseparallel#name#instance
157 {\clf_doifelseparallel{#name}{#instance}}
158
159\let\doifparallelelse\doifelseparallel
160
161\unexpanded\def\resetparallel
162 {\dodoubleempty\buff_parallel_reset}
163
164\def\buff_parallel_reset[#name][#instance]
165 {\clf_resetparallel{#name}{#instance}}
166
167\startsetups parallel:place:default
168 \hangafter\plusone
169 \hangindent4\emwidth
170 \dontleavehmode
171 \hbox to 3\emwidth \bgroup
172 \hss
173 \bf
174 \doifsomething \currentparallellabel {
175 \textreference[\currentparallellabel]{\currentparallelline}
176 }
177 \currentparallelline
178 \quad
179 \egroup
180 \currentparallelcontent
181 \par
182\stopsetups
183
184\protect \endinput
185 |