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