1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
%D \module
%D [ file=buff-par,
%D version=2010.12.05,
%D title=\CONTEXT\ Buffer Macros,
%D subtitle=Parallel,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
\writestatus{loading}{ConTeXt Buffer Macros / Parallel}
\registerctxluafile{buff-par}{1.001}
%D This module is developped for Thomas Schmitz as part of
%D a project. There is no documentation yet.
%D
%D \starttyping
%D \defineparallel[main][one,two]
%D
%D \startmain
%D \startone
%D first 1
%D [reference] first 2
%D first 3
%D \stopone
%D \starttwo
%D second 1
%D \stoptwo
%D \stopmain
%D
%D \placeparallel[main][one,two][criterium=all]
%D criterium=all start=<number> n=<number>
\unprotect
\installcorenamespace{parallel}
\installcommandhandler \??parallel {parallel} \??parallel
\setupparallel
[\c!setups=parallel:place:default]
\let\buff_parallel_define_saved\defineparallel
\unexpanded\def\defineparallel
{\dodoubleargument\buff_parallel_define}
\def\buff_parallel_define[#name][#instances]%
{\buff_parallel_define_saved[#name]
\ctxcommand{defineparallel("#name","#instances")}%
\processcommalist[#instances]\buff_parallel_define_instance
\setuevalue{\e!start#name}{\buff_parallel_start{#name}}%
\setuevalue{\e!stop #name}{\buff_parallel_stop}}
\def\buff_parallel_define_instance#instance%
{\normalexpanded{\buff_parallel_define_saved[#instance][\currentparallel]}%
\definebuffer[#instance]%
\setuevalue{\e!stop#instance}{\buff_parallel_save{#instance}}}
\unexpanded\def\buff_parallel_start#name%
{\pushmacro\currentparallel
\edef\currentparallel{#name}%
\ctxcommand{nextparallel("\currentparallel")}}
\unexpanded\def\buff_parallel_stop
{\popmacro\currentparallel}
\unexpanded\def\buff_parallel_save#instance% defined moet ook aan de lua kant kunnen
{\ctxcommand{saveparallel("\currentparallel","#instance",buffers.raw("\thedefinedbuffer{#instance}"))}}
\unexpanded\def\placeparallel
{\dotripleempty\buff_parallel_place}
\def\buff_parallel_place[#name][#instance][#settings]%
{\begingroup
\edef\currentparallel{#name}%
\ctxcommand{placeparallel("\currentparallel","#instance","#settings")}% -- todo: pass options as k/v
\endgroup}
\def\doflushparallel#instance#status#line#label#content% called at lua end
{\begingroup
\def\currentparallelinstance{#instance}%
\def\currentparallelnumber {#status}%
\def\currentparallelline {#line}%
\def\currentparallellabel {#label}%
\def\currentparallelcontent {#content}%
\ifcase#status\relax
\expandafter\buff_parallel_flush_nop
\or
\expandafter\buff_parallel_flush_yes
\fi
\endgroup}
\def\buff_parallel_flush_nop
{}
\def\buff_parallel_flush_yes
{\directsetup{\namedparallelparameter\currentparallelinstance\c!setups}}
\unexpanded\def\doifelseparallel#name#instance%
{\ctxcommand{doifelseparallel("#name","#instance")}}
\unexpanded\def\resetparallel
{\dodoubleempty\buff_parallel_reset}
\def\buff_parallel_reset[#name][#instance]%
{\ctxcommand{resetparallel("#name","#instance"))}}
\startsetups parallel:place:default
\hangafter\plusone
\hangindent4em
\dontleavehmode
\hbox to 3em \bgroup
\hss
\bf
\doifsomething \currentparallellabel {
\textreference[\currentparallellabel]{\currentparallelline}
}
\currentparallelline
\quad
\egroup
\currentparallelcontent
\par
\stopsetups
\protect \endinput
|