cld-environment.tex /size: 4758 b    last modification: 2021-10-28 13:50
1% language=us runpath=texruns:manuals/cld
2
3\startenvironment cld-environment
4
5\usemodule[abr-04]
6
7\setuplayout
8  [width=middle,
9   height=middle,
10   backspace=2cm,
11   topspace=1cm,
12   footer=0pt,
13   bottomdistance=1cm,
14   bottom=1cm,
15   bottomspace=2cm]
16
17\setuppagenumbering
18  [alternative=doublesided]
19
20\definecolor[darkred]  [r=.5]
21\definecolor[darkgreen][g=.5]
22\definecolor[darkblue] [b=.5]
23
24\definecolor[red]  [darkred]
25\definecolor[green][darkgreen]
26\definecolor[blue] [darkblue]
27
28\definetype
29  [boldtypebig]
30  [style=\ttbfa]
31
32\definetype
33  [boldtype]
34  [style=\ttbf]
35
36\definetyping
37  [smalltyping]
38  [bodyfont=small]
39
40\setuptype
41  [color=blue]
42
43\setuptyping
44  [color=blue]
45
46\setupbodyfont
47  [palatino,11pt]
48
49\setuphead
50  [chapter]
51  [style=\bfc,
52   color=blue]
53
54\setuphead
55  [section]
56  [style=\bfb,
57   color=blue]
58
59\definehead
60  [summary]
61  [subsubsubsubject]
62
63\setuphead
64  [summary]
65  [style=,
66   deeptextcommand=\boldtypebig,
67   color=blue]
68
69\definehead
70  [subsummary]
71  [subsubsubsubsubject]
72
73\setuphead
74  [subsummary]
75  [style=,
76   before=\blank,
77   after=\blank,
78   deeptextcommand=\type,
79   command=\MySubSummaryHead,
80   color=blue]
81
82\unexpanded\def\MySummaryHead#1#2%
83  {\framed
84     [frame=off,
85      bottomframe=on,
86      offset=0cm]
87     {#2}}
88
89\unexpanded\def\MySubSummaryHead#1#2%
90  {\framed
91     [frame=off,
92      bottomframe=on,
93      offset=0cm]
94     {#2}}
95
96\setupwhitespace
97  [big]
98
99\setupheadertexts
100  []
101
102\setupheadertexts
103  []
104  [{\getmarking[chapter]\quad\pagenumber}]
105  [{\pagenumber\quad\getmarking[chapter]}]
106  []
107
108\setupheader
109  [color=darkblue]
110
111\setuplist
112  [chapter,title]
113  [color=darkblue,
114   style=bold]
115
116\setupbottom
117  [style=\bfx,
118   color=darkred]
119
120\setupbottomtexts
121  [preliminary, uncorrected version -- \currentdate]
122
123% special functions
124
125\unexpanded\def\ShowLuaExampleOne#1#2#3%
126  {\bgroup
127   \obeyluatokens
128   \startsubsummary[title={#1.#2(#3)}]
129   \ctxlua{table.tocontext(#3)}
130   \stopsubsummary
131   \egroup}
132
133\unexpanded\def\ShowLuaExampleTwo#1#2#3%
134  {\bgroup
135   \obeyluatokens
136   \startsubsummary[title={#1.#2(#3)}]
137   \ctxlua{table.tocontext(#1.#2(#3))}
138   \stopsubsummary
139   \egroup}
140
141\unexpanded\def\ShowLuaExampleThree#1#2#3%
142  {\bgroup
143   \obeyluatokens
144   \startsubsummary[title={#1.#2(#3)}]
145   \ctxlua{string.tocontext(tostring(#1.#2(#3)))}
146   \stopsubsummary
147   \egroup}
148
149\unexpanded\def\ShowLuaExampleFour#1#2#3#4%
150  {\bgroup
151   \obeyluatokens
152   \startsubsummary[title={t=#3 #1.#2(t#4)}]
153   \ctxlua{local t = #3 #1.#2(t#4) table.tocontext(t)}
154   \stopsubsummary
155   \egroup}
156
157\unexpanded\def\ShowLuaExampleFive#1#2%
158  {\bgroup
159   \obeyluatokens
160   \startsubsummary[title={#1.#2}]
161   \ctxlua{string.tocontext(tostring(#1.#2))}
162   \stopsubsummary
163   \egroup}
164
165\unexpanded\def\ShowLuaExampleSix#1#2#3%
166  {\bgroup
167   \obeyluatokens
168   \startsubsummary[title={#1.#2(#3)}]
169   \ctxlua{string.tocontext(#1.#2(#3))}
170   \stopsubsummary
171   \egroup}
172
173\unexpanded\def\ShowLuaExampleSeven#1#2#3%
174  {\bgroup
175   \obeyluatokens
176   \startsubsummary[title={#1.#2(#3)}]
177   \ctxlua{string.tocontext(table.concat({#1.#2(#3)}," "))}
178   \stopsubsummary
179   \egroup}
180
181\unexpanded\def\ShowLuaExampleTable#1%
182  {\bgroup
183   \obeyluatokens
184   \startsubsummary[title={#1}]
185   \ctxlua{table.tocontext(#1,false)}
186   \stopsubsummary
187   \egroup}
188
189\unexpanded\def\ShowLuaExampleTableHex#1%
190  {\bgroup
191   \obeyluatokens
192   \startsubsummary[title={#1}]
193   \ctxlua{table.tocontext(#1,false,false,true,true)} % name, reduce, noquotes, hex
194   \stopsubsummary
195   \egroup}
196
197\unexpanded\def\ShowLuaExampleString#1%
198  {\bgroup
199   \obeyluatokens
200   \startsubsummary[title={#1}]
201   \ctxlua{string.tocontext(#1)}
202   \stopsubsummary
203   \egroup}
204
205\unexpanded\def\ShowLuaExampleBoolean#1%
206  {\bgroup
207   \obeyluatokens
208   \startsubsummary[title={#1}]
209   \ctxlua{boolean.tocontext(#1)}
210   \stopsubsummary
211   \egroup}
212
213% interaction
214
215\setupinteraction
216  [state=start,
217   color=,
218   contrastcolor=]
219
220\setuplist
221  [chapter,section]
222  [interaction=all]
223
224% a hack:
225
226\startluacode
227    function document.checkcldresource(filename)
228        if environment.arguments.runpath then
229            -- We're running elsewhere so we can have started fresh.
230            local cldname = file.replacesuffix(filename,"cld")
231            local pdfname = file.replacesuffix(filename,"pdf")
232            if not lfs.isfile(pdfname) then
233                -- We don't have the titlepage yet but need to fetch
234                -- the template from the real path.
235                local path = environment.arguments.path
236                if lfs.isdir(path) then
237                    os.execute('context --global --path="' .. path .. '" ' .. cldname)
238                else
239                    -- bad news
240                end
241            end
242        end
243    end
244\stopluacode
245
246
247\stopenvironment
248