1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16\registerctxluafile{msteps}{}
17
18\unprotect
19
20\defineMPinstance
21 [steps]
22 [\s!format=metafun,
23 \s!extensions=\v!yes,
24 \s!initializations=\v!yes]
25
26
27\startMPdefinitions{steps}
28 loadmodule "step" ;
29\stopMPdefinitions
30
31\installcorenamespace {stepcharts}
32\installcorenamespace {stepcells}
33\installcorenamespace {steptexts}
34\installcorenamespace {steplines}
35
36\installstylisticautosetuphandler \??stepcharts {STEPchart}
37\installstylisticautosetuphandler \??stepcells {STEPcell}
38\installstylisticautosetuphandler \??steptexts {STEPtext}
39\installstylisticautosetuphandler \??steplines {STEPline}
40
41\let\setupSTEPcharts\setupSTEPchart
42\let\setupSTEPtables\setupSTEPchart
43\let\setupSTEPcells \setupSTEPcell
44\let\setupSTEPtexts \setupSTEPtext
45\let\setupSTEPlines \setupSTEPline
46
47\let\setSTEPchartsparameter\setSTEPchartparameter
48\let\setSTEPcellsparameter \setSTEPcellparameter
49\let\setSTEPtextsparameter \setSTEPtextparameter
50\let\setSTEPlinesparameter \setSTEPlineparameter
51
52
53
54
55\setupSTEPcharts
56 [
57
58
59 \c!before=\blank,
60 \c!after=\blank]
61
62\setupSTEPcells
63 [\c!alternative=24,
64 \c!style=,
65 \c!color=,
66 \c!dx=\bodyfontsize,
67 \c!dy=\bodyfontsize,
68
69 \c!backgroundcolor=STEPbackgroundcolor,
70 \c!rulethickness=.1\bodyfontsize,
71 \c!framecolor=STEPframecolor,
72 \c!offset=.25\bodyfontsize]
73
74\setupSTEPtexts
75 [\c!alternative=24,
76 \c!style=\v!smallbodyfont,
77 \c!color=,
78
79 \c!backgroundcolor=STEPbackgroundcolor,
80 \c!rulethickness=.1\bodyfontsize,
81 \c!framecolor=STEPframecolor,
82 \c!distance=.5\bodyfontsize,
83 \c!offset=.25\bodyfontsize]
84
85\setupSTEPlines
86 [\c!alternative=1,
87 \c!rulethickness=.15\bodyfontsize,
88 \c!height=\STEPlineparameter\c!width,
89 \c!width=3\bodyfontsize,
90 \c!distance=.5\bodyfontsize,
91 \c!offset=.25\bodyfontsize,
92 \c!color=STEPlinecolor]
93
94\definecolor [STEPlinecolor] [s=.5]
95\definecolor [STEPframecolor] [s=.7]
96\definecolor [STEPbackgroundcolor] [s=.9]
97
98\newcount\c_module_steps_tag
99\newmacro\m_module_steps_category
100
101\unexpanded\def\setSTEPbox#tag#str
102 {\setbox\scratchbox\hbox\bgroup
103 \begstrut
104 \ignorespaces
105 #str
106 \removeunwantedspaces
107 \endstrut
108 \egroup
109 \ifzeropt\wd\scratchbox
110 \let#1\empty
111 \else
112 \global\advance\c_module_steps_tag\plusone
113 \edef#tag{\the\c_module_steps_tag}
114 \putboxincache{\??stepcharts\m_module_steps_category}{#tag}\scratchbox
115 \fi}
116
117\newtoks\everySTEPchart
118
119
120
121
122\def\module_steps_syncronize
123 {\let\currentSTEPtext\p_category
124 \let\currentSTEPcell\p_category
125 \let\currentSTEPline\p_category
126 \checkSTEPcellparent
127 \checkSTEPtextparent
128 \checkSTEPlineparent}
129
130\unexpanded\def\startSTEPchart
131 {\begingroup
132 \dodoubleempty\module_steps_start_chart}
133
134\def\module_steps_start_chart[#name][#settings]
135 {\iffirstargument
136 \doifelseassignment{#name}
137 {\let\currentSTEPchart\empty
138 \let\m_module_steps_category\empty
139 \setupcurrentSTEPchart[#name]
140 \def\module_steps_flush_chart{\module_steps_chart[][#name]}}
141 {\edef\currentSTEPchart{#name}
142 \setupcurrentSTEPchart[#settings]
143 \let\m_module_steps_category\currentSTEPchart
144 \resetboxesincache{\??stepcharts\m_module_steps_category}
145 \doifelse{\STEPchartparameter\c!buffer}\v!no
146 {\def\module_steps_flush_chart{\STEPchart[#name]}}
147 {\let\module_steps_flush_chart\relax}}
148 \else
149 \let\currentSTEPchart\empty
150 \def\module_steps_flush_chart{\module_steps_chart[][]}
151 \fi
152 \edef\p_category{\STEPchartparameter\c!category}
153 \let\currentSTEPtext\p_category
154 \let\currentSTEPcell\p_category
155 \let\currentSTEPline\p_category
156 \checkSTEPcellparent
157 \checkSTEPtextparent
158 \checkSTEPlineparent
159 \the\everySTEPchart
160 \startnointerference
161 \clf_step_start_chart{\currentSTEPchart}{\STEPchartparameter\c!alternative}}
162
163\unexpanded\def\stopSTEPchart
164 {\clf_step_stop_chart
165 \stopnointerference
166 \module_steps_flush_chart
167 \ifx\m_module_steps_category\empty
168 \resetboxesincache{\??stepcharts}
169 \fi
170 \endgroup}
171
172\unexpanded\def\startSTEPtable
173 {\begingroup
174 \setupSTEPchart[\c!alternative=\v!vertical]
175 \dodoubleempty\module_steps_start_chart}
176
177\let\stopSTEPtable\stopSTEPchart
178
179\unexpanded\def\startSTEPaligntable
180 {\begingroup
181 \setupSTEPchart[\c!alternative={\v!vertical,\v!three}]
182 \let\module_steps_cells\module_steps_cells_three
183 \dodoubleempty\module_steps_start_chart}
184
185\let\stopSTEPaligntable\stopSTEPchart
186
187\let\module_steps_flush_chart\relax
188
189
190
191\unexpanded\def\STEPchart
192 {\dodoubleempty\module_steps_chart}
193
194\unexpanded\def\module_steps_chart[#name][#settings]
195 {\begingroup
196 \edef\m_module_steps_category{#name}
197 \setupSTEPchart[#settings]
198 \ifinsidefloat
199 \makeSTEPchart[#name]
200 \else
201 \STEPchartparameter\c!before
202 \startbaselinecorrection
203 \setlocalhsize
204 \dontleavehmode\vpack{\makeSTEPchart[#name]}
205 \stopbaselinecorrection
206 \STEPchartparameter\c!after
207 \fi
208 \endgroup}
209
210\unexpanded\def\makeSTEPchart[#name]
211 {\clf_step_make_chart
212 chart {
213 category {\??stepcharts\m_module_steps_category}
214 name {#name}
215 alternative {\STEPchartparameter\c!alternative}
216 }
217 cell {
218 alternative {\STEPcellparameter\c!alternative}
219 offset \dimexpr\STEPcellparameter\c!offset\relax
220 rulethickness \dimexpr\STEPcellparameter\c!rulethickness\relax
221 framecolor {\STEPcellparameter\c!framecolor}
222 backgroundcolor {\STEPcellparameter\c!backgroundcolor}
223 dx \dimexpr\STEPcellparameter\c!dx\relax
224 dy \dimexpr\STEPcellparameter\c!dy\relax
225 }
226 text {
227 alternative {\STEPtextparameter\c!alternative}
228 offset \dimexpr\STEPtextparameter\c!offset\relax
229 distance \dimexpr\STEPtextparameter\c!distance\relax
230 rulethickness \dimexpr\STEPtextparameter\c!rulethickness\relax
231 framecolor {\STEPtextparameter\c!framecolor}
232 backgroundcolor {\STEPtextparameter\c!backgroundcolor}
233 }
234 line {
235 alternative {\STEPlineparameter\c!alternative}
236 rulethickness \dimexpr\STEPlineparameter\c!rulethickness\relax
237 height \dimexpr\STEPlineparameter\c!height\relax
238 distance \dimexpr\STEPlineparameter\c!distance\relax
239 offset \dimexpr\STEPlineparameter\c!offset\relax
240 color {\STEPlineparameter\c!color}
241 }
242 \relax}
243
244\unexpanded\def\startSTEPcell{\clf_step_start_cell}
245\unexpanded\def\stopSTEPcell {\clf_step_stop_cell}
246
247\unexpanded\def\module_steps_cells {\dosingleempty\module_steps_cells_indeed}
248\unexpanded\def\module_steps_cells_three{\dosingleempty\module_steps_cells_three_indeed}
249\unexpanded\def\module_steps_texts {\dosingleempty\module_steps_texts_indeed}
250\unexpanded\def\module_steps_cell {\dosingleempty\module_steps_cell_indeed}
251\unexpanded\def\module_steps_text {\dosingleempty\module_steps_text_indeed}
252\unexpanded\def\module_steps_toptext {\dosingleempty\module_steps_toptext_indeed}
253\unexpanded\def\module_steps_bottext {\dosingleempty\module_steps_bottext_indeed}
254\unexpanded\def\module_steps_topcell {\dosingleempty\module_steps_topcell_indeed}
255\unexpanded\def\module_steps_botcell {\dosingleempty\module_steps_botcell_indeed}
256
257\def\module_steps_check_cell#category
258 {\edef\p_category{#category}
259 \ifx\p_category\empty \else
260 \let\currentSTEPcell\p_category
261 \let\currentSTEPline\p_category
262 \checkSTEPcellparent
263 \checkSTEPlineparent
264 \fi}
265
266\def\module_steps_check_text#category
267 {\edef\p_category{#category}
268 \ifx\p_category\empty \else
269 \let\currentSTEPtext\p_category
270 \let\currentSTEPline\p_category
271 \checkSTEPtextparent
272 \checkSTEPlineparent
273 \fi}
274
275\def\module_steps_pass_data#1#2
276 {{
277 text {
278 #2
279 }
280 shape {
281 rulethickness \dimexpr#1\c!rulethickness\relax
282 alternative {#1\c!alternative}
283 framecolor {#1\c!framecolor}
284 backgroundcolor {#1\c!backgroundcolor}
285 }
286 line {
287 rulethickness \dimexpr\STEPlineparameter\c!rulethickness\relax
288 alternative {\STEPlineparameter\c!alternative}
289 color {\STEPlineparameter\c!color}
290 offset \dimexpr\STEPlineparameter\c!offset\relax
291 }
292 }}
293
294\def\module_steps_cells_indeed[#category]#top#bot
295 {\begingroup
296 \iffirstargument
297 \module_steps_check_cell{#category}
298 \fi
299 \useSTEPcellstyleandcolor\c!style\c!color
300 \setSTEPbox\module_steps_tag_a{#top}
301 \setSTEPbox\module_steps_tag_b{#bot}
302 \clf_step_cells \module_steps_pass_data \STEPcellparameter {
303 top {\module_steps_tag_a}
304 bot {\module_steps_tag_b}
305 }
306 \endgroup}
307
308\def\module_steps_cells_three_indeed[#category]#one#two#three
309 {\begingroup
310 \iffirstargument
311 \module_steps_check_cell{#category}
312 \fi
313 \useSTEPcellstyleandcolor\c!style\c!color
314 \setSTEPbox\module_steps_tag_a{#one}
315 \setSTEPbox\module_steps_tag_b{#two}
316 \setSTEPbox\module_steps_tag_c{#three}
317 \clf_step_cells_three \module_steps_pass_data \STEPcellparameter {
318 left {\module_steps_tag_a}
319 middle {\module_steps_tag_b}
320 right {\module_steps_tag_c}
321 }
322 \endgroup}
323
324\def\module_steps_texts_indeed[#category]#top#bot
325 {\begingroup
326 \iffirstargument
327 \module_steps_check_text{#category}
328 \fi
329 \useSTEPtextstyleandcolor\c!style\c!color
330 \setSTEPbox\module_steps_tag_a{#top}
331 \setSTEPbox\module_steps_tag_b{#bot}
332 \clf_step_texts \module_steps_pass_data \STEPtextparameter {
333 top {\module_steps_tag_a}
334 bot {\module_steps_tag_b}
335 }
336 \endgroup}
337
338\def\module_steps_cell_indeed[#category]#str
339 {\begingroup
340 \iffirstargument
341 \module_steps_check_cell{#category}
342 \fi
343 \useSTEPcellstyleandcolor\c!style\c!color
344 \setSTEPbox\module_steps_tag_a{#str}
345 \clf_step_cell \module_steps_pass_data \STEPcellparameter {
346 top {\module_steps_tag_a}
347 }
348 \endgroup}
349
350\def\module_steps_text_indeed[#category]#str
351 {\begingroup
352 \iffirstargument
353 \module_steps_check_text{#category}
354 \fi
355 \useSTEPtextstyleandcolor\c!style\c!color
356 \setSTEPbox\module_steps_tag_a{#str}
357 \clf_step_text \module_steps_pass_data \STEPtextparameter {
358 top {\module_steps_tag_a}
359 }
360 \endgroup}
361
362\def\module_steps_toptext_indeed[#category]#top
363 {\begingroup
364 \iffirstargument
365 \module_steps_check_text{#category}
366 \fi
367 \useSTEPtextstyleandcolor\c!style\c!color
368 \setSTEPbox\module_steps_tag_a{#top}
369 \clf_step_text_top \module_steps_pass_data \STEPtextparameter {
370 top {\module_steps_tag_a}
371 }
372 \endgroup}
373
374\def\module_steps_bottext_indeed[#category]#bot
375 {\begingroup
376 \iffirstargument
377 \module_steps_check_text{#category}
378 \fi
379 \useSTEPtextstyleandcolor\c!style\c!color
380 \setSTEPbox\module_steps_tag_a{#bot}
381 \clf_step_text_bot \module_steps_pass_data \STEPtextparameter {
382 bot {\module_steps_tag_a}
383 }
384 \endgroup}
385
386\def\module_steps_topcell_indeed[#category]#top
387 {\begingroup
388 \iffirstargument
389 \module_steps_check_cell{#category}
390 \fi
391 \useSTEPcellstyleandcolor\c!style\c!color
392 \setSTEPbox\module_steps_tag_a{#top}
393 \clf_step_cell_top \module_steps_pass_data \STEPcellparameter {
394 top {\module_steps_tag_a}
395 }
396 \endgroup}
397
398\def\module_steps_botcell_indeed[#category]#bot
399 {\begingroup
400 \iffirstargument
401 \module_steps_check_cell{#category}
402 \fi
403 \useSTEPcellstyleandcolor\c!style\c!color
404 \setSTEPbox\module_steps_tag_a{#bot}
405 \clf_step_cell_bot \module_steps_pass_data \STEPcellparameter {
406 bot {\module_steps_tag_a}
407 }
408 \endgroup}
409
410\appendtoks
411 \let\cells \module_steps_cells
412 \let\texts \module_steps_texts
413 \let\cell \module_steps_cell
414 \let\text \module_steps_text
415 \let\toptext\module_steps_toptext
416 \let\bottext\module_steps_bottext
417 \let\topcell\module_steps_topcell
418 \let\botcell\module_steps_botcell
419\to \everySTEPchart
420
421
422
423\unexpanded\def\setSTEPxmldirective#1#2#3
424 {\begincsname setSTEP#1parameter\endcsname{#2}{#3}}
425
426\xmlinstalldirective{stepchart}{setSTEPxmldirective}
427
428\startxmlsetups xml:step:define
429 \xmlsetsetup
430 {#1}
431 {stepchartsteptablestepaligntablecellstextsstepcellcelltextbr}
432 {xml:step:*}
433\stopxmlsetups
434
435\xmlregistersetup{xml:step:define}
436
437\startxmlsetups xml:step:br
438 \crlf
439\stopxmlsetups
440
441\startxmlsetups xml:step:stepchart
442 \startSTEPchart[\c!category=\xmlatt{#1}{class}]
443 \xmlflush{#1}
444 \stopSTEPchart
445\stopxmlsetups
446
447\startxmlsetups xml:step:steptable
448 \startSTEPtable[\c!category=\xmlatt{#1}{class}]
449 \xmlflush{#1}
450 \stopSTEPtable
451\stopxmlsetups
452
453\startxmlsetups xml:step:stepaligntable
454 \startSTEPaligntable[\c!category=\xmlatt{#1}{class}]
455 \xmlflush{#1}
456 \stopSTEPaligntable
457\stopxmlsetups
458
459\startxmlsetups xml:step:cells
460 \xmldoifelse {#1} {c1} {
461 \cells
462 [\xmlatt{#1}{class}]
463 {\xmltext{#1}{c1}}
464 {\xmltext{#1}{c2}}
465 {\xmltext{#1}{c3}}
466 } {
467 \cells
468 [\xmlatt{#1}{class}]
469 {\xmltext{#1}{top}}
470 {\xmltext{#1}{bot}}
471 }
472\stopxmlsetups
473
474\startxmlsetups xml:step:texts
475 \texts
476 [\xmlatt{#1}{class}]
477 {\xmltext{#1}{top}}
478 {\xmltext{#1}{bot}}
479\stopxmlsetups
480
481\startxmlsetups xml:step:stepcell
482 \cells
483 [\xmlatt{#1}{class}]
484 {\xmltext{#1}{topcell}}
485 {\xmltext{#1}{botcell}}
486 \texts
487 [\xmlatt{#1}{class}]
488 {\xmltext{#1}{toptext}}
489 {\xmltext{#1}{bottext}}
490\stopxmlsetups
491
492\startxmlsetups xml:step:cell
493 \cell
494 [\xmlatt{#1}{class}]
495 {\xmlflush{#1}}
496\stopxmlsetups
497
498\startxmlsetups xml:step:text
499 \doifelse {\xmlatt{#1}{option}} {paragraph} {
500 \text
501 [\xmlatt{#1}{class}]
502 {\framed
503 [\c!location=\v!middle,\c!align={\v!lohi,\v!flushleft},\c!offset=0pt,\c!frame=\v!no]
504 {\ignorespaces\xmlflush{#1}\removeunwantedspaces}}
505 } {
506 \text
507 [\xmlatt{#1}{class}]
508 {\xmlflush{#1}}
509 }
510\stopxmlsetups
511
512\protect
513
514\continueifinputfile{msteps.mkvi}
515
516\starttext
517
518\setupSTEPcells[demo1][style=bold]
519
520\startbuffer
521<stepchart>
522 <cell> some cell <cell>
523 <text> some text <text>
524 <cell class="demo1"> some cell <cell>
525 <text> some text <text>
526 <cell> some cell <cell>
527<stepchart>
528\stopbuffer
529
530\typebuffer \processxmlbuffer
531
532\startbuffer
533<steptable>
534 <cell> some cell A<cell>
535 <text> some text 1<text>
536 <cell> some cell B<cell>
537 <text> some text 2<text>
538 <cell> some cell C<cell>
539<steptable>
540\stopbuffer
541
542\typebuffer \processxmlbuffer
543
544\startbuffer
545<steptable>
546 <cell> some cell A<cell>
547 <text option="paragraph"> some more<br>text 1<text>
548 <cell> some cell B<cell>
549<steptable>
550\stopbuffer
551
552\typebuffer \processxmlbuffer
553
554\page
555
556\startSTEPchart
557 \cells {A} {B}
558 \cells {one} {five} \texts{$2$}{$2$}
559 \cells {two} {four} \texts{$3$}{$3$}
560 \cells {three} {three} \texts{$4$}{$4$}
561 \cells {four} {two} \texts{$5$}{$5$}
562 \cells {five} {one}
563\stopSTEPchart
564
565\startbuffer
566<stepchart>
567 <cells> <top> some text <top> <bot> some text <bot> <cells>
568 <texts> <top> text <top> <bot> text <bot> <texts>
569 <cells> <top> some text <top> <bot> some text <bot> <cells>
570<stepchart>
571\stopbuffer
572
573\processxmlbuffer
574
575\startbuffer
576<stepchart>
577 <cell> some text <cell>
578 <texts> <top> text <top> <bot> text <bot> <texts>
579 <cell> some text <cell>
580<stepchart>
581\stopbuffer
582
583\processxmlbuffer
584
585\page
586
587\startSTEPchart[second]
588 \startSTEPcell
589 \topcell {A}
590 \botcell {B}
591 \startSTEPcell
592 \topcell {one}
593 \botcell {five}
594 \toptext {$2$}
595 \bottext {$2$}
596 \stopSTEPcell
597 \startSTEPcell
598 \topcell {two}
599 \botcell {four}
600 \toptext {$3$}
601 \bottext {$3$}
602 \stopSTEPcell
603 \startSTEPcell
604 \topcell {three}
605 \botcell {three}
606 \toptext {$4$}
607 \bottext {$4$}
608 \stopSTEPcell
609 \startSTEPcell
610 \topcell {four}
611 \botcell {two}
612 \toptext {$5$}
613 \bottext {$5$}
614 \stopSTEPcell
615 \startSTEPcell
616 \topcell {five}
617 \botcell {one}
618 \stopSTEPcell
619\stopSTEPchart
620
621\STEPchart[first][alternative=horizontal]
622\STEPchart[first][alternative=vertical]
623
624\page
625
626\STEPchart[second][alternative=horizontal]
627\STEPchart[second][alternative=vertical]
628
629\page
630
631\setupSTEPchart
632 [mytable]
633 [before={\blank[2*big]},
634 after={\blank[2*big]}]
635
636\starttext
637
638\startSTEPaligntable[mytable]
639 \cells {$2c$} {$=$} {$2a3b$}
640 \text {with $a=5$}
641 \cells {$2c$}{$=$} {$103b$}
642 \text {and $b=6$}
643 \cells {$2c$} {$=$} {$1018$}
644 \text {we get}
645 \cells {$2c$} {$=$} {$28$}
646 \text {and therefore}
647 \cells {$c$} {$=$} {$282$}
648 \text {which reduces to}
649 \cells {$c$} {$=$} {$14$}
650\stopSTEPaligntable
651
652\input tufte
653
654\STEPchart[mytable]
655
656\input tufte
657
658\setupSTEPchart
659 [mytable]
660 [buffer=no]
661
662\startSTEPaligntable[mytable]
663 \cells {$2c$} {$=$} {$2a3b$}
664 \text {with $a=5$}
665 \cells {$2c$}{$=$} {$103b$}
666 \text {and $b=6$}
667 \cells {$2c$} {$=$} {$1018$}
668 \text {we get}
669 \cells {$2c$} {$=$} {$28$}
670 \text {and therefore}
671 \cells {$c$} {$=$} {$282$}
672 \text {which reduces to}
673 \cells {$c$} {$=$} {$14$}
674\stopSTEPaligntable
675
676\input tufte
677
678\STEPchart[mytable]
679
680\stoptext
681 |