Icons are changed
[gnuplot] / src / tables.c
1 #ifndef lint
2 static char *RCSid() { return RCSid("$Id: tables.c,v 1.71.2.5 2008/06/25 22:47:50 sfeam Exp $"); }
3 #endif
4
5 /* GNUPLOT - tables.c */
6
7 /*[
8  * Copyright 1999, 2004   Lars Hecking
9  *
10  * Permission to use, copy, and distribute this software and its
11  * documentation for any purpose with or without fee is hereby granted,
12  * provided that the above copyright notice appear in all copies and
13  * that both that copyright notice and this permission notice appear
14  * in supporting documentation.
15  *
16  * Permission to modify the software is granted, but not the right to
17  * distribute the complete modified source code.  Modifications are to
18  * be distributed as patches to the released version.  Permission to
19  * distribute binaries produced by compiling modified sources is granted,
20  * provided you
21  *   1. distribute the corresponding source modifications from the
22  *    released version in the form of a patch file along with the binaries,
23  *   2. add special version identification to distinguish your version
24  *    in addition to the base release version number,
25  *   3. provide your name and address as the primary contact for the
26  *    support of your modified version, and
27  *   4. retain our contact information in regard to use of the base
28  *    software.
29  * Permission to distribute the released version of the source code along
30  * with corresponding source modifications in the form of a patch file is
31  * granted with same provisions 2 through 4 for binary distributions.
32  *
33  * This software is provided "as is" without express or implied warranty
34  * to the extent permitted by applicable law.
35 ]*/
36
37 #include "tables.h"
38
39 #include "command.h"
40 #include "fit.h"
41 #include "setshow.h"
42 #include "term_api.h"
43 #include "util.h"
44 # include "getcolor.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     { "ca$ll", call_command },
57     { "cd", changedir_command },
58     { "cl$ear", clear_command },
59     { "ex$it", exit_command },
60     { "f$it", fit_command },
61     { "h$elp", help_command },
62     { "?", help_command },
63     { "hi$story", history_command },
64     { "if", if_command },
65     { "else", else_command },
66     { "l$oad", load_command },
67     { "pa$use", pause_command },
68     { "p$lot", plot_command },
69     { "pr$int", print_command },
70     { "pwd", pwd_command },
71     { "q$uit", exit_command },
72     { "rep$lot", replot_command },
73     { "re$read", reread_command },
74     { "res$et", reset_command },
75     { "sa$ve", save_command },
76     { "scr$eendump", screendump_command },
77     { "se$t", set_command },
78     { "she$ll", do_shell },
79     { "sh$ow", show_command },
80     { "sp$lot", splot_command },
81     { "sy$stem", system_command },
82     { "test", test_command },
83     { "und$efine", undefine_command },
84     { "uns$et", unset_command },
85     { "up$date", update_command },
86     { ";", null_command },
87     /* last key must be NULL */
88     { NULL, invalid_command }
89 };
90
91 /* 'plot' and 'splot' */
92 /* HBB 990829: unused, yet? */
93 /* Lars 991108: yes, because the 'plot' parser is a real bitch :( */
94 /* pm 011129: ...and therefore I'm putting it into #if 0 ... #endif.
95  * Anyway, this table can't be used as below because some options
96  * belong to the group of data file options and others to the group
97  * of plot options
98  */
99 #if 0
100 const struct gen_table plot_tbl[] =
101 {
102     { "ax$es", P_AXES },
103     { "ax$is", P_AXES },
104     { "bin$ary", P_BINARY },
105     { "ev$ery", P_EVERY },
106     { "i$ndex", P_INDEX },
107     { "mat$rix", P_MATRIX },
108     { "s$mooth", P_SMOOTH },
109     { "thru$", P_THRU },
110     { "t$itle", P_TITLE },
111     { "not$itle", P_NOTITLE },
112     { "u$sing", P_USING },
113     { "w$ith", P_WITH },
114     { NULL, P_INVALID }
115 };
116 #endif
117
118 /* 'plot ax[ei]s' parameter */
119 const struct gen_table plot_axes_tbl[] =
120 {
121     { "x1y1", AXES_X1Y1 },
122     { "x2y2", AXES_X2Y2 },
123     { "x1y2", AXES_X1Y2 },
124     { "x2y1", AXES_X2Y1 },
125     { NULL, AXES_NONE }
126 };
127
128 /* 'plot smooth' parameter */
129 const struct gen_table plot_smooth_tbl[] =
130 {
131     { "a$csplines", SMOOTH_ACSPLINES },
132     { "b$ezier", SMOOTH_BEZIER },
133     { "c$splines", SMOOTH_CSPLINES },
134     { "s$bezier", SMOOTH_SBEZIER },
135     { "u$nique", SMOOTH_UNIQUE },
136     { "f$requency", SMOOTH_FREQUENCY },
137     { NULL, SMOOTH_NONE }
138 };
139
140 /* 'save' command */
141 const struct gen_table save_tbl[] =
142 {
143     { "f$unctions", SAVE_FUNCS },
144     { "s$et", SAVE_SET },
145     { "t$erminal", SAVE_TERMINAL },
146     { "v$ariables", SAVE_VARS },
147     { NULL, SAVE_INVALID }
148 };
149
150 /* 'set' and 'show' commands */
151 const struct gen_table set_tbl[] =
152 {
153     { "a$ll", S_ALL },
154     { "ac$tion_table", S_ACTIONTABLE },
155     { "at", S_ACTIONTABLE },
156     { "an$gles", S_ANGLES },
157     { "ar$row", S_ARROW },
158     { "au$toscale", S_AUTOSCALE },
159     { "b$ars", S_BARS },
160     { "bor$der", S_BORDER },
161     { "box$width", S_BOXWIDTH },
162     { "cl$abel", S_CLABEL },
163     { "c$lip", S_CLIP },
164     { "cn$trparam", S_CNTRPARAM },
165     { "co$ntours", S_CONTOUR },
166     { "da$ta", S_DATA },
167
168     { "data$file", S_DATAFILE },
169
170     { "dg$rid3d", S_DGRID3D },
171     { "du$mmy", S_DUMMY },
172     { "enc$oding", S_ENCODING },
173     { "dec$imalsign", S_DECIMALSIGN },
174     { "fit", S_FIT },
175     { "font$path", S_FONTPATH },
176     { "fo$rmat", S_FORMAT },
177     { "fu$nction", S_FUNCTIONS },
178     { "fu$nctions", S_FUNCTIONS },
179     { "g$rid", S_GRID },
180     { "hid$den3d", S_HIDDEN3D },
181     { "his$torysize", S_HISTORYSIZE },
182     { "is$osamples", S_ISOSAMPLES },
183     { "k$ey", S_KEY },
184     { "keyt$itle", S_KEYTITLE },
185     { "la$bel", S_LABEL },
186     { "li$nestyle", S_LINESTYLE },
187     { "ls", S_LINESTYLE },
188     { "loa$dpath", S_LOADPATH },
189     { "loc$ale", S_LOCALE },
190     { "log$scale", S_LOGSCALE },
191 #ifdef GP_MACROS
192     { "mac$ros", S_MACROS },
193 #endif
194     { "map$ping", S_MAPPING },
195     { "map$ping3d", S_MAPPING },
196
197     { "mar$gin", S_MARGIN },
198     { "lmar$gin", S_LMARGIN },
199     { "rmar$gin", S_RMARGIN },
200     { "tmar$gin", S_TMARGIN },
201     { "bmar$gin", S_BMARGIN },
202
203 #ifdef USE_MOUSE
204     { "mo$use", S_MOUSE },
205 #endif
206     { "multi$plot", S_MULTIPLOT },
207
208     { "mxt$ics", S_MXTICS },
209     { "nomxt$ics", S_NOMXTICS },
210     { "mx2t$ics", S_MX2TICS },
211     { "nomx2t$ics", S_NOMX2TICS },
212     { "myt$ics", S_MYTICS },
213     { "nomyt$ics", S_NOMYTICS },
214     { "my2t$ics", S_MY2TICS },
215     { "nomy2t$ics", S_NOMY2TICS },
216     { "mzt$ics", S_MZTICS },
217     { "nomzt$ics", S_NOMZTICS },
218     { "mcbt$ics", S_MCBTICS },
219     { "nomcbt$ics", S_NOMCBTICS },
220     { "of$fsets", S_OFFSETS },
221     { "or$igin", S_ORIGIN },
222     { "o$utput", SET_OUTPUT },
223     { "pa$rametric", S_PARAMETRIC },
224     { "pm$3d", S_PM3D },
225     { "pal$ette", S_PALETTE },
226     { "colorb$ox", S_COLORBOX },
227     { "colorn$ames", S_COLORNAMES },
228     { "colors", S_COLORNAMES },
229     { "p$lot", S_PLOT },
230     { "poi$ntsize", S_POINTSIZE },
231     { "pol$ar", S_POLAR },
232     { "pr$int", S_PRINT },
233     { "obj$ect", S_OBJECT },
234     { "sa$mples", S_SAMPLES },
235     { "si$ze", S_SIZE },
236     { "st$yle", S_STYLE },
237     { "su$rface", S_SURFACE },
238     { "table", S_TABLE },
239     { "t$erminal", S_TERMINAL },
240     { "termo$ptions", S_TERMOPTIONS },
241     { "ti$cs", S_TICS },
242     { "ticsc$ale", S_TICSCALE },
243     { "ticsl$evel", S_TICSLEVEL },
244     { "timef$mt", S_TIMEFMT },
245     { "tim$estamp", S_TIMESTAMP },
246     { "tit$le", S_TITLE },
247     { "v$ariables", S_VARIABLES },
248     { "ve$rsion", S_VERSION },
249     { "vi$ew", S_VIEW },
250     { "xyp$lane", S_TICSLEVEL },
251
252     { "xda$ta", S_XDATA },
253     { "x2da$ta", S_X2DATA },
254     { "yda$ta", S_YDATA },
255     { "y2da$ta", S_Y2DATA },
256     { "zda$ta", S_ZDATA },
257     { "cbda$ta", S_CBDATA },
258
259     { "xl$abel", S_XLABEL },
260     { "x2l$abel", S_X2LABEL },
261     { "yl$abel", S_YLABEL },
262     { "y2l$abel", S_Y2LABEL },
263     { "zl$abel", S_ZLABEL },
264     { "cbl$abel", S_CBLABEL },
265
266     { "xti$cs", S_XTICS },
267     { "noxti$cs", S_NOXTICS },
268     { "x2ti$cs", S_X2TICS },
269     { "nox2ti$cs", S_NOX2TICS },
270     { "yti$cs", S_YTICS },
271     { "noyti$cs", S_NOYTICS },
272     { "y2ti$cs", S_Y2TICS },
273     { "noy2ti$cs", S_NOY2TICS },
274     { "zti$cs", S_ZTICS },
275     { "nozti$cs", S_NOZTICS },
276     { "cbti$cs", S_CBTICS },
277     { "nocbti$cs", S_NOCBTICS },
278
279     { "xdti$cs", S_XDTICS },
280     { "noxdti$cs", S_NOXDTICS },
281     { "x2dti$cs", S_X2DTICS },
282     { "nox2dti$cs", S_NOX2DTICS },
283     { "ydti$cs", S_YDTICS },
284     { "noydti$cs", S_NOYDTICS },
285     { "y2dti$cs", S_Y2DTICS },
286     { "noy2dti$cs", S_NOY2DTICS },
287     { "zdti$cs", S_ZDTICS },
288     { "nozdti$cs", S_NOZDTICS },
289     { "cbdti$cs", S_CBDTICS },
290     { "nocbdti$cs", S_NOCBDTICS },
291
292     { "xmti$cs", S_XMTICS },
293     { "noxmti$cs", S_NOXMTICS },
294     { "x2mti$cs", S_X2MTICS },
295     { "nox2mti$cs", S_NOX2MTICS },
296     { "ymti$cs", S_YMTICS },
297     { "noymti$cs", S_NOYMTICS },
298     { "y2mti$cs", S_Y2MTICS },
299     { "noy2mti$cs", S_NOY2MTICS },
300     { "zmti$cs", S_ZMTICS },
301     { "nozmti$cs", S_NOZMTICS },
302     { "cbmti$cs", S_CBMTICS },
303     { "nocbmti$cs", S_NOCBMTICS },
304
305     { "xr$ange", S_XRANGE },
306     { "x2r$ange", S_X2RANGE },
307     { "yr$ange", S_YRANGE },
308     { "y2r$ange", S_Y2RANGE },
309     { "zr$ange", S_ZRANGE },
310     { "cbr$ange", S_CBRANGE },
311     { "rr$ange", S_RRANGE },
312     { "tr$ange", S_TRANGE },
313     { "ur$ange", S_URANGE },
314     { "vr$ange", S_VRANGE },
315
316     { "xzeroa$xis", S_XZEROAXIS },
317     { "x2zeroa$xis", S_X2ZEROAXIS },
318     { "yzeroa$xis", S_YZEROAXIS },
319     { "y2zeroa$xis", S_Y2ZEROAXIS },
320     { "zzeroa$xis", S_ZZEROAXIS },
321     { "zeroa$xis", S_ZEROAXIS },
322
323     { "z$ero", S_ZERO },
324     { NULL, S_INVALID }
325 };
326
327 /* 'set hidden3d' options */
328 const struct gen_table set_hidden3d_tbl[] =
329 {
330     { "def$aults", S_HI_DEFAULTS },
331     { "off$set", S_HI_OFFSET },
332     { "nooff$set", S_HI_NOOFFSET },
333     { "tri$anglepattern", S_HI_TRIANGLEPATTERN },
334     { "undef$ined", S_HI_UNDEFINED },
335     { "nound$efined", S_HI_NOUNDEFINED },
336     { "alt$diagonal", S_HI_ALTDIAGONAL },
337     { "noalt$diagonal", S_HI_NOALTDIAGONAL },
338     { "bent$over", S_HI_BENTOVER },
339     { "nobent$over", S_HI_NOBENTOVER },
340     { NULL, S_HI_INVALID }
341 };
342
343 /* 'set key' options */
344 const struct gen_table set_key_tbl[] =
345 {
346     { "def$ault", S_KEY_DEFAULT },
347     { "on", S_KEY_ON },
348     { "off", S_KEY_OFF },
349     { "t$op", S_KEY_TOP },
350     { "b$ottom", S_KEY_BOTTOM },
351     { "l$eft", S_KEY_LEFT },
352     { "r$ight", S_KEY_RIGHT },
353     { "c$enter", S_KEY_CENTER },
354     { "ver$tical", S_KEY_VERTICAL },
355     { "hor$izontal", S_KEY_HORIZONTAL },
356     { "ov$er", S_KEY_OVER },
357     { "ab$ove", S_KEY_ABOVE },
358     { "u$nder", S_KEY_UNDER },
359     { "be$low", S_KEY_BELOW },
360     { "at", S_KEY_MANUAL },
361     { "ins$ide", S_KEY_INSIDE },
362     { "o$utside", S_KEY_OUTSIDE },
363     { "tm$argin", S_KEY_TMARGIN },
364     { "bm$argin", S_KEY_BMARGIN },
365     { "lm$argin", S_KEY_LMARGIN },
366     { "rm$argin", S_KEY_RMARGIN },
367     { "L$eft", S_KEY_LLEFT },
368     { "R$ight", S_KEY_RRIGHT },
369     { "rev$erse", S_KEY_REVERSE },
370     { "norev$erse", S_KEY_NOREVERSE },
371     { "inv$ert", S_KEY_INVERT },
372     { "noinv$ert", S_KEY_NOINVERT },
373     { "enh$anced", S_KEY_ENHANCED },
374     { "noenh$anced", S_KEY_NOENHANCED },
375     { "b$ox", S_KEY_BOX },
376     { "nob$ox", S_KEY_NOBOX },
377     { "sa$mplen", S_KEY_SAMPLEN },
378     { "sp$acing", S_KEY_SPACING },
379     { "w$idth", S_KEY_WIDTH },
380     { "h$eight", S_KEY_HEIGHT },
381     { "a$utotitles", S_KEY_AUTOTITLES },
382     { "noa$utotitles", S_KEY_NOAUTOTITLES },
383     { "ti$tle", S_KEY_TITLE },
384     { NULL, S_KEY_INVALID }
385 };
386
387 /* 'test' command */
388 const struct gen_table test_tbl[] =
389 {
390     { "term$inal", TEST_TERMINAL },
391     { "pal$ette", TEST_PALETTE },
392     { "time", TEST_TIME },
393     { NULL, TEST_INVALID }
394 };
395
396 /* 'set colorbox' options */
397 const struct gen_table set_colorbox_tbl[] =
398 {
399     { "v$ertical",      S_COLORBOX_VERTICAL },
400     { "h$orizontal",    S_COLORBOX_HORIZONTAL },
401     { "def$ault",       S_COLORBOX_DEFAULT },
402     { "u$ser",          S_COLORBOX_USER },
403     { "bo$rder",        S_COLORBOX_BORDER },
404     { "bd$efault",      S_COLORBOX_BDEFAULT },
405     { "nobo$rder",      S_COLORBOX_NOBORDER },
406     { "o$rigin",        S_COLORBOX_ORIGIN },
407     { "s$ize",          S_COLORBOX_SIZE },
408     { "fr$ont",         S_COLORBOX_FRONT },
409     { "ba$ck",          S_COLORBOX_BACK },
410     { NULL, S_COLORBOX_INVALID }
411 };
412
413 /* 'set palette' options */
414 const struct gen_table set_palette_tbl[] =
415 {
416     { "pos$itive",      S_PALETTE_POSITIVE },
417     { "neg$ative",      S_PALETTE_NEGATIVE },
418     { "gray",           S_PALETTE_GRAY },
419     { "grey",           S_PALETTE_GRAY },
420     { "col$or",         S_PALETTE_COLOR },
421     { "rgb$formulae",   S_PALETTE_RGBFORMULAE },
422     { "def$ined",       S_PALETTE_DEFINED },
423     { "file",           S_PALETTE_FILE },
424     { "func$tions",     S_PALETTE_FUNCTIONS },
425     { "mo$del",         S_PALETTE_MODEL },
426     { "nops_allcF",     S_PALETTE_NOPS_ALLCF },
427     { "ps_allcF",       S_PALETTE_PS_ALLCF },
428     { "maxc$olors",     S_PALETTE_MAXCOLORS },
429     { "gam$ma",         S_PALETTE_GAMMA },
430     { NULL, S_PALETTE_INVALID }
431 };
432
433
434 const struct gen_table color_model_tbl[] =
435 {
436     { "RGB", C_MODEL_RGB },
437     { "HSV", C_MODEL_HSV },
438     { "CMY", C_MODEL_CMY },
439     { "YIQ", C_MODEL_YIQ },
440     { "XYZ", C_MODEL_XYZ },
441     { NULL,  -1 }
442 };
443
444 /* 'set pm3d' options */
445 const struct gen_table set_pm3d_tbl[] =
446 {
447     { "at",             S_PM3D_AT },
448     { "interp$olate",   S_PM3D_INTERPOLATE },
449     { "scansfor$ward",  S_PM3D_SCANSFORWARD },
450     { "scansback$ward", S_PM3D_SCANSBACKWARD },
451     { "scansauto$matic",S_PM3D_SCANS_AUTOMATIC },
452     { "dep$thorder",    S_PM3D_DEPTH },
453     { "fl$ush",         S_PM3D_FLUSH },
454     { "ftr$iangles",    S_PM3D_FTRIANGLES },
455     { "noftr$iangles",  S_PM3D_NOFTRIANGLES },
456     { "clip1$in",       S_PM3D_CLIP_1IN },
457     { "clip4$in",       S_PM3D_CLIP_4IN },
458     { "map",            S_PM3D_MAP },
459     { "hi$dden3d",      S_PM3D_HIDDEN },
460     { "nohi$dden3d",    S_PM3D_NOHIDDEN },
461     { "so$lid",         S_PM3D_SOLID },
462     { "notr$ansparent", S_PM3D_NOTRANSPARENT },
463     { "noso$lid",       S_PM3D_NOSOLID },
464     { "tr$ansparent",   S_PM3D_TRANSPARENT },
465     { "i$mplicit",      S_PM3D_IMPLICIT },
466     { "noe$xplicit",    S_PM3D_NOEXPLICIT },
467     { "noi$mplicit",    S_PM3D_NOIMPLICIT },
468     { "e$xplicit",      S_PM3D_EXPLICIT },
469     { "corners2c$olor",S_PM3D_WHICH_CORNER },
470     { NULL, S_PM3D_INVALID }
471 };
472
473 /* fixed RGB color names for 'set palette defined' */
474 const struct gen_table pm3d_color_names_tbl[] =
475 {
476     /* black, white and gray/grey */
477     { "white"           , 255*(1<<16) + 255*(1<<8) + 255 },
478     { "black"           ,   0*(1<<16) +   0*(1<<8) +   0 },
479     { "gray0"           ,   0*(1<<16) +   0*(1<<8) +   0 },
480     { "grey0"           ,   0*(1<<16) +   0*(1<<8) +   0 },
481     { "gray10"          ,  26*(1<<16) +  26*(1<<8) +  26 },
482     { "grey10"          ,  26*(1<<16) +  26*(1<<8) +  26 },
483     { "gray20"          ,  51*(1<<16) +  51*(1<<8) +  51 },
484     { "grey20"          ,  51*(1<<16) +  51*(1<<8) +  51 },
485     { "gray30"          ,  77*(1<<16) +  77*(1<<8) +  77 },
486     { "grey30"          ,  77*(1<<16) +  77*(1<<8) +  77 },
487     { "gray40"          , 102*(1<<16) + 102*(1<<8) + 102 },
488     { "grey40"          , 102*(1<<16) + 102*(1<<8) + 102 },
489     { "gray50"          , 127*(1<<16) + 127*(1<<8) + 127 },
490     { "grey50"          , 127*(1<<16) + 127*(1<<8) + 127 },
491     { "gray60"          , 153*(1<<16) + 153*(1<<8) + 153 },
492     { "grey60"          , 153*(1<<16) + 153*(1<<8) + 153 },
493     { "gray70"          , 179*(1<<16) + 179*(1<<8) + 179 },
494     { "grey70"          , 179*(1<<16) + 179*(1<<8) + 179 },
495     { "gray80"          , 204*(1<<16) + 204*(1<<8) + 204 },
496     { "grey80"          , 204*(1<<16) + 204*(1<<8) + 204 },
497     { "gray90"          , 229*(1<<16) + 229*(1<<8) + 229 },
498     { "grey90"          , 229*(1<<16) + 229*(1<<8) + 229 },
499     { "gray100"         , 255*(1<<16) + 255*(1<<8) + 255 },
500     { "grey100"         , 255*(1<<16) + 255*(1<<8) + 255 },
501     { "gray"            , 190*(1<<16) + 190*(1<<8) + 190 },
502     { "grey"            , 190*(1<<16) + 190*(1<<8) + 190 },
503     { "light-gray"      , 211*(1<<16) + 211*(1<<8) + 211 },
504     { "light-grey"      , 211*(1<<16) + 211*(1<<8) + 211 },
505     { "dark-gray"       , 169*(1<<16) + 169*(1<<8) + 169 },
506     { "dark-grey"       , 169*(1<<16) + 169*(1<<8) + 169 },
507     /* red */
508     { "red"             , 255*(1<<16) +   0*(1<<8) +   0 },
509     { "light-red"       , 240*(1<<16) +  50*(1<<8) +  50 },
510     { "dark-red"        , 139*(1<<16) +   0*(1<<8) +   0 },
511     /* yellow */
512     { "yellow"          , 255*(1<<16) + 255*(1<<8) +   0 },
513     { "light-yellow"    , 255*(1<<16) + 255*(1<<8) + 224 },
514     { "dark-yellow"     , 200*(1<<16) + 200*(1<<8) +   0 },
515     /* green */
516     { "green"           ,   0*(1<<16) + 255*(1<<8) +   0 },
517     { "light-green"     , 144*(1<<16) + 238*(1<<8) + 144 },
518     { "dark-green"      ,   0*(1<<16) + 100*(1<<8) +   0 },
519     { "spring-green"    ,   0*(1<<16) + 255*(1<<8) + 127 },
520     { "forest-green"    ,  34*(1<<16) + 139*(1<<8) +  34 },
521     { "sea-green"       ,  46*(1<<16) + 139*(1<<8) +  87 },
522     /* blue */
523     { "blue"            ,   0*(1<<16) +   0*(1<<8) + 255 },
524     { "light-blue"      , 173*(1<<16) + 216*(1<<8) + 230 },
525     { "dark-blue"       ,   0*(1<<16) +   0*(1<<8) + 139 },
526     { "midnight-blue"   ,  25*(1<<16) +  25*(1<<8) + 112 },
527     { "navy"            ,   0*(1<<16) +   0*(1<<8) + 128 },
528     { "medium-blue"     ,   0*(1<<16) +   0*(1<<8) + 205 },
529     { "royalblue"       ,  65*(1<<16) + 105*(1<<8) + 225 },
530     { "skyblue"         , 135*(1<<16) + 206*(1<<8) + 235 },
531     /* cyan */
532     { "cyan"            ,   0*(1<<16) + 255*(1<<8) + 255 },
533     { "light-cyan"      , 224*(1<<16) + 255*(1<<8) + 255 },
534     { "dark-cyan"       ,   0*(1<<16) + 139*(1<<8) + 139 },
535     /* magenta */
536     { "magenta"         , 255*(1<<16) +   0*(1<<8) + 255 },
537     { "light-magenta"   , 240*(1<<16) +  85*(1<<8) + 240 },
538     { "dark-magenta"    , 139*(1<<16) +   0*(1<<8) + 139 },
539     /* turquoise */
540     { "turquoise"       ,  64*(1<<16) + 224*(1<<8) + 208 },
541     { "light-turquoise" , 175*(1<<16) + 238*(1<<8) + 238 },
542     { "dark-turquoise"  ,   0*(1<<16) + 206*(1<<8) + 209 },
543     /* pink */
544     { "pink"            , 255*(1<<16) + 192*(1<<8) + 203 },
545     { "light-pink"      , 255*(1<<16) + 182*(1<<8) + 193 },
546     { "dark-pink"       , 255*(1<<16) +  20*(1<<8) + 147 },
547     /* coral */
548     { "coral"           , 255*(1<<16) + 127*(1<<8) +  80 },
549     { "light-coral"     , 240*(1<<16) + 128*(1<<8) + 128 },
550     { "orange-red"      , 255*(1<<16) +  69*(1<<8) +   0 },
551     /* salmon */
552     { "salmon"          , 250*(1<<16) + 128*(1<<8) + 114 },
553     { "light-salmon"    , 255*(1<<16) + 160*(1<<8) + 122 },
554     { "dark-salmon"     , 233*(1<<16) + 150*(1<<8) + 122 },
555     /* some more */
556     { "aquamarine"      , 127*(1<<16) + 255*(1<<8) + 212 },
557     { "khaki"           , 240*(1<<16) + 230*(1<<8) + 140 },
558     { "dark-khaki"      , 189*(1<<16) + 183*(1<<8) + 107 },
559     { "goldenrod"       , 218*(1<<16) + 165*(1<<8) +  32 },
560     { "light-goldenrod" , 238*(1<<16) + 221*(1<<8) + 130 },
561     { "dark-goldenrod"  , 184*(1<<16) + 134*(1<<8) +  11 },
562     { "gold"            , 255*(1<<16) + 215*(1<<8) +   0 },
563     { "beige"           , 245*(1<<16) + 245*(1<<8) + 220 },
564     { "brown"           , 165*(1<<16) +  42*(1<<8) +  42 },
565     { "orange"          , 255*(1<<16) + 165*(1<<8) +   0 },
566     { "dark-orange"     , 255*(1<<16) + 140*(1<<8) +   0 },
567     { "violet"          , 238*(1<<16) + 130*(1<<8) + 238 },
568     { "dark-violet"     , 148*(1<<16) +   0*(1<<8) + 211 },
569     { "plum"            , 221*(1<<16) + 160*(1<<8) + 221 },
570     { "purple"          , 160*(1<<16) +  32*(1<<8) + 240 },
571     { NULL, -1 }
572 };
573
574 const struct gen_table show_style_tbl[] =
575 {
576     { "d$ata", SHOW_STYLE_DATA },
577     { "f$unction", SHOW_STYLE_FUNCTION },
578     { "l$ines", SHOW_STYLE_LINE },
579     { "fill", SHOW_STYLE_FILLING },
580     { "fs", SHOW_STYLE_FILLING },
581     { "ar$row", SHOW_STYLE_ARROW },
582     { "incr$ement", SHOW_STYLE_INCREMENT },
583 #ifdef EAM_HISTOGRAMS
584     { "hist$ogram", SHOW_STYLE_HISTOGRAM },
585 #endif
586     { "rect$angle", SHOW_STYLE_RECTANGLE },
587     { NULL, SHOW_STYLE_INVALID }
588 };
589
590 const struct gen_table plotstyle_tbl[] =
591 {
592     { "l$ines", LINES },
593     { "i$mpulses", IMPULSES },
594     { "p$oints", POINTSTYLE },
595     { "linesp$oints", LINESPOINTS },
596     { "lp", LINESPOINTS },
597     { "d$ots", DOTS },
598     { "yerrorl$ines", YERRORLINES },
599     { "errorl$ines", YERRORLINES },
600     { "xerrorl$ines", XERRORLINES },
601     { "xyerrorl$ines", XYERRORLINES },
602     { "ye$rrorbars", YERRORBARS },
603     { "e$rrorbars", YERRORBARS },
604     { "xe$rrorbars", XERRORBARS },
605     { "xye$rrorbars", XYERRORBARS },
606     { "boxes", BOXES },
607 #ifdef EAM_HISTOGRAMS
608     { "hist$ograms", HISTOGRAMS },
609 #endif
610     { "filledc$urves", FILLEDCURVES },
611     { "boxer$rorbars", BOXERROR },
612     { "boxx$yerrorbars", BOXXYERROR },
613     { "st$eps", STEPS },
614     { "fs$teps", FSTEPS },
615     { "his$teps", HISTEPS },
616     { "vec$tors", VECTOR },
617     { "fin$ancebars", FINANCEBARS },
618     { "can$dlesticks", CANDLESTICKS },
619     { "pm$3d", PM3DSURFACE },
620 #ifdef EAM_DATASTRINGS
621     { "labels", LABELPOINTS },
622 #endif
623 #ifdef WITH_IMAGE
624     { "ima$ge", IMAGE },
625     { "rgbima$ge", RGBIMAGE },
626 #endif
627     { NULL, -1 }
628 };
629
630 const struct gen_table filledcurves_opts_tbl[] =
631 {
632     { "c$losed", FILLEDCURVES_CLOSED },
633     { "x1", FILLEDCURVES_X1 },
634     { "y1", FILLEDCURVES_Y1 },
635     { "x2", FILLEDCURVES_X2 },
636     { "y2", FILLEDCURVES_Y2 },
637     { "xy", FILLEDCURVES_ATXY },
638     { "above", FILLEDCURVES_ABOVE },
639     { "below", FILLEDCURVES_BELOW },
640     { NULL, -1 }
641 };
642
643 int
644 lookup_table(const struct gen_table *tbl, int find_token)
645 {
646     while (tbl->key) {
647         if (almost_equals(find_token, tbl->key))
648             return tbl->value;
649         tbl++;
650     }
651     return tbl->value; /* *_INVALID */
652 }
653
654 parsefuncp_t
655 lookup_ftable(const struct gen_ftable *ftbl, int find_token)
656 {
657     while (ftbl->key) {
658         if (almost_equals(find_token, ftbl->key))
659             return ftbl->value;
660         ftbl++;
661     }
662     return ftbl->value;
663 }
664
665 /* Returns value of the first table entry for which the search string
666  * is a leading substring, or -1 if there is no match.
667  */
668 int
669 lookup_table_entry(const struct gen_table *tbl, const char *search_str)
670 {
671     while (tbl->key) {
672         if (!strncmp(search_str, tbl->key, strlen(search_str)))
673             return tbl->value;
674         tbl++;
675     }
676     return -1;
677 }
678
679 /* Returns index of the table tbl whose key matches the beginning of the
680  * search string search_str.
681  * It returns index into the table or -1 if there is no match.
682  */
683 int
684 lookup_table_nth(const struct gen_table *tbl, const char *search_str)
685 {
686     int k = -1;
687     while (tbl[++k].key)
688         if (tbl[k].key && !strncmp(search_str, tbl[k].key, strlen(tbl[k].key)))
689             return k;
690     return -1; /* not found */
691 }
692
693 /* Returns index of the table tbl whose key matches the beginning of the
694  * search string search_str. The table_len is necessary because the table
695  * is searched in the reversed order. The routine is used in parsing commands
696  * '(un)set log x2zcb', for instance.
697  * It returns index into the table or -1 if there is no match.
698  */
699 int
700 lookup_table_nth_reverse(
701     const struct gen_table *tbl,
702     int table_len,
703     const char *search_str)
704 {
705     while (--table_len >= 0) {
706         if (tbl[table_len].key && !strncmp(search_str, tbl[table_len].key, strlen(tbl[table_len].key)))
707             return table_len;
708     }
709     return -1; /* not found */
710 }
711
712 /* Returns the key associated with this indexed value
713  * or NULL if the key/value pair is not found.
714  */
715 const char *
716 reverse_table_lookup(const struct gen_table *tbl, int entry)
717 {
718     int k = -1;
719     while (tbl[++k].key)
720         if (tbl[k].value == entry)
721             return(tbl[k].key);
722     return NULL;
723 }