colo-run.mkiv /size: 9027 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=colo-run,
3
%D version=1997.04.01,
4
%D title=\CONTEXT\ Color Macros,
5
%D subtitle=Runtime loaded commands,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
\registerctxluafile
{
colo
-
run
}{}
15 16
\unprotect
17 18
%D Colors
19 20
% These are nicer in \LUA\ code than in \TEX\ code but not more
21
% efficient.
22 23
\unexpanded
\gdef
\showcolorbar
[#
1
]
%
24
{
\backgroundline
[#
1
]
{
\strut\enspace
\color
[
white
]
{
white
}
\enspace
\color
[
black
]
{
black
}
\enspace
}}
25 26
\unexpanded
\gdef
\showcolor
{
\dosingleempty
\colo_basics_show
}
27
\unexpanded
\gdef
\showcolorset
{
\dosingleempty
\colo_basics_show_set
}
28
\unexpanded
\gdef
\showcolorcomponents
{
\dosingleempty
\colo_basics_show_components
}
29 30
\gdef
\colo_basics_show_set
[#
1
]
{
\ctxcommand{
showcolorset
(
"
#1
"
)
}
}
31
\gdef
\colo_basics_show_components
[#
1
]
{
\ctxcommand{
showcolorcomponents
(
"
#1
"
)
}
}
32 33
\gdef
\colo_basics_show
[#
1
]
% % we do this at the tex end as loading happens
34
{
\usecolors
[#
1
]
% % delayed and we can only ask for the set if
35
\showcolorset
[#
1
]
}
% loading has happened
36 37
% The rest might also be done in \LUA\ although there is not much
38
% beauty to gain here (too much typesetting specific). Also, these
39
% macros are pretty old and hardly used so best keep them as they
40
% are.
41 42
%D Palets
43 44
\unexpanded
\gdef
\showpalet
45
{
\dodoubleargument
\colo_show_palet
}
46 47
\gdef
\colo_show_palet
[#
1
][#
2
]
%
48
{
\doifelsecolorpalet
{
#
1
}
49
{
\doifelseinset
\v!vertical
{
#
2
}
\colo_palets_show_vertical
\colo_palets_show_horizontal
{
#
1
}{
#
2
}}
%
50
{}}
51 52
\gdef
\colo_palets_show_vertical
#
1
#
2
%
53
{
\begingroup
54
\forgetall
55
\setlocalhsize
56
\hsize
\localhsize
57
\offinterlineskip
58
\setuppalet
[#
1
]
59
\tabskip
\zeropoint
60
\def
\colo_palets_show_palet
##
1
%
61
{
\doifelseinset
\v!number
{
#
2
}{
##
1
\hskip
.
5
\emwidth
}{}
%
62
\aligntab
63
\color
[##
1
]
{
\vrule
\s!width
3
\emwidth
\s!height
\strutht
\s!depth
\strutdp
}
%
64
\graycolor
[##
1
]
{
\vrule
\s!width
3
\emwidth
\s!height
\strutht
\s!depth
\strutdp
}
%
65
\aligntab
66
\doifinset
\v!value
{
#
2
}{
\hskip
.
5
\emwidth
\colorvalue
{
##
1
}}
%
67
\crcr
}
68
\halign
69
{
\hss\alignmark\alignmark\aligntab\hss\alignmark\alignmark\hss\aligntab\alignmark\alignmark\cr
70
\aligntab
\doifinset
\v!name
{
#
2
}{
\strut
#
1
}
\aligntab\cr
71
\colo_palets_process
[#
1
]
\colo_palets_show_palet
\crcr
}
%
72
\endgroup
}
73 74
\gdef
\colo_palets_show_horizontal
#
1
#
2
% todo: bTABLE etc
75
{
\vbox
76
{
\forgetall
77
\setlocalhsize
78
\hsize
\localhsize
79
\offinterlineskip
80
\setuppalet
[#
1
]
81
\tabskip
\zeropoint
82
\scratchwidth
\zeropoint
83
\doifinset
\v!number
{
#
2
}
84
{
\def
\colo_palets_show_palet
##
1
%
85
{
\setbox
\scratchbox
\hbox
{
##
1
}
%
86
\ifdim
\scratchwidth
<
\wd
\scratchbox
87
\scratchwidth
\wd
\scratchbox
88
\fi
}
%
89
\colo_palets_process
[#
1
]
\colo_palets_show_palet
}
%
90
\advance
\scratchwidth
\emwidth
91
\ifdim
\scratchwidth
<
5
\emwidth
92
\scratchwidth
5
\emwidth
93
\fi
94
\halign
95
{
\alignmark\alignmark\aligntab\aligntab\hbox
to
\scratchwidth
{
\hss\alignmark\alignmark\hss
}
\cr
96
\doifinset
\v!number
{
#
2
}
97
{
\def
\colo_palets_show_palet
##
1
{
\aligntab
\strut
##
1
}
%
98
\colo_palets_process
[#
1
]
\colo_palets_show_palet
}
\cr
99
\doifinset
\v!name
{
#
2
}{
#
1
\hskip
.
5
\emwidth
}
%
100
\def
\colo_palets_show_palet
##
1
%
101
{
\aligntab
\strut
\color
[##
1
]
{
\vrule
\s!width
\scratchwidth
\s!height
\strutht
\s!depth
\zeropoint
}}
%
102
\colo_palets_process
[#
1
]
\colo_palets_show_palet
\crcr
103
\noalign
{
\vskip
-
\strutdepth
}
%
104
\def
\colo_palets_show_palet
##
1
%
105
{
\aligntab
\graycolor
[##
1
]
{
\vrule
\s!width
\scratchwidth
\s!height
\zeropoint
\s!depth
\strutdp
}}
%
106
\colo_palets_process
[#
1
]
\colo_palets_show_palet
\crcr
107
\doifinset
\v!value
{
#
2
}
108
{
\def
\colo_palets_show_palet
##
1
%
109
{
\aligntab\vbox
110
{
\hsize
\scratchwidth
111
\vskip
.
2
5
\exheight
112
\everypar
{
\strut
}
113
\veryraggedcenter
114
\let
\colorformatseparator
\endgraf
115
\colorvalue
{
##
1
}}}
%
116
\colo_palets_process
[#
1
]
\colo_palets_show_palet
}
%
117
\crcr
}}}
118 119
\gdef
\colo_palets_process
[#
1
]
%
120
{
\getpaletlist
[#
1
]
%
121
\normalexpanded
{
\globalprocesscommalist
[
\paletlist
]
}}
122 123
\unexpanded
\gdef
\comparepalet
124
{
\dosingleargument
\colo_palets_compare
}
125 126
\gdef
\colo_palets_compare
[#
1
]
%
127
{
\doifelsecolorpalet
{
#
1
}
%
128
{
\hbox
129
{
\colo_palets_compare_indeed
\color
{
#
1
}
%
130
\quad
131
\colo_palets_compare_indeed
\graycolor
{
#
1
}}}
%
132
{}}
133 134
\gdef
\colo_palets_compare_indeed
#
1
#
2
%
135
{
\vbox
136
{
\forgetall
137
\setlocalhsize
138
\hsize
\localhsize
139
\offinterlineskip
140
\setuppalet
[#
2
]
141
\getpaletsize
[#
2
]
%
142
\getpaletlist
[#
2
]
%
143
\scratchwidth
2
\emwidth
\relax
144
\hsize
\paletsize
\scratchwidth
145
\def
\colo_palets_compare
##
1
%
146
{
\hbox
147
{
\setbox
0
\hbox
148
{
#
1
[##
1
]
{
\vrule
\s!width
\hsize
\s!height
3
ex
}}
%
149
\wd
0
\zeropoint
150
\box
0
151
\hbox
to
\hsize
152
{
\def
\colo_palets_compare
####
1
%
153
{
\hbox
to
\scratchwidth
154
{
\hss
#
1
[####
1
]
{
\vrule
\s!width
.
5
\scratchwidth
\s!height
2
.
2
5
\exheight
\s!depth
-
.
7
5
\exheight
}
\hss
}}
%
155
\processcommacommand
[
\paletlist
]
\colo_palets_compare
}}
156
\endgraf
}
157
\processcommacommand
[
\paletlist
]
\colo_palets_compare
}}
158 159
%D Groups
160 161
\unexpanded
\gdef
\showcolorgroup
162
{
\dodoubleargument
\colo_groups_show
}
163 164
\gdef
\colo_groups_show
[#
1
][#
2
]
%
165
{
\doifcolor
{
#
1
:
1
}
166
{
\doifelseinset
\v!vertical
{
#
2
}
167
\colo_groups_show_vertical
168
\colo_groups_show_horizontal
169
[#
1
][#
2
]
}}
170 171
\gdef
\colo_groups_show_horizontal
[#
1
][#
2
]
%
172
{
\vbox
173
{
\forgetall
174
\setlocalhsize
175
\hsize
\localhsize
176
\offinterlineskip
177
\setuppalet
178
\tabskip
\zeropoint
179
\def
\colorformatseparator
{
\strut
\cr
}
180
\def
\colo_groups_show_group
##
1
%
181
{
\doifcolor
{
#
1
:
##
1
}{
\vbox
182
{
\halign
183
{
\hss\alignmark\alignmark\alignmark\alignmark\hss\cr
184
\doifinset
\v!number
{
#
2
}{
\strut
##
1
}
\cr
185
\color
[#
1
:
##
1
]
{
\vrule
\s!width
4
\emwidth
\s!height
\strutht
\s!depth
\zeropoint
}
\cr
186
\graycolor
[#
1
:
##
1
]
{
\vrule
\s!width
4
\emwidth
\s!height
\zeropoint
\s!depth
\strutdp
}
\cr
187
\doifinset
\v!value
{
#
2
}{
\colorvalue
{
#
1
:
##
1
}
\strut
}
\crcr
}}}}
%
188
\hbox
189
{
\doifinset
\v!name
{
#
2
}
190
{
\strut
191
\doifelseinset
\v!value
{
#
2
}
192
{
\raise
3
\lineheight
\hbox
{
#
1
\hskip
.
5
\emwidth
}}
193
{
#
1
}
%
194
\hskip
.
5
\emwidth
}
%
195
\colo_groups_show_group
1
\colo_groups_show_group
2
\colo_groups_show_group
3
\colo_groups_show_group
4
%
196
\colo_groups_show_group
5
\colo_groups_show_group
6
\colo_groups_show_group
7
\colo_groups_show_group
8
}}}
197 198
\gdef
\colo_groups_show_vertical
[#
1
][#
2
]
%
199
{
\vbox
200
{
\forgetall
201
\setlocalhsize
202
\hsize
\localhsize
203
\offinterlineskip
204
\setuppalet
205
\tabskip
\zeropoint
206
\def
\colo_groups_show_group
##
1
%
207
{
\doifcolor
{
#
1
:
##
1
}
208
{
\doifinset
\v!number
{
#
2
}
209
{
##
1
\hskip
.
5
\emwidth
}
%
210
\aligntab
211
\color
[#
1
:
##
1
]
{
\vrule
\s!width
2
.
5
\emwidth
\s!height
\strutht
\s!depth
\strutdp
}
%
212
\graycolor
[#
1
:
##
1
]
{
\vrule
\s!width
2
.
5
\emwidth
\s!height
\strutht
\s!depth
\strutdp
}
213
\aligntab
214
\doifinset
\v!value
{
#
2
}{
\hskip
.
5
\emwidth
\colorvalue
{
#
1
:
##
1
}}
%
215
\crcr
}}
%
216
\halign
217
{
\hss\alignmark\alignmark\aligntab\hss\alignmark\alignmark\hss\aligntab\alignmark\alignmark\hss\cr
218
\aligntab
\doifinset
\v!name
{
#
2
}{
\strut
#
1
}
\aligntab\crcr
219
\colo_groups_show_group
1
\colo_groups_show_group
2
\colo_groups_show_group
3
\colo_groups_show_group
4
%
220
\colo_groups_show_group
5
\colo_groups_show_group
6
\colo_groups_show_group
7
\colo_groups_show_group
8
}}}
221 222
\unexpanded
\gdef
\comparecolorgroup
223
{
\dosingleargument
\colo_groups_compare
}
224 225
\gdef
\colo_groups_compare
[#
1
]
%
226
{
\doifcolor
{
#
1
:
1
}
227
{
\hbox
228
{
\colo_groups_compare_indeed
\color
[#
1
]
\quad
229
\colo_groups_compare_indeed
\graycolor
[#
1
]
}}}
230 231
\gdef
\colo_groups_compare_indeed
#
1
[#
2
]
%
232
{
\vbox
233
{
\forgetall
234
\setlocalhsize
235
\hsize
\localhsize
236
\scratchcounter
\zerocount
237
\dorecurse
{
1
5
}{
\doifcolor
{
#
2
:
\recurselevel
}{
\advance
\scratchcounter
\plusone
}}
238
\scratchwidth
2
\emwidth
\relax
239
\hsize
\scratchcounter\scratchwidth
240
\dorecurse\scratchcounter
{
\colo_groups_compare_step
{
#
1
}{
#
2
}
\recurselevel
}}}
241 242
\def
\colo_groups_compare_step
#
1
#
2
#
3
%
243
{
\hbox
to
\hsize
244
{
\setbox
\scratchbox
\hbox
245
{
#
1
[#
2
:
#
3
]
{
\vrule
\s!width
\hsize
\s!height
3
\exheight
}}
%
246
\wd
\scratchbox
\zeropoint
247
\box
\scratchbox
248
\hbox
to
\hsize
249
{
\hss
250
\dorecurse\scratchcounter
251
{
#
1
[#
2
:
\recurselevel
]
{
\vrule
\s!width
.
5
\scratchwidth
\s!height
2
.
2
5
\exheight
\s!depth
-
.
7
5
\exheight
}
%
252
\hss
}}}
253
\endgraf
}
254 255
\protect
\endinput
256