1 /* GNUPLOT - tables.c */
2
3 /*[
4 * Copyright 1999, 2004 Lars Hecking
5 *
6 * Permission to use, copy, and distribute this software and its
7 * documentation for any purpose with or without fee is hereby granted,
8 * provided that the above copyright notice appear in all copies and
9 * that both that copyright notice and this permission notice appear
10 * in supporting documentation.
11 *
12 * Permission to modify the software is granted, but not the right to
13 * distribute the complete modified source code. Modifications are to
14 * be distributed as patches to the released version. Permission to
15 * distribute binaries produced by compiling modified sources is granted,
16 * provided you
17 * 1. distribute the corresponding source modifications from the
18 * released version in the form of a patch file along with the binaries,
19 * 2. add special version identification to distinguish your version
20 * in addition to the base release version number,
21 * 3. provide your name and address as the primary contact for the
22 * support of your modified version, and
23 * 4. retain our contact information in regard to use of the base
24 * software.
25 * Permission to distribute the released version of the source code along
26 * with corresponding source modifications in the form of a patch file is
27 * granted with same provisions 2 through 4 for binary distributions.
28 *
29 * This software is provided "as is" without express or implied warranty
30 * to the extent permitted by applicable law.
31 ]*/
32
33 #include "tables.h"
34
35 #include "command.h"
36 #include "datablock.h"
37 #include "fit.h"
38 #include "setshow.h"
39 #include "term_api.h"
40 #include "util.h"
41 #include "alloc.h" /* for init_colornames() */
42 #include "graph3d.h" /* for DGRID3D_* options */
43 # include "getcolor.h"
44
45 /* gnuplot commands */
46
47 /* the actual commands */
48 const struct gen_ftable command_ftbl[] =
49 {
50 { "ra$ise", raise_command },
51 { "low$er", lower_command },
52 #ifdef USE_MOUSE
53 { "bi$nd", bind_command },
54 #endif
55 { "array", array_command },
56 { "break", break_command },
57 { "ca$ll", call_command },
58 { "cd", changedir_command },
59 { "cl$ear", clear_command },
60 { "continue", continue_command },
61 { "do", do_command },
62 { "eval$uate", eval_command },
63 { "ex$it", exit_command },
64 { "f$it", fit_command },
65 { "h$elp", help_command },
66 { "?", help_command },
67 { "hi$story", history_command },
68 { "if", if_command },
69 { "import", import_command },
70 { "else", else_command },
71 { "l$oad", load_command },
72 { "pa$use", pause_command },
73 { "p$lot", plot_command },
74 { "pr$int", print_command },
75 { "printerr$or", printerr_command },
76 { "pwd", pwd_command },
77 { "q$uit", exit_command },
78 { "ref$resh", refresh_command },
79 { "rep$lot", replot_command },
80 { "re$read", reread_command },
81 { "res$et", reset_command },
82 { "sa$ve", save_command },
83 { "scr$eendump", screendump_command },
84 { "se$t", set_command },
85 { "she$ll", do_shell },
86 { "sh$ow", show_command },
87 { "sp$lot", splot_command },
88 { "st$ats", stats_command },
89 { "sy$stem", system_command },
90 { "test", test_command },
91 { "tog$gle", toggle_command },
92 { "und$efine", undefine_command },
93 { "uns$et", unset_command },
94 { "up$date", update_command },
95 { "while", while_command },
96 { "{", begin_clause },
97 { "}", end_clause },
98 { ";", null_command },
99 { "$", datablock_command },
100 /* last key must be NULL */
101 { NULL, invalid_command }
102 };
103
104 /* 'plot ax[ei]s' parameter */
105 const struct gen_table plot_axes_tbl[] =
106 {
107 { "x1y1", AXES_X1Y1 },
108 { "x2y2", AXES_X2Y2 },
109 { "x1y2", AXES_X1Y2 },
110 { "x2y1", AXES_X2Y1 },
111 { NULL, AXES_NONE }
112 };
113
114 /* 'plot smooth' parameter */
115 const struct gen_table plot_smooth_tbl[] =
116 {
117 { "a$csplines", SMOOTH_ACSPLINES },
118 { "bins", SMOOTH_BINS },
119 { "b$ezier", SMOOTH_BEZIER },
120 { "c$splines", SMOOTH_CSPLINES },
121 { "s$bezier", SMOOTH_SBEZIER },
122 { "u$nique", SMOOTH_UNIQUE },
123 { "unwrap", SMOOTH_UNWRAP },
124 { "f$requency", SMOOTH_FREQUENCY },
125 { "cum$ulative", SMOOTH_CUMULATIVE },
126 { "k$density", SMOOTH_KDENSITY },
127 { "cn$ormal", SMOOTH_CUMULATIVE_NORMALISED },
128 { "mcs$plines", SMOOTH_MONOTONE_CSPLINE },
129 { "fnor$mal", SMOOTH_FREQUENCY_NORMALISED },
130 { NULL, SMOOTH_NONE }
131 };
132
133 /* dgrid3d modes */
134 const struct gen_table dgrid3d_mode_tbl[] =
135 {
136 { "qnorm", DGRID3D_QNORM },
137 { "spline$s", DGRID3D_SPLINES },
138 { "gauss", DGRID3D_GAUSS },
139 { "exp", DGRID3D_EXP },
140 { "cauchy", DGRID3D_CAUCHY },
141 { "box", DGRID3D_BOX },
142 { "hann", DGRID3D_HANN },
143 { NULL, DGRID3D_OTHER }
144 };
145
146 /* 'save' command */
147 const struct gen_table save_tbl[] =
148 {
149 { "fit", SAVE_FIT },
150 { "fun$ctions", SAVE_FUNCS },
151 { "set", SAVE_SET },
152 { "ter$minal", SAVE_TERMINAL },
153 { "var$iables", SAVE_VARS },
154 { NULL, SAVE_INVALID }
155 };
156
157 /* 'set' and 'show' commands */
158 const struct gen_table set_tbl[] =
159 {
160 { "a$ll", S_ALL },
161 { "ac$tion_table", S_ACTIONTABLE },
162 { "at", S_ACTIONTABLE },
163 { "an$gles", S_ANGLES },
164 { "ar$row", S_ARROW },
165 { "au$toscale", S_AUTOSCALE },
166 { "b$ars", S_BARS },
167 { "bind", S_BIND },
168 { "bor$der", S_BORDER },
169 { "box$width", S_BOXWIDTH },
170 { "cl$abel", S_CLABEL },
171 { "c$lip", S_CLIP },
172 { "cntrp$aram", S_CNTRPARAM },
173 { "cntrl$abel", S_CNTRLABEL },
174 { "cont$ours", S_CONTOUR },
175 { "dasht$ype", S_DASHTYPE },
176 { "dt", S_DASHTYPE },
177 { "da$ta", S_DATA },
178
179 { "data$file", S_DATAFILE },
180
181 { "dg$rid3d", S_DGRID3D },
182 { "du$mmy", S_DUMMY },
183 { "enc$oding", S_ENCODING },
184 { "dec$imalsign", S_DECIMALSIGN },
185 { "errorbars", S_BARS },
186 { "fit", S_FIT },
187 { "font$path", S_FONTPATH },
188 { "fo$rmat", S_FORMAT },
189 { "fu$nction", S_FUNCTIONS },
190 { "fu$nctions", S_FUNCTIONS },
191 { "g$rid", S_GRID },
192 { "hid$den3d", S_HIDDEN3D },
193 { "historysize", S_HISTORYSIZE }, /* Deprecated */
194 { "his$tory", S_HISTORY },
195 { "is$osamples", S_ISOSAMPLES },
196 { "jitter", S_JITTER },
197 { "k$ey", S_KEY },
198 { "keyt$itle", S_KEY },
199 { "la$bel", S_LABEL },
200 { "link", S_LINK },
201 { "lines$tyle", S_LINESTYLE },
202 { "linetype$s", S_LINETYPE },
203 { "ls", S_LINESTYLE },
204 { "lt", S_LINETYPE },
205 { "loa$dpath", S_LOADPATH },
206 { "loc$ale", S_LOCALE },
207 { "log$scale", S_LOGSCALE },
208 { "mac$ros", S_MACROS },
209 { "map$ping", S_MAPPING },
210 { "map$ping3d", S_MAPPING },
211
212 { "mar$gins", S_MARGIN },
213 { "lmar$gin", S_LMARGIN },
214 { "rmar$gin", S_RMARGIN },
215 { "tmar$gin", S_TMARGIN },
216 { "bmar$gin", S_BMARGIN },
217
218 { "micro", S_MICRO },
219 { "minus$sign", S_MINUS_SIGN },
220 { "mo$use", S_MOUSE },
221 { "mono$chrome", S_MONOCHROME },
222 { "multi$plot", S_MULTIPLOT },
223
224 { "mxt$ics", S_MXTICS },
225 { "nomxt$ics", S_NOMXTICS },
226 { "mx2t$ics", S_MX2TICS },
227 { "nomx2t$ics", S_NOMX2TICS },
228 { "myt$ics", S_MYTICS },
229 { "nomyt$ics", S_NOMYTICS },
230 { "my2t$ics", S_MY2TICS },
231 { "nomy2t$ics", S_NOMY2TICS },
232 { "mzt$ics", S_MZTICS },
233 { "nomzt$ics", S_NOMZTICS },
234 { "mrt$ics", S_MRTICS },
235 { "mtt$ics", S_MTTICS },
236 { "mcbt$ics", S_MCBTICS },
237 { "nomcbt$ics", S_NOMCBTICS },
238 { "nonlinear", S_NONLINEAR },
239 { "of$fsets", S_OFFSETS },
240 { "or$igin", S_ORIGIN },
241 { "o$utput", SET_OUTPUT },
242 { "pa$rametric", S_PARAMETRIC },
243 { "pm$3d", S_PM3D },
244 { "pal$ette", S_PALETTE },
245 { "color", S_COLOR },
246 { "colorb$ox", S_COLORBOX },
247 { "colorn$ames", S_COLORNAMES },
248 { "colors$equence", S_COLORSEQUENCE },
249 { "p$lot", S_PLOT },
250 { "pointint$ervalbox", S_POINTINTERVALBOX },
251 { "poi$ntsize", S_POINTSIZE },
252 { "pol$ar", S_POLAR },
253 { "pr$int", S_PRINT },
254 { "psdir", S_PSDIR },
255 { "obj$ect", S_OBJECT },
256 { "rgbmax", S_RGBMAX },
257 { "sa$mples", S_SAMPLES },
258 { "si$ze", S_SIZE },
259 { "st$yle", S_STYLE },
260 { "su$rface", S_SURFACE },
261 { "table", S_TABLE },
262 { "t$erminal", S_TERMINAL },
263 { "termopt$ions", S_TERMOPTIONS },
264 { "theta$0", S_THETA },
265 { "ti$cs", S_TICS },
266 { "ticsc$ale", S_TICSCALE },
267 { "ticsl$evel", S_TICSLEVEL },
268 { "timef$mt", S_TIMEFMT },
269 { "tim$estamp", S_TIMESTAMP },
270 { "tit$le", S_TITLE },
271 { "v$ariables", S_VARIABLES },
272 { "ve$rsion", S_VERSION },
273 { "vi$ew", S_VIEW },
274 { "xyp$lane", S_XYPLANE },
275
276 { "xda$ta", S_XDATA },
277 { "x2da$ta", S_X2DATA },
278 { "yda$ta", S_YDATA },
279 { "y2da$ta", S_Y2DATA },
280 { "zda$ta", S_ZDATA },
281 { "cbda$ta", S_CBDATA },
282
283 { "xl$abel", S_XLABEL },
284 { "x2l$abel", S_X2LABEL },
285 { "yl$abel", S_YLABEL },
286 { "y2l$abel", S_Y2LABEL },
287 { "zl$abel", S_ZLABEL },
288 { "cbl$abel", S_CBLABEL },
289 { "rlabel", S_RLABEL },
290
291 { "xti$cs", S_XTICS },
292 { "noxti$cs", S_NOXTICS },
293 { "x2ti$cs", S_X2TICS },
294 { "nox2ti$cs", S_NOX2TICS },
295 { "yti$cs", S_YTICS },
296 { "noyti$cs", S_NOYTICS },
297 { "y2ti$cs", S_Y2TICS },
298 { "noy2ti$cs", S_NOY2TICS },
299 { "zti$cs", S_ZTICS },
300 { "nozti$cs", S_NOZTICS },
301 { "rti$cs", S_RTICS },
302 { "tti$cs", S_TTICS },
303 { "cbti$cs", S_CBTICS },
304 { "nocbti$cs", S_NOCBTICS },
305
306 { "xdti$cs", S_XDTICS },
307 { "noxdti$cs", S_NOXDTICS },
308 { "x2dti$cs", S_X2DTICS },
309 { "nox2dti$cs", S_NOX2DTICS },
310 { "ydti$cs", S_YDTICS },
311 { "noydti$cs", S_NOYDTICS },
312 { "y2dti$cs", S_Y2DTICS },
313 { "noy2dti$cs", S_NOY2DTICS },
314 { "zdti$cs", S_ZDTICS },
315 { "nozdti$cs", S_NOZDTICS },
316 { "cbdti$cs", S_CBDTICS },
317 { "nocbdti$cs", S_NOCBDTICS },
318
319 { "xmti$cs", S_XMTICS },
320 { "noxmti$cs", S_NOXMTICS },
321 { "x2mti$cs", S_X2MTICS },
322 { "nox2mti$cs", S_NOX2MTICS },
323 { "ymti$cs", S_YMTICS },
324 { "noymti$cs", S_NOYMTICS },
325 { "y2mti$cs", S_Y2MTICS },
326 { "noy2mti$cs", S_NOY2MTICS },
327 { "zmti$cs", S_ZMTICS },
328 { "nozmti$cs", S_NOZMTICS },
329 { "cbmti$cs", S_CBMTICS },
330 { "nocbmti$cs", S_NOCBMTICS },
331
332 { "xr$ange", S_XRANGE },
333 { "x2r$ange", S_X2RANGE },
334 { "yr$ange", S_YRANGE },
335 { "y2r$ange", S_Y2RANGE },
336 { "zr$ange", S_ZRANGE },
337 { "cbr$ange", S_CBRANGE },
338 { "rr$ange", S_RRANGE },
339 { "tr$ange", S_TRANGE },
340 { "ur$ange", S_URANGE },
341 { "vr$ange", S_VRANGE },
342
343 { "xzeroa$xis", S_XZEROAXIS },
344 { "x2zeroa$xis", S_X2ZEROAXIS },
345 { "yzeroa$xis", S_YZEROAXIS },
346 { "y2zeroa$xis", S_Y2ZEROAXIS },
347 { "zzeroa$xis", S_ZZEROAXIS },
348 { "zeroa$xis", S_ZEROAXIS },
349 { "rax$is", S_RAXIS },
350 { "paxis", S_PAXIS },
351
352 { "z$ero", S_ZERO },
353 { NULL, S_INVALID }
354 };
355
356 /* 'set hidden3d' options */
357 const struct gen_table set_hidden3d_tbl[] =
358 {
359 { "def$aults", S_HI_DEFAULTS },
360 { "off$set", S_HI_OFFSET },
361 { "nooff$set", S_HI_NOOFFSET },
362 { "tri$anglepattern", S_HI_TRIANGLEPATTERN },
363 { "undef$ined", S_HI_UNDEFINED },
364 { "nound$efined", S_HI_NOUNDEFINED },
365 { "alt$diagonal", S_HI_ALTDIAGONAL },
366 { "noalt$diagonal", S_HI_NOALTDIAGONAL },
367 { "bent$over", S_HI_BENTOVER },
368 { "nobent$over", S_HI_NOBENTOVER },
369 { "front", S_HI_FRONT },
370 { "back", S_HI_BACK },
371 { NULL, S_HI_INVALID }
372 };
373
374 /* 'set key' options */
375 const struct gen_table set_key_tbl[] =
376 {
377 { "def$ault", S_KEY_DEFAULT },
378 { "on", S_KEY_ON },
379 { "off", S_KEY_OFF },
380 { "t$op", S_KEY_TOP },
381 { "b$ottom", S_KEY_BOTTOM },
382 { "l$eft", S_KEY_LEFT },
383 { "r$ight", S_KEY_RIGHT },
384 { "c$enter", S_KEY_CENTER },
385 { "ver$tical", S_KEY_VERTICAL },
386 { "hor$izontal", S_KEY_HORIZONTAL },
387 { "ov$er", S_KEY_OVER },
388 { "ab$ove", S_KEY_ABOVE },
389 { "u$nder", S_KEY_UNDER },
390 { "be$low", S_KEY_BELOW },
391 { "at", S_KEY_MANUAL },
392 { "ins$ide", S_KEY_INSIDE },
393 { "o$utside", S_KEY_OUTSIDE },
394 { "fix$ed", S_KEY_FIXED },
395 { "tm$argin", S_KEY_TMARGIN },
396 { "bm$argin", S_KEY_BMARGIN },
397 { "lm$argin", S_KEY_LMARGIN },
398 { "rm$argin", S_KEY_RMARGIN },
399 { "L$eft", S_KEY_LLEFT },
400 { "R$ight", S_KEY_RRIGHT },
401 { "rev$erse", S_KEY_REVERSE },
402 { "norev$erse", S_KEY_NOREVERSE },
403 { "inv$ert", S_KEY_INVERT },
404 { "noinv$ert", S_KEY_NOINVERT },
405 { "enh$anced", S_KEY_ENHANCED },
406 { "noenh$anced", S_KEY_NOENHANCED },
407 { "b$ox", S_KEY_BOX },
408 { "nob$ox", S_KEY_NOBOX },
409 { "sa$mplen", S_KEY_SAMPLEN },
410 { "sp$acing", S_KEY_SPACING },
411 { "w$idth", S_KEY_WIDTH },
412 { "h$eight", S_KEY_HEIGHT },
413 { "a$utotitles", S_KEY_AUTOTITLES },
414 { "noa$utotitles", S_KEY_NOAUTOTITLES },
415 { "ti$tle", S_KEY_TITLE },
416 { "noti$tle", S_KEY_NOTITLE },
417 { "font", S_KEY_FONT },
418 { "tc", S_KEY_TEXTCOLOR },
419 { "text$color", S_KEY_TEXTCOLOR },
420 { "maxcol$s", S_KEY_MAXCOLS},
421 { "maxcolu$mns", S_KEY_MAXCOLS},
422 { "maxrow$s", S_KEY_MAXROWS},
423 { "opaque", S_KEY_FRONT},
424 { "noopaque", S_KEY_NOFRONT},
425 { NULL, S_KEY_INVALID }
426 };
427
428 /* 'test' command */
429 const struct gen_table test_tbl[] =
430 {
431 { "term$inal", TEST_TERMINAL },
432 { "pal$ette", TEST_PALETTE },
433 { NULL, TEST_INVALID }
434 };
435
436 /* 'set colorbox' options */
437 const struct gen_table set_colorbox_tbl[] =
438 {
439 { "v$ertical", S_COLORBOX_VERTICAL },
440 { "h$orizontal", S_COLORBOX_HORIZONTAL },
441 { "def$ault", S_COLORBOX_DEFAULT },
442 { "u$ser", S_COLORBOX_USER },
443 { "at", S_COLORBOX_USER },
444 { "bo$rder", S_COLORBOX_BORDER },
445 { "bd$efault", S_COLORBOX_BDEFAULT },
446 { "nobo$rder", S_COLORBOX_NOBORDER },
447 { "o$rigin", S_COLORBOX_ORIGIN },
448 { "s$ize", S_COLORBOX_SIZE },
449 { "inv$ert", S_COLORBOX_INVERT },
450 { "noinv$ert", S_COLORBOX_NOINVERT },
451 { "fr$ont", S_COLORBOX_FRONT },
452 { "ba$ck", S_COLORBOX_BACK },
453 { NULL, S_COLORBOX_INVALID }
454 };
455
456 /* 'set palette' options */
457 const struct gen_table set_palette_tbl[] =
458 {
459 { "pos$itive", S_PALETTE_POSITIVE },
460 { "neg$ative", S_PALETTE_NEGATIVE },
461 { "gray$scale", S_PALETTE_GRAY },
462 { "grey$scale", S_PALETTE_GRAY },
463 { "col$or", S_PALETTE_COLOR },
464 { "rgb$formulae", S_PALETTE_RGBFORMULAE },
465 { "def$ined", S_PALETTE_DEFINED },
466 { "file", S_PALETTE_FILE },
467 { "func$tions", S_PALETTE_FUNCTIONS },
468 { "mo$del", S_PALETTE_MODEL },
469 { "nops_allcF", S_PALETTE_NOPS_ALLCF },
470 { "ps_allcF", S_PALETTE_PS_ALLCF },
471 { "maxc$olors", S_PALETTE_MAXCOLORS },
472 { "gam$ma", S_PALETTE_GAMMA },
473 { "cubehelix", S_PALETTE_CUBEHELIX },
474 { NULL, S_PALETTE_INVALID }
475 };
476
477
478 const struct gen_table color_model_tbl[] =
479 {
480 { "RGB", C_MODEL_RGB },
481 { "HSV", C_MODEL_HSV },
482 { "CMY", C_MODEL_CMY },
483 { "XYZ", C_MODEL_XYZ }, /* Obsolete */
484 { NULL, -1 }
485 };
486
487 /* 'set pm3d' options */
488 const struct gen_table set_pm3d_tbl[] =
489 {
490 { "at", S_PM3D_AT },
491 { "interp$olate", S_PM3D_INTERPOLATE },
492 { "scansfor$ward", S_PM3D_SCANSFORWARD },
493 { "scansback$ward", S_PM3D_SCANSBACKWARD },
494 { "scansauto$matic",S_PM3D_SCANS_AUTOMATIC },
495 { "dep$thorder", S_PM3D_DEPTH },
496 { "fl$ush", S_PM3D_FLUSH },
497 { "ftr$iangles", S_PM3D_FTRIANGLES },
498 { "noftr$iangles", S_PM3D_NOFTRIANGLES },
499 { "clip1$in", S_PM3D_CLIP_1IN },
500 { "clip4$in", S_PM3D_CLIP_4IN },
501 { "clipcb", S_PM3D_CLIPCB },
502 { "noclipcb", S_PM3D_NOCLIPCB },
503 { "map", S_PM3D_MAP },
504 { "bo$rder", S_PM3D_BORDER },
505 { "nobo$rder", S_PM3D_NOBORDER },
506 { "hi$dden3d", S_PM3D_HIDDEN },
507 { "nohi$dden3d", S_PM3D_NOHIDDEN },
508 { "so$lid", S_PM3D_SOLID },
509 { "notr$ansparent", S_PM3D_NOTRANSPARENT },
510 { "noso$lid", S_PM3D_NOSOLID },
511 { "tr$ansparent", S_PM3D_TRANSPARENT },
512 { "i$mplicit", S_PM3D_IMPLICIT },
513 { "noe$xplicit", S_PM3D_NOEXPLICIT },
514 { "noi$mplicit", S_PM3D_NOIMPLICIT },
515 { "e$xplicit", S_PM3D_EXPLICIT },
516 { "corners2c$olor", S_PM3D_WHICH_CORNER },
517 { "light$ing", S_PM3D_LIGHTING_MODEL },
518 { "nolight$ing", S_PM3D_NOLIGHTING_MODEL },
519 { NULL, S_PM3D_INVALID }
520 };
521
522 /* EAM Nov 2008 - RGB color names for 'set palette defined'
523 * merged with colors from web_color_rgbs used by terminals.
524 */
525 struct gen_table default_color_names_tbl[] =
526 {
527 /* Put the colors used by gd/pdf/ppm terminals first */
528
529 { "white" , 255*(1<<16) + 255*(1<<8) + 255 },
530 { "black" , 0*(1<<16) + 0*(1<<8) + 0 },
531 { "dark-grey" , 160*(1<<16) + 160*(1<<8) + 160 },
532 { "red" , 255*(1<<16) + 0*(1<<8) + 0 },
533 { "web-green" , 0*(1<<16) + 192*(1<<8) + 0 },
534 { "web-blue" , 0*(1<<16) + 128*(1<<8) + 255 },
535 { "dark-magenta" , 192*(1<<16) + 0*(1<<8) + 255 },
536 { "dark-cyan" , 0*(1<<16) + 238*(1<<8) + 238 },
537 { "dark-orange" , 192*(1<<16) + 64*(1<<8) + 0 },
538 { "dark-yellow" , 200*(1<<16) + 200*(1<<8) + 0 },
539 { "royalblue" , 65*(1<<16) + 105*(1<<8) + 225 },
540 { "goldenrod" , 255*(1<<16) + 192*(1<<8) + 32 },
541 { "dark-spring-green", 0*(1<<16) + 128*(1<<8) + 64 },
542 { "purple" , 192*(1<<16) + 128*(1<<8) + 255 },
543 { "steelblue" , 48*(1<<16) + 96*(1<<8) + 128 },
544 { "dark-red" , 139*(1<<16) + 0*(1<<8) + 0 },
545 { "dark-chartreuse" , 64*(1<<16) + 128*(1<<8) + 0 },
546 { "orchid" , 255*(1<<16) + 128*(1<<8) + 255 },
547 { "aquamarine" , 127*(1<<16) + 255*(1<<8) + 212 },
548 { "brown" , 165*(1<<16) + 42*(1<<8) + 42 },
549 { "yellow" , 255*(1<<16) + 255*(1<<8) + 0 },
550 { "turquoise" , 64*(1<<16) + 224*(1<<8) + 208 },
551
552 /* greyscale gradient */
553
554 { "grey0" , 0*(1<<16) + 0*(1<<8) + 0 },
555 { "grey10" , 26*(1<<16) + 26*(1<<8) + 26 },
556 { "grey20" , 51*(1<<16) + 51*(1<<8) + 51 },
557 { "grey30" , 77*(1<<16) + 77*(1<<8) + 77 },
558 { "grey40" , 102*(1<<16) + 102*(1<<8) + 102 },
559 { "grey50" , 127*(1<<16) + 127*(1<<8) + 127 },
560 { "grey60" , 153*(1<<16) + 153*(1<<8) + 153 },
561 { "grey70" , 179*(1<<16) + 179*(1<<8) + 179 },
562 { "grey" , 192*(1<<16) + 192*(1<<8) + 192 },
563 { "grey80" , 204*(1<<16) + 204*(1<<8) + 204 },
564 { "grey90" , 229*(1<<16) + 229*(1<<8) + 229 },
565 { "grey100" , 255*(1<<16) + 255*(1<<8) + 255 },
566
567 /* random other colors */
568
569 { "light-red" , 240*(1<<16) + 50*(1<<8) + 50 },
570 { "light-green" , 144*(1<<16) + 238*(1<<8) + 144 },
571 { "light-blue" , 173*(1<<16) + 216*(1<<8) + 230 },
572 { "light-magenta" , 240*(1<<16) + 85*(1<<8) + 240 },
573 { "light-cyan" , 224*(1<<16) + 255*(1<<8) + 255 },
574 { "light-goldenrod" , 238*(1<<16) + 221*(1<<8) + 130 },
575 { "light-pink" , 255*(1<<16) + 182*(1<<8) + 193 },
576 { "light-turquoise" , 175*(1<<16) + 238*(1<<8) + 238 },
577 { "gold" , 255*(1<<16) + 215*(1<<8) + 0 },
578 { "green" , 0*(1<<16) + 255*(1<<8) + 0 },
579 { "dark-green" , 0*(1<<16) + 100*(1<<8) + 0 },
580 { "spring-green" , 0*(1<<16) + 255*(1<<8) + 127 },
581 { "forest-green" , 34*(1<<16) + 139*(1<<8) + 34 },
582 { "sea-green" , 46*(1<<16) + 139*(1<<8) + 87 },
583 { "blue" , 0*(1<<16) + 0*(1<<8) + 255 },
584 { "dark-blue" , 0*(1<<16) + 0*(1<<8) + 139 },
585 { "midnight-blue" , 25*(1<<16) + 25*(1<<8) + 112 },
586 { "navy" , 0*(1<<16) + 0*(1<<8) + 128 },
587 { "medium-blue" , 0*(1<<16) + 0*(1<<8) + 205 },
588 { "skyblue" , 135*(1<<16) + 206*(1<<8) + 235 },
589 { "cyan" , 0*(1<<16) + 255*(1<<8) + 255 },
590 { "magenta" , 255*(1<<16) + 0*(1<<8) + 255 },
591 { "dark-turquoise" , 0*(1<<16) + 206*(1<<8) + 209 },
592 { "dark-pink" , 255*(1<<16) + 20*(1<<8) + 147 },
593 { "coral" , 255*(1<<16) + 127*(1<<8) + 80 },
594 { "light-coral" , 240*(1<<16) + 128*(1<<8) + 128 },
595 { "orange-red" , 255*(1<<16) + 69*(1<<8) + 0 },
596 { "salmon" , 250*(1<<16) + 128*(1<<8) + 114 },
597 { "dark-salmon" , 233*(1<<16) + 150*(1<<8) + 122 },
598 { "khaki" , 240*(1<<16) + 230*(1<<8) + 140 },
599 { "dark-khaki" , 189*(1<<16) + 183*(1<<8) + 107 },
600 { "dark-goldenrod" , 184*(1<<16) + 134*(1<<8) + 11 },
601 { "beige" , 245*(1<<16) + 245*(1<<8) + 220 },
602 { "olive" , 160*(1<<16) + 128*(1<<8) + 32 },
603 { "orange" , 255*(1<<16) + 165*(1<<8) + 0 },
604 { "violet" , 238*(1<<16) + 130*(1<<8) + 238 },
605 { "dark-violet" , 148*(1<<16) + 0*(1<<8) + 211 },
606 { "plum" , 221*(1<<16) + 160*(1<<8) + 221 },
607 { "dark-plum" , 144*(1<<16) + 80*(1<<8) + 64 },
608 { "dark-olivegreen" , 85*(1<<16) + 107*(1<<8) + 47 },
609
610 { "orangered4" , 128*(1<<16) + 20*(1<<8) + 0 },
611 { "brown4" , 128*(1<<16) + 20*(1<<8) + 20 },
612 { "sienna4" , 128*(1<<16) + 64*(1<<8) + 20 },
613 { "orchid4" , 128*(1<<16) + 64*(1<<8) + 128 },
614 { "mediumpurple3" , 128*(1<<16) + 96*(1<<8) + 192 },
615 { "slateblue1" , 128*(1<<16) + 96*(1<<8) + 255 },
616 { "yellow4" , 128*(1<<16) + 128*(1<<8) + 0 },
617 { "sienna1" , 255*(1<<16) + 128*(1<<8) + 64 },
618 { "tan1" , 255*(1<<16) + 160*(1<<8) + 64 },
619 { "sandybrown" , 255*(1<<16) + 160*(1<<8) + 96 },
620 { "light-salmon" , 255*(1<<16) + 160*(1<<8) + 112 },
621 { "pink" , 255*(1<<16) + 192*(1<<8) + 192 },
622 { "khaki1" , 255*(1<<16) + 255*(1<<8) + 128 },
623 { "lemonchiffon" , 255*(1<<16) + 255*(1<<8) + 192 },
624 { "bisque" , 205*(1<<16) + 183*(1<<8) + 158 },
625 { "honeydew" , 240*(1<<16) + 255*(1<<8) + 240 },
626 { "slategrey" , 160*(1<<16) + 182*(1<<8) + 205 },
627 { "seagreen" , 193*(1<<16) + 255*(1<<8) + 193 },
628 { "antiquewhite" , 205*(1<<16) + 192*(1<<8) + 176 },
629 { "chartreuse" , 124*(1<<16) + 255*(1<<8) + 64 },
630 { "greenyellow" , 160*(1<<16) + 255*(1<<8) + 32 },
631
632 /* Synonyms */
633 { "gray" , 190*(1<<16) + 190*(1<<8) + 190 },
634 { "light-gray" , 211*(1<<16) + 211*(1<<8) + 211 },
635 { "light-grey" , 211*(1<<16) + 211*(1<<8) + 211 },
636 { "dark-gray" , 160*(1<<16) + 160*(1<<8) + 160 },
637 { "slategray" , 160*(1<<16) + 182*(1<<8) + 205 },
638 { "gray0" , 0*(1<<16) + 0*(1<<8) + 0 },
639 { "gray10" , 26*(1<<16) + 26*(1<<8) + 26 },
640 { "gray20" , 51*(1<<16) + 51*(1<<8) + 51 },
641 { "gray30" , 77*(1<<16) + 77*(1<<8) + 77 },
642 { "gray40" , 102*(1<<16) + 102*(1<<8) + 102 },
643 { "gray50" , 127*(1<<16) + 127*(1<<8) + 127 },
644 { "gray60" , 153*(1<<16) + 153*(1<<8) + 153 },
645 { "gray70" , 179*(1<<16) + 179*(1<<8) + 179 },
646 { "gray80" , 204*(1<<16) + 204*(1<<8) + 204 },
647 { "gray90" , 229*(1<<16) + 229*(1<<8) + 229 },
648 { "gray100" , 255*(1<<16) + 255*(1<<8) + 255 },
649 { NULL, -1 }
650 };
651 struct gen_table *pm3d_color_names_tbl = default_color_names_tbl;
652 struct gen_table *user_color_names_tbl = NULL;
653 const int num_predefined_colors = sizeof(default_color_names_tbl)
654 / sizeof(struct gen_table) - 1;
655 int num_userdefined_colors = 0;
656
657
658 const struct gen_table show_style_tbl[] =
659 {
660 { "d$ata", SHOW_STYLE_DATA },
661 { "f$unction", SHOW_STYLE_FUNCTION },
662 { "l$ines", SHOW_STYLE_LINE },
663 { "fill", SHOW_STYLE_FILLING },
664 { "fs", SHOW_STYLE_FILLING },
665 { "ar$row", SHOW_STYLE_ARROW },
666 { "incr$ement", SHOW_STYLE_INCREMENT },
667 { "hist$ogram", SHOW_STYLE_HISTOGRAM },
668 { "circ$le", SHOW_STYLE_CIRCLE },
669 { "ell$ipse", SHOW_STYLE_ELLIPSE },
670 { "rect$angle", SHOW_STYLE_RECTANGLE },
671 { "boxplot", SHOW_STYLE_BOXPLOT },
672 { "parallel$axis", SHOW_STYLE_PARALLEL },
673 #ifdef EAM_BOXED_TEXT
674 { "textbox", SHOW_STYLE_TEXTBOX },
675 #endif
676 { NULL, SHOW_STYLE_INVALID }
677 };
678
679 const struct gen_table plotstyle_tbl[] =
680 {
681 { "l$ines", LINES },
682 { "i$mpulses", IMPULSES },
683 { "p$oints", POINTSTYLE },
684 { "linesp$oints", LINESPOINTS },
685 { "lp", LINESPOINTS },
686 { "d$ots", DOTS },
687 { "yerrorl$ines", YERRORLINES },
688 { "errorl$ines", YERRORLINES },
689 { "xerrorl$ines", XERRORLINES },
690 { "xyerrorl$ines", XYERRORLINES },
691 { "ye$rrorbars", YERRORBARS },
692 { "e$rrorbars", YERRORBARS },
693 { "xe$rrorbars", XERRORBARS },
694 { "xye$rrorbars", XYERRORBARS },
695 { "boxes", BOXES },
696 { "hist$ograms", HISTOGRAMS },
697 { "filledc$urves", FILLEDCURVES },
698 { "boxer$rorbars", BOXERROR },
699 { "boxx$yerrorbars", BOXXYERROR },
700 { "st$eps", STEPS },
701 { "fillst$eps", FILLSTEPS },
702 { "fs$teps", FSTEPS },
703 { "his$teps", HISTEPS },
704 { "vec$tors", VECTOR },
705 { "fin$ancebars", FINANCEBARS },
706 { "can$dlesticks", CANDLESTICKS },
707 { "boxplot", BOXPLOT },
708 { "pm$3d", PM3DSURFACE },
709 { "labels", LABELPOINTS },
710 { "ima$ge", IMAGE },
711 { "rgbima$ge", RGBIMAGE },
712 { "rgba$lpha", RGBA_IMAGE },
713 #ifdef EAM_OBJECTS
714 { "cir$cles", CIRCLES },
715 { "ell$ipses", ELLIPSES },
716 #endif
717 { "sur$face", SURFACEGRID },
718 { "parallel$axes", PARALLELPLOT },
719 { "table", TABLESTYLE },
720 { "zerror$fill", ZERRORFILL },
721 { NULL, PLOT_STYLE_NONE }
722 };
723
724 const struct gen_table filledcurves_opts_tbl[] =
725 {
726 { "c$losed", FILLEDCURVES_CLOSED },
727 { "x$1", FILLEDCURVES_X1 },
728 { "y1", FILLEDCURVES_Y1 },
729 { "x2", FILLEDCURVES_X2 },
730 { "y2", FILLEDCURVES_Y2 },
731 { "xy", FILLEDCURVES_ATXY },
732 { "r", FILLEDCURVES_ATR },
733 { "above", FILLEDCURVES_ABOVE },
734 { "below", FILLEDCURVES_BELOW },
735 { "y", FILLEDCURVES_Y1 },
736 { NULL, -1 }
737 };
738
739 int
lookup_table(const struct gen_table * tbl,int find_token)740 lookup_table(const struct gen_table *tbl, int find_token)
741 {
742 while (tbl->key) {
743 if (almost_equals(find_token, tbl->key))
744 return tbl->value;
745 tbl++;
746 }
747 return tbl->value; /* *_INVALID */
748 }
749
750 parsefuncp_t
lookup_ftable(const struct gen_ftable * ftbl,int find_token)751 lookup_ftable(const struct gen_ftable *ftbl, int find_token)
752 {
753 while (ftbl->key) {
754 if (almost_equals(find_token, ftbl->key))
755 return ftbl->value;
756 ftbl++;
757 }
758 return ftbl->value;
759 }
760
761 /* Returns value of the first table entry for which the search string
762 * is a leading substring, or -1 if there is no match.
763 */
764 int
lookup_table_entry(const struct gen_table * tbl,const char * search_str)765 lookup_table_entry(const struct gen_table *tbl, const char *search_str)
766 {
767 while (tbl->key) {
768 if (!strncmp(search_str, tbl->key, strlen(search_str)))
769 return tbl->value;
770 tbl++;
771 }
772 return -1;
773 }
774
775 /* Returns the index of the table entry whose key matches the search string.
776 * If there is no exact match return the first table entry that is a leading
777 * substring of the search string. Returns -1 if there is no match.
778 */
779 int
lookup_table_nth(const struct gen_table * tbl,const char * search_str)780 lookup_table_nth(const struct gen_table *tbl, const char *search_str)
781 {
782 int k = -1;
783 int best_so_far = -1;
784 while (tbl[++k].key) {
785 /* Exact match always wins */
786 if (!strcmp(search_str, tbl[k].key))
787 return k;
788 if (!strncmp(search_str, tbl[k].key, strlen(tbl[k].key)))
789 if (best_so_far < 0) best_so_far = k;
790 }
791 return best_so_far;
792 }
793
794 /* Returns index of the table tbl whose key matches the beginning of the
795 * search string search_str. The table_len is necessary because the table
796 * is searched in the reversed order. The routine is used in parsing commands
797 * '(un)set log x2zcb', for instance.
798 * It returns index into the table or -1 if there is no match.
799 */
800 int
lookup_table_nth_reverse(const struct gen_table * tbl,int table_len,const char * search_str)801 lookup_table_nth_reverse(
802 const struct gen_table *tbl,
803 int table_len,
804 const char *search_str)
805 {
806 while (--table_len >= 0) {
807 if (tbl[table_len].key && !strncmp(search_str, tbl[table_len].key, strlen(tbl[table_len].key)))
808 return table_len;
809 }
810 return -1; /* not found */
811 }
812
813 /* Returns the key associated with this indexed value
814 * or NULL if the key/value pair is not found.
815 */
816 const char *
reverse_table_lookup(const struct gen_table * tbl,int entry)817 reverse_table_lookup(const struct gen_table *tbl, int entry)
818 {
819 int k = -1;
820 while (tbl[++k].key)
821 if (tbl[k].value == entry)
822 return(tbl[k].key);
823 return NULL;
824 }
825