1 /* Color handling for the SDL interface to Xconq.
2 Copyright (C) 2004 Eric A. McDonald.
3
4 Xconq is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version. See the file COPYING. */
8
9 #include "sdlpreconq.h"
10 #include "conq.h"
11 #include "sdlconq.h"
12
13 /* The following table was shamelessly stolen from:
14 http://www.tcl.tk/man/tcl8.4/TkCmd/colors.htm
15 and saved as text. The C/C++ form was then brought to you by the
16 letters 'cut', 'sed', and 'awk', and the number 'paste'.
17 This has been a production of the Children's Televis... Never mind. */
18 RGBColorTableEntry stdcolors [] = {
19 { "alice blue", 240, 248, 255 },
20 { "AliceBlue", 240, 248, 255 },
21 { "antique white", 250, 235, 215 },
22 { "AntiqueWhite", 250, 235, 215 },
23 { "AntiqueWhite1", 255, 239, 219 },
24 { "AntiqueWhite2", 238, 223, 204 },
25 { "AntiqueWhite3", 205, 192, 176 },
26 { "AntiqueWhite4", 139, 131, 120 },
27 { "aquamarine", 127, 255, 212 },
28 { "aquamarine1", 127, 255, 212 },
29 { "aquamarine2", 118, 238, 198 },
30 { "aquamarine3", 102, 205, 170 },
31 { "aquamarine4", 69, 139, 116 },
32 { "azure", 240, 255, 255 },
33 { "azure1", 240, 255, 255 },
34 { "azure2", 224, 238, 238 },
35 { "azure3", 193, 205, 205 },
36 { "azure4", 131, 139, 139 },
37 { "beige", 245, 245, 220 },
38 { "bisque", 255, 228, 196 },
39 { "bisque1", 255, 228, 196 },
40 { "bisque2", 238, 213, 183 },
41 { "bisque3", 205, 183, 158 },
42 { "bisque4", 139, 125, 107 },
43 { "black", 0, 0, 0 },
44 { "blanched almond", 255, 235, 205 },
45 { "BlanchedAlmond", 255, 235, 205 },
46 { "blue", 0, 0, 255 },
47 { "blue violet", 138, 43, 226 },
48 { "blue1", 0, 0, 255 },
49 { "blue2", 0, 0, 238 },
50 { "blue3", 0, 0, 205 },
51 { "blue4", 0, 0, 139 },
52 { "BlueViolet", 138, 43, 226 },
53 { "brown", 165, 42, 42 },
54 { "brown1", 255, 64, 64 },
55 { "brown2", 238, 59, 59 },
56 { "brown3", 205, 51, 51 },
57 { "brown4", 139, 35, 35 },
58 { "burlywood", 222, 184, 135 },
59 { "burlywood1", 255, 211, 155 },
60 { "burlywood2", 238, 197, 145 },
61 { "burlywood3", 205, 170, 125 },
62 { "burlywood4", 139, 115, 85 },
63 { "cadet blue", 95, 158, 160 },
64 { "CadetBlue", 95, 158, 160 },
65 { "CadetBlue1", 152, 245, 255 },
66 { "CadetBlue2", 142, 229, 238 },
67 { "CadetBlue3", 122, 197, 205 },
68 { "CadetBlue4", 83, 134, 139 },
69 { "chartreuse", 127, 255, 0 },
70 { "chartreuse1", 127, 255, 0 },
71 { "chartreuse2", 118, 238, 0 },
72 { "chartreuse3", 102, 205, 0 },
73 { "chartreuse4", 69, 139, 0 },
74 { "chocolate", 210, 105, 30 },
75 { "chocolate1", 255, 127, 36 },
76 { "chocolate2", 238, 118, 33 },
77 { "chocolate3", 205, 102, 29 },
78 { "chocolate4", 139, 69, 19 },
79 { "coral", 255, 127, 80 },
80 { "coral1", 255, 114, 86 },
81 { "coral2", 238, 106, 80 },
82 { "coral3", 205, 91, 69 },
83 { "coral4", 139, 62, 47 },
84 { "cornflower blue", 100, 149, 237 },
85 { "CornflowerBlue", 100, 149, 237 },
86 { "cornsilk", 255, 248, 220 },
87 { "cornsilk1", 255, 248, 220 },
88 { "cornsilk2", 238, 232, 205 },
89 { "cornsilk3", 205, 200, 177 },
90 { "cornsilk4", 139, 136, 120 },
91 { "cyan", 0, 255, 255 },
92 { "cyan1", 0, 255, 255 },
93 { "cyan2", 0, 238, 238 },
94 { "cyan3", 0, 205, 205 },
95 { "cyan4", 0, 139, 139 },
96 { "dark blue", 0, 0, 139 },
97 { "dark cyan", 0, 139, 139 },
98 { "dark goldenrod", 184, 134, 11 },
99 { "dark gray", 169, 169, 169 },
100 { "dark green", 0, 100, 0 },
101 { "dark grey", 169, 169, 169 },
102 { "dark khaki", 189, 183, 107 },
103 { "dark magenta", 139, 0, 139 },
104 { "dark olive green", 85, 107, 47 },
105 { "dark orange", 255, 140, 0 },
106 { "dark orchid", 153, 50, 204 },
107 { "dark red", 139, 0, 0 },
108 { "dark salmon", 233, 150, 122 },
109 { "dark sea green", 143, 188, 143 },
110 { "dark slate blue", 72, 61, 139 },
111 { "dark slate gray", 47, 79, 79 },
112 { "dark slate grey", 47, 79, 79 },
113 { "dark turquoise", 0, 206, 209 },
114 { "dark violet", 148, 0, 211 },
115 { "DarkBlue", 0, 0, 139 },
116 { "DarkCyan", 0, 139, 139 },
117 { "DarkGoldenrod", 184, 134, 11 },
118 { "DarkGoldenrod1", 255, 185, 15 },
119 { "DarkGoldenrod2", 238, 173, 14 },
120 { "DarkGoldenrod3", 205, 149, 12 },
121 { "DarkGoldenrod4", 139, 101, 8 },
122 { "DarkGray", 169, 169, 169 },
123 { "DarkGreen", 0, 100, 0 },
124 { "DarkGrey", 169, 169, 169 },
125 { "DarkKhaki", 189, 183, 107 },
126 { "DarkMagenta", 139, 0, 139 },
127 { "DarkOliveGreen", 85, 107, 47 },
128 { "DarkOliveGreen1", 202, 255, 112 },
129 { "DarkOliveGreen2", 188, 238, 104 },
130 { "DarkOliveGreen3", 162, 205, 90 },
131 { "DarkOliveGreen4", 110, 139, 61 },
132 { "DarkOrange", 255, 140, 0 },
133 { "DarkOrange1", 255, 127, 0 },
134 { "DarkOrange2", 238, 118, 0 },
135 { "DarkOrange3", 205, 102, 0 },
136 { "DarkOrange4", 139, 69, 0 },
137 { "DarkOrchid", 153, 50, 204 },
138 { "DarkOrchid1", 191, 62, 255 },
139 { "DarkOrchid2", 178, 58, 238 },
140 { "DarkOrchid3", 154, 50, 205 },
141 { "DarkOrchid4", 104, 34, 139 },
142 { "DarkRed", 139, 0, 0 },
143 { "DarkSalmon", 233, 150, 122 },
144 { "DarkSeaGreen", 143, 188, 143 },
145 { "DarkSeaGreen1", 193, 255, 193 },
146 { "DarkSeaGreen2", 180, 238, 180 },
147 { "DarkSeaGreen3", 155, 205, 155 },
148 { "DarkSeaGreen4", 105, 139, 105 },
149 { "DarkSlateBlue", 72, 61, 139 },
150 { "DarkSlateGray", 47, 79, 79 },
151 { "DarkSlateGray1", 151, 255, 255 },
152 { "DarkSlateGray2", 141, 238, 238 },
153 { "DarkSlateGray3", 121, 205, 205 },
154 { "DarkSlateGray4", 82, 139, 139 },
155 { "DarkSlateGrey", 47, 79, 79 },
156 { "DarkTurquoise", 0, 206, 209 },
157 { "DarkViolet", 148, 0, 211 },
158 { "deep pink", 255, 20, 147 },
159 { "deep sky blue", 0, 191, 255 },
160 { "DeepPink", 255, 20, 147 },
161 { "DeepPink1", 255, 20, 147 },
162 { "DeepPink2", 238, 18, 137 },
163 { "DeepPink3", 205, 16, 118 },
164 { "DeepPink4", 139, 10, 80 },
165 { "DeepSkyBlue", 0, 191, 255 },
166 { "DeepSkyBlue1", 0, 191, 255 },
167 { "DeepSkyBlue2", 0, 178, 238 },
168 { "DeepSkyBlue3", 0, 154, 205 },
169 { "DeepSkyBlue4", 0, 104, 139 },
170 { "dim gray", 105, 105, 105 },
171 { "dim grey", 105, 105, 105 },
172 { "DimGray", 105, 105, 105 },
173 { "DimGrey", 105, 105, 105 },
174 { "dodger blue", 30, 144, 255 },
175 { "DodgerBlue", 30, 144, 255 },
176 { "DodgerBlue1", 30, 144, 255 },
177 { "DodgerBlue2", 28, 134, 238 },
178 { "DodgerBlue3", 24, 116, 205 },
179 { "DodgerBlue4", 16, 78, 139 },
180 { "firebrick", 178, 34, 34 },
181 { "firebrick1", 255, 48, 48 },
182 { "firebrick2", 238, 44, 44 },
183 { "firebrick3", 205, 38, 38 },
184 { "firebrick4", 139, 26, 26 },
185 { "floral white", 255, 250, 240 },
186 { "FloralWhite", 255, 250, 240 },
187 { "forest green", 34, 139, 34 },
188 { "ForestGreen", 34, 139, 34 },
189 { "gainsboro", 220, 220, 220 },
190 { "ghost white", 248, 248, 255 },
191 { "GhostWhite", 248, 248, 255 },
192 { "gold", 255, 215, 0 },
193 { "gold1", 255, 215, 0 },
194 { "gold2", 238, 201, 0 },
195 { "gold3", 205, 173, 0 },
196 { "gold4", 139, 117, 0 },
197 { "goldenrod", 218, 165, 32 },
198 { "goldenrod1", 255, 193, 37 },
199 { "goldenrod2", 238, 180, 34 },
200 { "goldenrod3", 205, 155, 29 },
201 { "goldenrod4", 139, 105, 20 },
202 { "gray", 190, 190, 190 },
203 { "gray0", 0, 0, 0 },
204 { "gray1", 3, 3, 3 },
205 { "gray2", 5, 5, 5 },
206 { "gray3", 8, 8, 8 },
207 { "gray4", 10, 10, 10 },
208 { "gray5", 13, 13, 13 },
209 { "gray6", 15, 15, 15 },
210 { "gray7", 18, 18, 18 },
211 { "gray8", 20, 20, 20 },
212 { "gray9", 23, 23, 23 },
213 { "gray10", 26, 26, 26 },
214 { "gray11", 28, 28, 28 },
215 { "gray12", 31, 31, 31 },
216 { "gray13", 33, 33, 33 },
217 { "gray14", 36, 36, 36 },
218 { "gray15", 38, 38, 38 },
219 { "gray16", 41, 41, 41 },
220 { "gray17", 43, 43, 43 },
221 { "gray18", 46, 46, 46 },
222 { "gray19", 48, 48, 48 },
223 { "gray20", 51, 51, 51 },
224 { "gray21", 54, 54, 54 },
225 { "gray22", 56, 56, 56 },
226 { "gray23", 59, 59, 59 },
227 { "gray24", 61, 61, 61 },
228 { "gray25", 64, 64, 64 },
229 { "gray26", 66, 66, 66 },
230 { "gray27", 69, 69, 69 },
231 { "gray28", 71, 71, 71 },
232 { "gray29", 74, 74, 74 },
233 { "gray30", 77, 77, 77 },
234 { "gray31", 79, 79, 79 },
235 { "gray32", 82, 82, 82 },
236 { "gray33", 84, 84, 84 },
237 { "gray34", 87, 87, 87 },
238 { "gray35", 89, 89, 89 },
239 { "gray36", 92, 92, 92 },
240 { "gray37", 94, 94, 94 },
241 { "gray38", 97, 97, 97 },
242 { "gray39", 99, 99, 99 },
243 { "gray40", 102, 102, 102 },
244 { "gray41", 105, 105, 105 },
245 { "gray42", 107, 107, 107 },
246 { "gray43", 110, 110, 110 },
247 { "gray44", 112, 112, 112 },
248 { "gray45", 115, 115, 115 },
249 { "gray46", 117, 117, 117 },
250 { "gray47", 120, 120, 120 },
251 { "gray48", 122, 122, 122 },
252 { "gray49", 125, 125, 125 },
253 { "gray50", 127, 127, 127 },
254 { "gray51", 130, 130, 130 },
255 { "gray52", 133, 133, 133 },
256 { "gray53", 135, 135, 135 },
257 { "gray54", 138, 138, 138 },
258 { "gray55", 140, 140, 140 },
259 { "gray56", 143, 143, 143 },
260 { "gray57", 145, 145, 145 },
261 { "gray58", 148, 148, 148 },
262 { "gray59", 150, 150, 150 },
263 { "gray60", 153, 153, 153 },
264 { "gray61", 156, 156, 156 },
265 { "gray62", 158, 158, 158 },
266 { "gray63", 161, 161, 161 },
267 { "gray64", 163, 163, 163 },
268 { "gray65", 166, 166, 166 },
269 { "gray66", 168, 168, 168 },
270 { "gray67", 171, 171, 171 },
271 { "gray68", 173, 173, 173 },
272 { "gray69", 176, 176, 176 },
273 { "gray70", 179, 179, 179 },
274 { "gray71", 181, 181, 181 },
275 { "gray72", 184, 184, 184 },
276 { "gray73", 186, 186, 186 },
277 { "gray74", 189, 189, 189 },
278 { "gray75", 191, 191, 191 },
279 { "gray76", 194, 194, 194 },
280 { "gray77", 196, 196, 196 },
281 { "gray78", 199, 199, 199 },
282 { "gray79", 201, 201, 201 },
283 { "gray80", 204, 204, 204 },
284 { "gray81", 207, 207, 207 },
285 { "gray82", 209, 209, 209 },
286 { "gray83", 212, 212, 212 },
287 { "gray84", 214, 214, 214 },
288 { "gray85", 217, 217, 217 },
289 { "gray86", 219, 219, 219 },
290 { "gray87", 222, 222, 222 },
291 { "gray88", 224, 224, 224 },
292 { "gray89", 227, 227, 227 },
293 { "gray90", 229, 229, 229 },
294 { "gray91", 232, 232, 232 },
295 { "gray92", 235, 235, 235 },
296 { "gray93", 237, 237, 237 },
297 { "gray94", 240, 240, 240 },
298 { "gray95", 242, 242, 242 },
299 { "gray96", 245, 245, 245 },
300 { "gray97", 247, 247, 247 },
301 { "gray98", 250, 250, 250 },
302 { "gray99", 252, 252, 252 },
303 { "gray100", 255, 255, 255 },
304 { "green", 0, 255, 0 },
305 { "green yellow", 173, 255, 47 },
306 { "green1", 0, 255, 0 },
307 { "green2", 0, 238, 0 },
308 { "green3", 0, 205, 0 },
309 { "green4", 0, 139, 0 },
310 { "GreenYellow", 173, 255, 47 },
311 { "grey", 190, 190, 190 },
312 { "grey0", 0, 0, 0 },
313 { "grey1", 3, 3, 3 },
314 { "grey2", 5, 5, 5 },
315 { "grey3", 8, 8, 8 },
316 { "grey4", 10, 10, 10 },
317 { "grey5", 13, 13, 13 },
318 { "grey6", 15, 15, 15 },
319 { "grey7", 18, 18, 18 },
320 { "grey8", 20, 20, 20 },
321 { "grey9", 23, 23, 23 },
322 { "grey10", 26, 26, 26 },
323 { "grey11", 28, 28, 28 },
324 { "grey12", 31, 31, 31 },
325 { "grey13", 33, 33, 33 },
326 { "grey14", 36, 36, 36 },
327 { "grey15", 38, 38, 38 },
328 { "grey16", 41, 41, 41 },
329 { "grey17", 43, 43, 43 },
330 { "grey18", 46, 46, 46 },
331 { "grey19", 48, 48, 48 },
332 { "grey20", 51, 51, 51 },
333 { "grey21", 54, 54, 54 },
334 { "grey22", 56, 56, 56 },
335 { "grey23", 59, 59, 59 },
336 { "grey24", 61, 61, 61 },
337 { "grey25", 64, 64, 64 },
338 { "grey26", 66, 66, 66 },
339 { "grey27", 69, 69, 69 },
340 { "grey28", 71, 71, 71 },
341 { "grey29", 74, 74, 74 },
342 { "grey30", 77, 77, 77 },
343 { "grey31", 79, 79, 79 },
344 { "grey32", 82, 82, 82 },
345 { "grey33", 84, 84, 84 },
346 { "grey34", 87, 87, 87 },
347 { "grey35", 89, 89, 89 },
348 { "grey36", 92, 92, 92 },
349 { "grey37", 94, 94, 94 },
350 { "grey38", 97, 97, 97 },
351 { "grey39", 99, 99, 99 },
352 { "grey40", 102, 102, 102 },
353 { "grey41", 105, 105, 105 },
354 { "grey42", 107, 107, 107 },
355 { "grey43", 110, 110, 110 },
356 { "grey44", 112, 112, 112 },
357 { "grey45", 115, 115, 115 },
358 { "grey46", 117, 117, 117 },
359 { "grey47", 120, 120, 120 },
360 { "grey48", 122, 122, 122 },
361 { "grey49", 125, 125, 125 },
362 { "grey50", 127, 127, 127 },
363 { "grey51", 130, 130, 130 },
364 { "grey52", 133, 133, 133 },
365 { "grey53", 135, 135, 135 },
366 { "grey54", 138, 138, 138 },
367 { "grey55", 140, 140, 140 },
368 { "grey56", 143, 143, 143 },
369 { "grey57", 145, 145, 145 },
370 { "grey58", 148, 148, 148 },
371 { "grey59", 150, 150, 150 },
372 { "grey60", 153, 153, 153 },
373 { "grey61", 156, 156, 156 },
374 { "grey62", 158, 158, 158 },
375 { "grey63", 161, 161, 161 },
376 { "grey64", 163, 163, 163 },
377 { "grey65", 166, 166, 166 },
378 { "grey66", 168, 168, 168 },
379 { "grey67", 171, 171, 171 },
380 { "grey68", 173, 173, 173 },
381 { "grey69", 176, 176, 176 },
382 { "grey70", 179, 179, 179 },
383 { "grey71", 181, 181, 181 },
384 { "grey72", 184, 184, 184 },
385 { "grey73", 186, 186, 186 },
386 { "grey74", 189, 189, 189 },
387 { "grey75", 191, 191, 191 },
388 { "grey76", 194, 194, 194 },
389 { "grey77", 196, 196, 196 },
390 { "grey78", 199, 199, 199 },
391 { "grey79", 201, 201, 201 },
392 { "grey80", 204, 204, 204 },
393 { "grey81", 207, 207, 207 },
394 { "grey82", 209, 209, 209 },
395 { "grey83", 212, 212, 212 },
396 { "grey84", 214, 214, 214 },
397 { "grey85", 217, 217, 217 },
398 { "grey86", 219, 219, 219 },
399 { "grey87", 222, 222, 222 },
400 { "grey88", 224, 224, 224 },
401 { "grey89", 227, 227, 227 },
402 { "grey90", 229, 229, 229 },
403 { "grey91", 232, 232, 232 },
404 { "grey92", 235, 235, 235 },
405 { "grey93", 237, 237, 237 },
406 { "grey94", 240, 240, 240 },
407 { "grey95", 242, 242, 242 },
408 { "grey96", 245, 245, 245 },
409 { "grey97", 247, 247, 247 },
410 { "grey98", 250, 250, 250 },
411 { "grey99", 252, 252, 252 },
412 { "grey100", 255, 255, 255 },
413 { "honeydew", 240, 255, 240 },
414 { "honeydew1", 240, 255, 240 },
415 { "honeydew2", 224, 238, 224 },
416 { "honeydew3", 193, 205, 193 },
417 { "honeydew4", 131, 139, 131 },
418 { "hot pink", 255, 105, 180 },
419 { "HotPink", 255, 105, 180 },
420 { "HotPink1", 255, 110, 180 },
421 { "HotPink2", 238, 106, 167 },
422 { "HotPink3", 205, 96, 144 },
423 { "HotPink4", 139, 58, 98 },
424 { "indian red", 205, 92, 92 },
425 { "IndianRed", 205, 92, 92 },
426 { "IndianRed1", 255, 106, 106 },
427 { "IndianRed2", 238, 99, 99 },
428 { "IndianRed3", 205, 85, 85 },
429 { "IndianRed4", 139, 58, 58 },
430 { "ivory", 255, 255, 240 },
431 { "ivory1", 255, 255, 240 },
432 { "ivory2", 238, 238, 224 },
433 { "ivory3", 205, 205, 193 },
434 { "ivory4", 139, 139, 131 },
435 { "khaki", 240, 230, 140 },
436 { "khaki1", 255, 246, 143 },
437 { "khaki2", 238, 230, 133 },
438 { "khaki3", 205, 198, 115 },
439 { "khaki4", 139, 134, 78 },
440 { "lavender", 230, 230, 250 },
441 { "lavender blush", 255, 240, 245 },
442 { "LavenderBlush", 255, 240, 245 },
443 { "LavenderBlush1", 255, 240, 245 },
444 { "LavenderBlush2", 238, 224, 229 },
445 { "LavenderBlush3", 205, 193, 197 },
446 { "LavenderBlush4", 139, 131, 134 },
447 { "lawn green", 124, 252, 0 },
448 { "LawnGreen", 124, 252, 0 },
449 { "lemon chiffon", 255, 250, 205 },
450 { "LemonChiffon", 255, 250, 205 },
451 { "LemonChiffon1", 255, 250, 205 },
452 { "LemonChiffon2", 238, 233, 191 },
453 { "LemonChiffon3", 205, 201, 165 },
454 { "LemonChiffon4", 139, 137, 112 },
455 { "light blue", 173, 216, 230 },
456 { "light coral", 240, 128, 128 },
457 { "light cyan", 224, 255, 255 },
458 { "light goldenrod", 238, 221, 130 },
459 { "light goldenrod yellow", 250, 250, 210 },
460 { "light gray", 211, 211, 211 },
461 { "light green", 144, 238, 144 },
462 { "light grey", 211, 211, 211 },
463 { "light pink", 255, 182, 193 },
464 { "light salmon", 255, 160, 122 },
465 { "light sea green", 32, 178, 170 },
466 { "light sky blue", 135, 206, 250 },
467 { "light slate blue", 132, 112, 255 },
468 { "light slate gray", 119, 136, 153 },
469 { "light slate grey", 119, 136, 153 },
470 { "light steel blue", 176, 196, 222 },
471 { "light yellow", 255, 255, 224 },
472 { "LightBlue", 173, 216, 230 },
473 { "LightBlue1", 191, 239, 255 },
474 { "LightBlue2", 178, 223, 238 },
475 { "LightBlue3", 154, 192, 205 },
476 { "LightBlue4", 104, 131, 139 },
477 { "LightCoral", 240, 128, 128 },
478 { "LightCyan", 224, 255, 255 },
479 { "LightCyan1", 224, 255, 255 },
480 { "LightCyan2", 209, 238, 238 },
481 { "LightCyan3", 180, 205, 205 },
482 { "LightCyan4", 122, 139, 139 },
483 { "LightGoldenrod", 238, 221, 130 },
484 { "LightGoldenrod1", 255, 236, 139 },
485 { "LightGoldenrod2", 238, 220, 130 },
486 { "LightGoldenrod3", 205, 190, 112 },
487 { "LightGoldenrod4", 139, 129, 76 },
488 { "LightGoldenrodYellow", 250, 250, 210 },
489 { "LightGray", 211, 211, 211 },
490 { "LightGreen", 144, 238, 144 },
491 { "LightGrey", 211, 211, 211 },
492 { "LightPink", 255, 182, 193 },
493 { "LightPink1", 255, 174, 185 },
494 { "LightPink2", 238, 162, 173 },
495 { "LightPink3", 205, 140, 149 },
496 { "LightPink4", 139, 95, 101 },
497 { "LightSalmon", 255, 160, 122 },
498 { "LightSalmon1", 255, 160, 122 },
499 { "LightSalmon2", 238, 149, 114 },
500 { "LightSalmon3", 205, 129, 98 },
501 { "LightSalmon4", 139, 87, 66 },
502 { "LightSeaGreen", 32, 178, 170 },
503 { "LightSkyBlue", 135, 206, 250 },
504 { "LightSkyBlue1", 176, 226, 255 },
505 { "LightSkyBlue2", 164, 211, 238 },
506 { "LightSkyBlue3", 141, 182, 205 },
507 { "LightSkyBlue4", 96, 123, 139 },
508 { "LightSlateBlue", 132, 112, 255 },
509 { "LightSlateGray", 119, 136, 153 },
510 { "LightSlateGrey", 119, 136, 153 },
511 { "LightSteelBlue", 176, 196, 222 },
512 { "LightSteelBlue1", 202, 225, 255 },
513 { "LightSteelBlue2", 188, 210, 238 },
514 { "LightSteelBlue3", 162, 181, 205 },
515 { "LightSteelBlue4", 110, 123, 139 },
516 { "LightYellow", 255, 255, 224 },
517 { "LightYellow1", 255, 255, 224 },
518 { "LightYellow2", 238, 238, 209 },
519 { "LightYellow3", 205, 205, 180 },
520 { "LightYellow4", 139, 139, 122 },
521 { "lime green", 50, 205, 50 },
522 { "LimeGreen", 50, 205, 50 },
523 { "linen", 250, 240, 230 },
524 { "magenta", 255, 0, 255 },
525 { "magenta1", 255, 0, 255 },
526 { "magenta2", 238, 0, 238 },
527 { "magenta3", 205, 0, 205 },
528 { "magenta4", 139, 0, 139 },
529 { "maroon", 176, 48, 96 },
530 { "maroon1", 255, 52, 179 },
531 { "maroon2", 238, 48, 167 },
532 { "maroon3", 205, 41, 144 },
533 { "maroon4", 139, 28, 98 },
534 { "medium aquamarine", 102, 205, 170 },
535 { "medium blue", 0, 0, 205 },
536 { "medium orchid", 186, 85, 211 },
537 { "medium purple", 147, 112, 219 },
538 { "medium sea green", 60, 179, 113 },
539 { "medium slate blue", 123, 104, 238 },
540 { "medium spring green", 0, 250, 154 },
541 { "medium turquoise", 72, 209, 204 },
542 { "medium violet red", 199, 21, 133 },
543 { "MediumAquamarine", 102, 205, 170 },
544 { "MediumBlue", 0, 0, 205 },
545 { "MediumOrchid", 186, 85, 211 },
546 { "MediumOrchid1", 224, 102, 255 },
547 { "MediumOrchid2", 209, 95, 238 },
548 { "MediumOrchid3", 180, 82, 205 },
549 { "MediumOrchid4", 122, 55, 139 },
550 { "MediumPurple", 147, 112, 219 },
551 { "MediumPurple1", 171, 130, 255 },
552 { "MediumPurple2", 159, 121, 238 },
553 { "MediumPurple3", 137, 104, 205 },
554 { "MediumPurple4", 93, 71, 139 },
555 { "MediumSeaGreen", 60, 179, 113 },
556 { "MediumSlateBlue", 123, 104, 238 },
557 { "MediumSpringGreen", 0, 250, 154 },
558 { "MediumTurquoise", 72, 209, 204 },
559 { "MediumVioletRed", 199, 21, 133 },
560 { "midnight blue", 25, 25, 112 },
561 { "MidnightBlue", 25, 25, 112 },
562 { "mint cream", 245, 255, 250 },
563 { "MintCream", 245, 255, 250 },
564 { "misty rose", 255, 228, 225 },
565 { "MistyRose", 255, 228, 225 },
566 { "MistyRose1", 255, 228, 225 },
567 { "MistyRose2", 238, 213, 210 },
568 { "MistyRose3", 205, 183, 181 },
569 { "MistyRose4", 139, 125, 123 },
570 { "moccasin", 255, 228, 181 },
571 { "navajo white", 255, 222, 173 },
572 { "NavajoWhite", 255, 222, 173 },
573 { "NavajoWhite1", 255, 222, 173 },
574 { "NavajoWhite2", 238, 207, 161 },
575 { "NavajoWhite3", 205, 179, 139 },
576 { "NavajoWhite4", 139, 121, 94 },
577 { "navy", 0, 0, 128 },
578 { "navy blue", 0, 0, 128 },
579 { "NavyBlue", 0, 0, 128 },
580 { "old lace", 253, 245, 230 },
581 { "OldLace", 253, 245, 230 },
582 { "olive drab", 107, 142, 35 },
583 { "OliveDrab", 107, 142, 35 },
584 { "OliveDrab1", 192, 255, 62 },
585 { "OliveDrab2", 179, 238, 58 },
586 { "OliveDrab3", 154, 205, 50 },
587 { "OliveDrab4", 105, 139, 34 },
588 { "orange", 255, 165, 0 },
589 { "orange red", 255, 69, 0 },
590 { "orange1", 255, 165, 0 },
591 { "orange2", 238, 154, 0 },
592 { "orange3", 205, 133, 0 },
593 { "orange4", 139, 90, 0 },
594 { "OrangeRed", 255, 69, 0 },
595 { "OrangeRed1", 255, 69, 0 },
596 { "OrangeRed2", 238, 64, 0 },
597 { "OrangeRed3", 205, 55, 0 },
598 { "OrangeRed4", 139, 37, 0 },
599 { "orchid", 218, 112, 214 },
600 { "orchid1", 255, 131, 250 },
601 { "orchid2", 238, 122, 233 },
602 { "orchid3", 205, 105, 201 },
603 { "orchid4", 139, 71, 137 },
604 { "pale goldenrod", 238, 232, 170 },
605 { "pale green", 152, 251, 152 },
606 { "pale turquoise", 175, 238, 238 },
607 { "pale violet red", 219, 112, 147 },
608 { "PaleGoldenrod", 238, 232, 170 },
609 { "PaleGreen", 152, 251, 152 },
610 { "PaleGreen1", 154, 255, 154 },
611 { "PaleGreen2", 144, 238, 144 },
612 { "PaleGreen3", 124, 205, 124 },
613 { "PaleGreen4", 84, 139, 84 },
614 { "PaleTurquoise", 175, 238, 238 },
615 { "PaleTurquoise1", 187, 255, 255 },
616 { "PaleTurquoise2", 174, 238, 238 },
617 { "PaleTurquoise3", 150, 205, 205 },
618 { "PaleTurquoise4", 102, 139, 139 },
619 { "PaleVioletRed", 219, 112, 147 },
620 { "PaleVioletRed1", 255, 130, 171 },
621 { "PaleVioletRed2", 238, 121, 159 },
622 { "PaleVioletRed3", 205, 104, 127 },
623 { "PaleVioletRed4", 139, 71, 93 },
624 { "papaya whip", 255, 239, 213 },
625 { "PapayaWhip", 255, 239, 213 },
626 { "peach puff", 255, 218, 185 },
627 { "PeachPuff", 255, 218, 185 },
628 { "PeachPuff1", 255, 218, 185 },
629 { "PeachPuff2", 238, 203, 173 },
630 { "PeachPuff3", 205, 175, 149 },
631 { "PeachPuff4", 139, 119, 101 },
632 { "peru", 205, 133, 63 },
633 { "pink", 255, 192, 203 },
634 { "pink1", 255, 181, 197 },
635 { "pink2", 238, 169, 184 },
636 { "pink3", 205, 145, 158 },
637 { "pink4", 139, 99, 108 },
638 { "plum", 221, 160, 221 },
639 { "plum1", 255, 187, 255 },
640 { "plum2", 238, 174, 238 },
641 { "plum3", 205, 150, 205 },
642 { "plum4", 139, 102, 139 },
643 { "powder blue", 176, 224, 230 },
644 { "PowderBlue", 176, 224, 230 },
645 { "purple", 160, 32, 240 },
646 { "purple1", 155, 48, 255 },
647 { "purple2", 145, 44, 238 },
648 { "purple3", 125, 38, 205 },
649 { "purple4", 85, 26, 139 },
650 { "red", 255, 0, 0 },
651 { "red1", 255, 0, 0 },
652 { "red2", 238, 0, 0 },
653 { "red3", 205, 0, 0 },
654 { "red4", 139, 0, 0 },
655 { "rosy brown", 188, 143, 143 },
656 { "RosyBrown", 188, 143, 143 },
657 { "RosyBrown1", 255, 193, 193 },
658 { "RosyBrown2", 238, 180, 180 },
659 { "RosyBrown3", 205, 155, 155 },
660 { "RosyBrown4", 139, 105, 105 },
661 { "royal blue", 65, 105, 225 },
662 { "RoyalBlue", 65, 105, 225 },
663 { "RoyalBlue1", 72, 118, 255 },
664 { "RoyalBlue2", 67, 110, 238 },
665 { "RoyalBlue3", 58, 95, 205 },
666 { "RoyalBlue4", 39, 64, 139 },
667 { "saddle brown", 139, 69, 19 },
668 { "SaddleBrown", 139, 69, 19 },
669 { "salmon", 250, 128, 114 },
670 { "salmon1", 255, 140, 105 },
671 { "salmon2", 238, 130, 98 },
672 { "salmon3", 205, 112, 84 },
673 { "salmon4", 139, 76, 57 },
674 { "sandy brown", 244, 164, 96 },
675 { "SandyBrown", 244, 164, 96 },
676 { "sea green", 46, 139, 87 },
677 { "SeaGreen", 46, 139, 87 },
678 { "SeaGreen1", 84, 255, 159 },
679 { "SeaGreen2", 78, 238, 148 },
680 { "SeaGreen3", 67, 205, 128 },
681 { "SeaGreen4", 46, 139, 87 },
682 { "seashell", 255, 245, 238 },
683 { "seashell1", 255, 245, 238 },
684 { "seashell2", 238, 229, 222 },
685 { "seashell3", 205, 197, 191 },
686 { "seashell4", 139, 134, 130 },
687 { "sienna", 160, 82, 45 },
688 { "sienna1", 255, 130, 71 },
689 { "sienna2", 238, 121, 66 },
690 { "sienna3", 205, 104, 57 },
691 { "sienna4", 139, 71, 38 },
692 { "sky blue", 135, 206, 235 },
693 { "SkyBlue", 135, 206, 235 },
694 { "SkyBlue1", 135, 206, 255 },
695 { "SkyBlue2", 126, 192, 238 },
696 { "SkyBlue3", 108, 166, 205 },
697 { "SkyBlue4", 74, 112, 139 },
698 { "slate blue", 106, 90, 205 },
699 { "slate gray", 112, 128, 144 },
700 { "slate grey", 112, 128, 144 },
701 { "SlateBlue", 106, 90, 205 },
702 { "SlateBlue1", 131, 111, 255 },
703 { "SlateBlue2", 122, 103, 238 },
704 { "SlateBlue3", 105, 89, 205 },
705 { "SlateBlue4", 71, 60, 139 },
706 { "SlateGray", 112, 128, 144 },
707 { "SlateGray1", 198, 226, 255 },
708 { "SlateGray2", 185, 211, 238 },
709 { "SlateGray3", 159, 182, 205 },
710 { "SlateGray4", 108, 123, 139 },
711 { "SlateGrey", 112, 128, 144 },
712 { "snow", 255, 250, 250 },
713 { "snow1", 255, 250, 250 },
714 { "snow2", 238, 233, 233 },
715 { "snow3", 205, 201, 201 },
716 { "snow4", 139, 137, 137 },
717 { "spring green", 0, 255, 127 },
718 { "SpringGreen", 0, 255, 127 },
719 { "SpringGreen1", 0, 255, 127 },
720 { "SpringGreen2", 0, 238, 118 },
721 { "SpringGreen3", 0, 205, 102 },
722 { "SpringGreen4", 0, 139, 69 },
723 { "steel blue", 70, 130, 180 },
724 { "SteelBlue", 70, 130, 180 },
725 { "SteelBlue1", 99, 184, 255 },
726 { "SteelBlue2", 92, 172, 238 },
727 { "SteelBlue3", 79, 148, 205 },
728 { "SteelBlue4", 54, 100, 139 },
729 { "tan", 210, 180, 140 },
730 { "tan1", 255, 165, 79 },
731 { "tan2", 238, 154, 73 },
732 { "tan3", 205, 133, 63 },
733 { "tan4", 139, 90, 43 },
734 { "thistle", 216, 191, 216 },
735 { "thistle1", 255, 225, 255 },
736 { "thistle2", 238, 210, 238 },
737 { "thistle3", 205, 181, 205 },
738 { "thistle4", 139, 123, 139 },
739 { "tomato", 255, 99, 71 },
740 { "tomato1", 255, 99, 71 },
741 { "tomato2", 238, 92, 66 },
742 { "tomato3", 205, 79, 57 },
743 { "tomato4", 139, 54, 38 },
744 { "turquoise", 64, 224, 208 },
745 { "turquoise1", 0, 245, 255 },
746 { "turquoise2", 0, 229, 238 },
747 { "turquoise3", 0, 197, 205 },
748 { "turquoise4", 0, 134, 139 },
749 { "violet", 238, 130, 238 },
750 { "violet red", 208, 32, 144 },
751 { "VioletRed", 208, 32, 144 },
752 { "VioletRed1", 255, 62, 150 },
753 { "VioletRed2", 238, 58, 140 },
754 { "VioletRed3", 205, 50, 120 },
755 { "VioletRed4", 139, 34, 82 },
756 { "wheat", 245, 222, 179 },
757 { "wheat1", 255, 231, 186 },
758 { "wheat2", 238, 216, 174 },
759 { "wheat3", 205, 186, 150 },
760 { "wheat4", 139, 126, 102 },
761 { "white", 255, 255, 255 },
762 { "white smoke", 245, 245, 245 },
763 { "WhiteSmoke", 245, 245, 245 },
764 { "yellow", 255, 255, 0 },
765 { "yellow green", 154, 205, 50 },
766 { "yellow1", 255, 255, 0 },
767 { "yellow2", 238, 238, 0 },
768 { "yellow3", 205, 205, 0 },
769 { "yellow4", 139, 139, 0 },
770 { "YellowGreen", 154, 205, 50 },
771 { NULL, 0, 0, 0 }
772 };
773
774 /* Find a SDL color by name in the given lookup table. */
775
776 int
find_sdl_color_by_name(char * name,RGBColorTableEntry * table,SDL_Color * color)777 find_sdl_color_by_name(char *name, RGBColorTableEntry *table, SDL_Color *color)
778 {
779 int i = 0;
780 ImageFamily *imf = NULL;
781 Image *img = NULL;
782 int r = -1, g = -1, b = -1, dum = -1;
783
784 /* Sanity checks. */
785 assert_error(color, "Attempted to find an unallocated color");
786 assert_error(table, "Attempted to find a color in a NULL color table");
787 /* Warn and then return black, if color name is unspecified. */
788 if (!name) {
789 assert_warning(name, "Attempted to lookup an unspecifed color name");
790 memset(color, 0, sizeof(SDL_Color));
791 return FALSE;
792 }
793 /* Lookup the color by name in the provided table. */
794 for (i = 0; table[i].name; ++i) {
795 if (!strcmp(name, table[i].name)) {
796 color->r = table[i].r;
797 color->g = table[i].g;
798 color->b = table[i].b;
799 return TRUE;
800 }
801 }
802 /* Lookup the color if an IMF name matches it. */
803 /* (This code stolen and adapted from Tkconq's 'request_color' function.) */
804 imf = get_generic_images(name);
805 if (imf != NULL
806 && imf->numsizes > 0
807 && imf->images != NULL
808 && imf->images->w == 1
809 && imf->images->h == 1
810 && imf->images->palette != lispnil) {
811 img = imf->images;
812 parse_lisp_palette_entry(car(img->palette), &dum, &r, &g, &b);
813 color->r = (Uint8)r; color->g = (Uint8)g; color->b = (Uint8)b;
814 }
815 return FALSE;
816 }
817
818 /* Find a RGB triplet by name in the given lookup table. */
819
820 int
find_rgb_triplet_by_name(char * name,RGBColorTableEntry * table,Uint8 * r,Uint8 * g,Uint8 * b)821 find_rgb_triplet_by_name(char *name, RGBColorTableEntry *table,
822 Uint8 *r, Uint8 *g, Uint8 *b)
823 {
824 SDL_Color color;
825 int retval = FALSE;
826
827 /* Sanity checks. */
828 assert_error(r && g && b, "Attempted to find an unallocated color");
829 assert_error(table, "Attempted to find a color in a NULL color table");
830 /* Set color to black, in case of failure. */
831 *r = *g = *b = 0;
832 /* Grab an SDL color, and fill out the triplet from it. */
833 retval = find_sdl_color_by_name(name, table, &color);
834 if (retval) {
835 *r = color.r;
836 *g = color.g;
837 *b = color.b;
838 }
839 return retval;
840 }
841