forked from emacs-gnuplot/gnuplot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gnuplot-gui.el
1748 lines (1651 loc) · 68.4 KB
/
gnuplot-gui.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;;; gnuplot-gui.el -- GUI interface to setting options in gnuplot-mode
;; Copyright (C) 1998-2000 Bruce Ravel
;; Author: Bruce Ravel <[email protected]>
;; Maintainer: Bruce Ravel <[email protected]>
;; Created: 19 December 1998
;; Updated: 16 November 2000
;; Version: (same as gnuplot.el)
;; Keywords: gnuplot, plotting, interactive, GUI
;; This file is not part of GNU Emacs.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;;
;; This lisp script is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
;;
;; Permission is granted to distribute copies of this lisp script
;; provided the copyright notice and this permission are preserved in
;; all copies.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, you can either send email to this
;; program's maintainer or write to: The Free Software Foundation,
;; Inc.; 675 Massachusetts Avenue; Cambridge, MA 02139, USA.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; send bug reports to the authors ([email protected])
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;; This file provides a graphical user interface to setting arguments
;; to gnuplot commands. Positioning point near a command and invoking
;; `gnuplot-gui-set-options-and-insert' (C-c C-c or shift-mouse-2)
;; will pop open a frame with widgets for setting the various
;; arguments appropriate the the item that was near point. The goal
;; is to provide point-and-click functionality to gnuplot-mode.
;;
;; gnuplot-gui is designed for gnuplot 3.7, but since much of 3.7 is
;; backward compatible to 3.5, it will work well for that version
;; also.
;;
;; gnuplot-gui.el was developed using Emacs 19.34 and is known to work
;; on Emacs 20.x and XEmacs 20.x. I do not know what is the earliest
;; version for which it will work, but I make no guarantees for
;; versions before 19.34. Note that this makes heavy use of the
;; widget package, so this will not work on Emacs 19.34 unless you
;; install the widget package separately.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; To do:
;;
;; Widgets I need:
;; -- 'position: two or three comma separated numbers used to denote a
;; position or a tic start/end/increment (see arrow,
;; need a prefix)
;; -- 'modifier: colon separated fields used for datafile modifiers
;;
;; command types which are currently unsupported or contain mistakes
;; -- unsupported: cntrparam
;; -- plot, splot, fit: rather lame
;; -- label: position information missing
;; -- label: font string handled in overly simple manner
;; -- hidden3d: not really suited to 'list, but all options are exclusive...
;; -- pointstyle argument to "set label"
;;
;; overall:
;; -- continuation lines (ugh!)
;; -- multiple frames end up displaying same window after setting options
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Code:
(require 'gnuplot)
(eval-and-compile
(condition-case ()
(progn
(require 'widget)
(require 'wid-edit))
(error nil)))
(require 'cl)
(eval-when-compile ; suppress some compiler warnings
(defvar gnuplot-xemacs-p nil)
(defvar gnuplot-quote-character nil)
(defvar gnuplot-info-display nil)
(defvar gnuplot-mode-map nil))
;; (eval-when-compile
;; (require 'wid-edit))
(eval-and-compile ; I need this!
(if (fboundp 'split-string)
()
(defun split-string (string &optional pattern)
"Return a list of substrings of STRING which are separated by PATTERN.
If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"."
(or pattern
(setq pattern "[ \f\t\n\r\v]+"))
;; The FSF version of this function takes care not to cons in case
;; of infloop. Maybe we should synch?
(let (parts (start 0))
(while (string-match pattern string start)
(setq parts (cons (substring string start (match-beginning 0)) parts)
start (match-end 0)))
(nreverse (cons (substring string start) parts)))) ))
;;; customizable variables
(defgroup gnuplot-gui nil
"Graphical interface to setting arguments in gnuplot scrips."
:prefix "gnuplot-gui-"
:group 'gnuplot)
(defcustom gnuplot-gui-popup-flag nil
"*Non-nil means to open arguments pop-ups automatically.
This would be done after menu insertion of Gnuplot commands."
:group 'gnuplot-gui
:type 'boolean)
(defvar gnuplot-gui-frame nil
"Frame used to hold the buffer for setting options.")
(defcustom gnuplot-gui-frame-plist
'(height 18 width 65 border-width 0
user-position t top 150 left 150
internal-border-width 0 unsplittable t
default-toolbar-visible-p nil has-modeline-p nil
menubar-visible-p nil)
"Frame plist for the input run-time display frame in XEmacs."
:type '(repeat (group :inline t
(symbol :tag "Property")
(sexp :tag "Value")))
:group 'gnuplot-gui)
(defcustom gnuplot-gui-frame-parameters
'((height . 18)
(width . 65)
(user-position . t)
(top . 150)
(left . 150)
(border-width . 0)
(menu-bar-lines . 0)
(unsplittable . t))
"Frame parameters for the input run-time display frame in Emacs."
:group 'gnuplot-gui
:type '(repeat (sexp :tag "Parameter:")))
(defcustom gnuplot-gui-fontname-list
'(" " "\"Helvetica\"" "\"Times-Roman\"")
"List of known font names.
These *must* be quoted, like so \"\\\"Helvetica\\\"\". This allows
for fonts with names like \"\\\"Arial Bold Italic\\\"\" to be treated
as single entries in the menu-buttons. And it is really important that
the first entry in the list be a blank string."
:group 'gnuplot-gui
:type '(repeat (string :tag "Font name:")))
;; some global variables
(defvar gnuplot-current-frame nil)
(defvar gnuplot-current-buffer nil)
(defvar gnuplot-current-buffer-point nil)
(defvar gnuplot-gui-alist nil)
(defvar gnuplot-gui-current-string nil)
;;; various tools for handling data structures and text in the buffer
;; tools for accessing the elements of the lists in `gnuplot-gui-all-types'
(defsubst gnuplot-gui-type-tag (obj) (elt obj 0))
(defsubst gnuplot-gui-type-symbol (obj) (elt obj 1))
(defsubst gnuplot-gui-type-default (obj) (elt obj 2))
(defsubst gnuplot-gui-type-prefix (obj) (elt obj 3)) ; also 'range seperator
(defsubst gnuplot-gui-type-fourth (obj) (elt obj 4))
(defsubst gnuplot-gui-type-list (obj) (cddr obj))
(defun gnuplot-this-word ()
"Return the word under point."
(let ((begin (save-excursion (beginning-of-line) (point-marker)))
(end (save-excursion (end-of-line) (point-marker))))
(save-excursion
(or (looking-at "\\<") (= (current-column) 0) (forward-word -1))
(if (> (point) begin) (setq begin (point-marker)))
(forward-word 1)
(if (> (point) end) (goto-char end))
(buffer-substring-no-properties begin (point)))))
;;; data structures containing regarding options in Gnuplot 3.7
;; various constants used for options that take the same sorts of arguments
(defconst gnuplot-gui-mtics-list
'(("FREQUENCY" 'number " ")
("DEFAULT" 'list " " "default")))
(defconst gnuplot-gui-data-list
'(("DATA TYPE" 'list " " "time")))
(defconst gnuplot-gui-label-list
'(("LABEL" 'string " ")
("POSITION" 'position " " "" 2)
("FONTNAME" 'list " " gnuplot-gui-fontname-list)
("FONTSIZE" 'fontsize " ")))
(defconst gnuplot-gui-range-list
'(("RANGE" 'range (" " . " ") ":")
("REVERSE" 'list " " "reverse" "noreverse")
("WRITEBACK" 'list " " "writeback" "nowriteback")))
(defconst gnuplot-gui-tics-list
'(("WHERE" 'list " " "axis" "border")
("MIRROR" 'list " " "mirror" "nomirror")
("ROTATE" 'list " " "rotate" "norotate")
("SERIES" 'position " " "" 3)
("LABEL ARRAY" 'labels () )))
(defconst gnuplot-gui-zeroaxis-list
'(("LINETYPE" 'number " ")))
(defvar gnuplot-gui-terminal-types nil
"Associated list of terminal descriptions.
See the doc-string for `gnuplot-gui-all-types'.")
(setq gnuplot-gui-terminal-types
(list (cons "aifm"
'(("COLOR" 'list " " "monochrome" "gray" "color")
("FONTNAME" 'list " " gnuplot-gui-fontname-list)
("FONTSIZE" 'fontsize " ")))
(cons "cgm"
'(("MODE" 'list " " "landscape" "portrait" "default")
("COLOR" 'list " " "color" "monochrome")
("ROTATION" 'list " " "rotate" "norotate")
("WIDTH" 'number " " "width")
("LINEWIDTH" 'number " " "linewidth")
("FONTNAME" 'list " " "\"Arial\"" "\"Arial Italic\""
"\"Arial Bold\"" "\"Arial Bold Italic\""
"\"Times Roman\"" "\"Times Roman Italic\""
"\"Times Roman Bold\"" "\"Times Roman Bold Italic\""
"\"Helvetica\"" "\"Roman\"")
("FONTSIZE" 'fontsize " ")))
(cons "corel"
'(("COLOR" 'list " " "default" "color" "monochrome")
("FONTNAME" 'list " " "\"SwitzerlandLight\""
"\"Helvetica\"" "\"Times-Roman\"")
("FONTSIZE " 'number " ")
("X-SIZE " 'number " ")
("Y-SIZE " 'number " ")
("LINEWIDTH" 'number " ")))
(cons "dumb"
'(("LINEFEED" 'list " " "feed" "nofeed")
("X-SIZE" 'number " ")
("Y-SIZE" 'number " ")))
(cons "emf"
'(("COLOR" 'list " " "color" "monochrome")
("LINE" 'list " " "solid" "dashed")
("FONTNAME" 'string " ")
("FONTSIZE" 'number " ")))
(cons "emtex"
'(("FONTNAME" 'list " " "courier" "roman")
("FONTSIZE" 'fontsize " ")))
(cons "fig"
'(("COLOR" 'list " " "color" "monochrome")
("FRAMESIZE" 'list " " "small" "big")
("POINTSMAX" 'number " " "pointsmax")
("ORIENTATION" 'list " " "landscape" "portrait")
("UNITS" 'list " " "metric" "inches")
("FONT SIZE" 'number " " "fontsize")
("SIZE" 'pair (" " . " ") "size")
("LINE THICKNESS" 'number " " "thickness")
("LAYER DEPTH" 'number " " "depth")))
(cons "hp500c"
'(("RESOLUTION" 'list " " "75" "100" "150" "300")
("COMPRESSION" 'list " " "rle" "tiff")))
(cons "hpgl"
'(("PENS" 'number " ")
("EJECT" 'list " " "eject")))
(cons "hpdj"
'(("RESOLUTION" 'list " " "75" "100" "150" "300")))
(cons "hpljii"
'(("RESOLUTION" 'list " " "75" "100" "150" "300")))
(cons "hppj"
'(("FONT" 'list " " "FNT9X17" "FNT5X9" "FNT13X25")))
(cons "imagen"
'(("FONT SIZE" 'number " ")
("LAYOUT" 'list " " "portrait" "landscape")
("NUMBER OF GRAPHS" 'range (" " . " ") ",")))
(cons "gpic"
'(("X ORIGIN" 'number " ")
("Y ORIGIN" 'number " " ",")))
(cons "latex"
'(("FONTNAME" 'list " " "courier" "roman")
("FONTSIZE" 'fontsize " ")))
(cons "mif"
'(("COLOUR" 'list " " "colour" "monochrome")
("LINETYPE" 'list " " "polyline" "vectors")))
(cons "nec-cp6"
'(("MODE" 'list " " "monochrome" "colour" "draft")))
(cons "pbm"
'(("SIZE" 'list " " "small" "medium" "large")
("COLOR" 'list " " "monochrome" "gray" "color")))
(cons "pcl5L"
'(("MODE" 'list " " "landscape" "portrait")
("FONTNAME" 'list " " "stick" "univers" "cg_times")
("FONTSIZE" 'fontsize " ")))
(cons "png"
'(("SIZE" 'list " " "small" "medium" "large")
("COLOR" 'list " " "monochrome" "gray" "color")))
(cons "postscript"
'(("MODE" 'list " " "landscape" "portrait" "eps" "default")
("ENHANCED" 'list " " "enhanced" "noenhanced")
("COLOR" 'list " " "color" "monochrome")
("SOLID" 'list " " "solid" "dashed")
("DUPLEXING" 'list " " "defaultplex" "simplex" "duplex")
("FONTNAME" 'list " " gnuplot-gui-fontname-list)
("FONTSIZE" 'fontsize " ")))
(cons "pslatex"
'(("COLOR" 'list " " "monochrome" "color")
("DASHED" 'list " " "dashed")
("ROTATION" 'list " " "rotate" "norotate")
("AUXFILE" 'list " " "auxfile")))
(cons "pstex"
'(("COLOR" 'list " " "monochrome" "color")
("DASHED" 'list " " "dashed")
("ROTATION" 'list " " "rotate" "norotate")
("AUXFILE" 'list " " "auxfile")))
(cons "pstricks"
'(("HACK TEXT" 'list " " "hacktext" "nohacktext")
("PLOT SCALING" 'list " " "nounit" "unit")))
(cons "regis"
'(("COLOR DEPTH" 'list "4" "16")))
(cons "tgif"
'(("LAYOUT" 'list " " "portrait" "landscape")
("NUMBER OF GRAPHS" 'range (" " . " ") ",")
("LINE TYPE" 'list " " "solid" "dashed")
("FONTNAME" 'list " " gnuplot-gui-fontname-list)
("FONTSIZE" 'fontsize " ")))
(cons "tpic"
'(("POINTSIZE" 'number " ")
("LINEWIDTH" 'number " ")
("INTERVAL " 'number " ")))
(cons "vgagl" ; for pm3d patch (also persist, raise in x11) <MT>
'(("BACKGROUND" 'position " " "background" 3)
("INTERPOLATION" 'list " " "uniform" "interpolate")
("DUMP" 'file " ")
("MODE" 'string " " "")))
(cons "x11"
'(("RESET" 'list " " "reset")
("TERMINAL NUMBER" 'number " ")
("PERSIST" 'list " " "persist" "nopersist")
("RAISE" 'list " " "raise" "noraise"))) ))
(defvar gnuplot-gui-terminal-list nil)
(setq gnuplot-gui-terminal-list
(append (list " ") (mapcar 'car gnuplot-gui-terminal-types)))
(defvar gnuplot-gui-set-types nil
"Associated list of set option descriptions.
See the doc-string for `gnuplot-gui-all-types'.")
(setq gnuplot-gui-set-types
(list (cons "angles"
'(("UNITS" 'list " " "degrees" "radians")))
(cons "arrow"
'(("TAG" 'tag " ")
("FROM" 'position " " "from" 3)
("TO" 'position " " "to" 3)
("HEAD" 'list " " "head" "nohead")
("LINESTYLE" 'number " " "ls")
("LINETYPE " 'number " " "lt")
("LINEWIDTH" 'number " " "lw")))
(cons "noarrow"
'(("TAG" 'tag " ")))
(cons "autoscale"
'(("AXIS" 'list " " "x" "y" "z" "x2" "y2" "xy"
"xmin" "ymin" "zmin" "x2min" "y2min" "xymin"
"xmax" "ymax" "zmax" "x2max" "y2max" "xymax")))
(cons "noautoscale"
'(("AXIS" 'list " " "x" "y" "z" "x2" "y2" "xy"
"xmin" "ymin" "zmin" "x2min" "y2min" "xymin"
"xmax" "ymax" "zmax" "x2max" "y2max" "xymax")))
(cons "bar"
'(("SIZE" 'list " " "small" "large")))
(cons "border"
'(("BORDER CODE" 'number " ")
("LINE STYLE" 'list " " "lines"
"dots" "points" "linespoints")
("LINESTYLE" 'number " " "ls")
("LINETYPE" 'number " " "lt")
("LINEWIDTH" 'number " " "lw")
))
(cons "boxwidth"
'(("WIDTH" 'number " ")))
(cons "clabel"
'(("FORMAT" 'format " ")))
(cons "clip"
'(("CLIP TYPE" 'list " " "points" "one" "two")))
(cons "noclip"
'(("CLIP TYPE" 'list " " "points" "one" "two")))
;;(cons "cntrparam"
;; '(("INTERPOLATION" 'list " " "linear" "cubicspline" "bspline")
;; ("POINTS" 'number " " "points")
;; ("ORDER" 'number " " "order")))
(cons "contour"
'(("WHERE" 'list " " "base" "surface" "both")))
(cons "dgrid3d"
'(("ROW,COLUMN,NORM" 'position " " "" 3)))
(cons "encoding"
'(("ENCODING" 'list " " "default" "iso_8859_1"
"cp850" "cp437")))
(cons "format"
'(("AXIS" 'list " " "x" "y" "z" "xy" "x2" "y2")
("FORMAT" 'format " ")))
(cons "dummy"
'(("VAR 1" 'string " " "")
("VAR 2" 'string " " ",")))
(cons "grid"
'(("XTICS" 'list " " "xtics" "mxtics" "noxtics" "nomxtics")
("YTICS" 'list " " "ytics" "mytics" "noytics" "nomytics")
("ZTICS" 'list " " "ztics" "mztics" "noztics" "nomztics")
("X2TICS" 'list " " "x2tics" "mx2tics" "nox2tics" "nomx2tics")
("Y2TICS" 'list " " "y2tics" "my2tics" "noy2tics" "nomy2tics")
("POLAR" 'number " " "polar")
("MAJOR LINETYPE" 'number " ")
("MINOR LINETYPE" 'number " ")))
(cons "hidden3d"
'(("ALGORITHM" 'list " " "defaults"
"offset"
"nooffset"
;;"trianglepattern # bitpattern between 0 and 7"
"trianglepattern 0" "trianglepattern 1"
"trianglepattern 2" "trianglepattern 3"
"trianglepattern 4" "trianglepattern 5"
"trianglepattern 6" "trianglepattern 7"
;;"undefined # level between 0 and 3"
"undefined 0" "undefined 1" "undefined 2" "undefined 3"
"noundefined" "altdiagonal" "noaltdiagonal"
"bentover" "nobentover")))
(cons "historysize"
'(("SIZE" 'number " ")))
(cons "isosamples"
'(("ISO_U LINES" 'number " ")
("ISO_V LINES" 'number " " ",")))
(cons "key"
'(("LOCATION" 'list " " "left" "right" "top" "bottom"
"outside" "below")
("POSITION" 'position " " "" 3)
("JUSTIFICATION" 'list " " "Left" "Right")
("REVERSE" 'list " " "reverse" "noreverse")
("SAMPLE LENGTH" 'number " " "samplen")
("SPACING" 'number " " "spacing")
("WIDTH" 'number " " "width")
("TITLE" 'string " " "title ")
("BOX LINETYPE" 'number " " "box") ;; linetype data
("NOBOX" 'list " " "nobox")))
(cons "label"
'(("TAG" 'tag " ")
("LABEL TEXT" 'string " ")
("POSITION" 'position " " "at" 3)
;; first, second, graph, screen
("JUSTIFICATION" 'list " " "left" "right" "center")
("ROTATE" 'list " " "rotate" "norotate")
("FONT" 'string " " "font"))) ;; font "name,size"
(cons "nolabel"
'(("TAG" 'tag " ")))
(cons "linestyle"
'(("TAG " 'tag " ")
("LINE STYLE" 'list " " "boxerrorbars" "boxes"
"boxxyerrorbars" "candlesticks" "dots"
"financebars" "fsteps" "histeps" "impulses"
"lines" "linespoints" "points" "steps" "vector"
"xerrorbars" "xyerrorbars" "yerrorbars")
("LINETYPE " 'number " " "lt")
("LINEWIDTH" 'number " " "lw")
("POINTTYPE" 'number " " "pt")
("POINTSIZE" 'number " " "ps")))
(cons "locale"
'(("LOCALE" 'string " ")))
(cons "logscale"
'(("AXIS" 'list " " "x" "y" "z" "xy" "xz" "yz" "xyz"
"x2" "y2")
("BASE" 'number " ")))
(cons "nologscale"
'(("AXIS" 'list " " "x" "y" "z" "xy" "xz" "yz" "xyz"
"x2" "y2")))
(cons "mapping"
'(("COORDINATE SYSTEM" 'list " " "cartesian" "spherical"
"cylindrical")))
; _margin
(cons "bmargin"
'(("BOTTOM MARGIN" 'number " ")))
(cons "lmargin"
'(("LEFT MARGIN" 'number " ")))
(cons "rmargin"
'(("RIGHT MARGIN" 'number " ")))
(cons "tmargin"
'(("TOP MARGIN" 'number " ")))
(cons "missing"
'(("CHARACTER" 'string " " 1)))
; m_tics
(cons "mxtics" gnuplot-gui-mtics-list)
(cons "mytics" gnuplot-gui-mtics-list)
(cons "mztics" gnuplot-gui-mtics-list)
(cons "mx2tics" gnuplot-gui-mtics-list)
(cons "my2tics" gnuplot-gui-mtics-list)
; pm3d additions <MT>
(cons "mouse"
'(("DOUBLECLICK" 'number " " "doubleclick")
("ZOOM" 'list " " "zoomcoordinates" "nozoomcoordinates")
("POLAR" 'list " " "polarcoordinates" "nopolarcoordinates")
("FORMAT" 'string " " "format")
("CLIPBOARDFORMAT" 'string " " "clipboardformat")
("MOUSEFORMAT" 'string " " "mouseformat")
("LABELS" 'list " " "labels" "nolabels")
("LABELOPTIONS" 'string " " "labeloptions")
("ZOOMJUMP" 'list " " "zoomjump" "nozoomjump")
("VERBOSE" 'list " " "verbose" "noverbose")))
(cons "palette"
'(("COLOR" 'list " " "gray" "color")
("RGBFORMULAE" 'position " " "rgbformulae" 3)
("PARITY" 'list " " "positive" "negative")
("FORMULAE" 'list " " "nops_allcF" "ps_allcF")
("MAXCOLORS" 'number " ")
("COLOR_BOX" 'list " " "nocb" "cbdefault" "cbuser")
("ORIENTATION" 'list " " "cbvertical" "cbhorizontal")
("ORIGIN" 'position " " "origin" 2)
("SIZE" 'position " " "size" 2)
("BORDER" 'number " ")
("NOBORDER" 'list " " "bdefault" "noborder")))
(cons "pm3d"
'(("AT" 'list* " " "b" "s" "t" "bs" "bt" "st" "bst")
("SCANS" 'list " " "scansautomatic" "scansforward" "scansbackward")
("FLUSH" 'list* " " "begin" "center" "end")
("CLIP" 'list " " "clip1in" "clip4in")
("ZRANGE" 'range (" " . " ") ":")
("HIDDEN3D" 'number " ")
("NOHIDDEN3D" 'list " " "nohidden3d")
("FILLING" 'list " " "transparent" "solid")
("MAP" 'list " " "map")))
(cons "offsets"
'(("LEFT " 'number " ")
("RIGHT " 'number " " ",")
("TOP " 'number " " ",")
("BOTTOM" 'number " " ",")))
(cons "origin"
'(("X ORIGIN" 'number " ")
("Y ORIGIN" 'number " " ",")))
(cons "output"
'(("FILENAME" 'file " ")))
(cons "pointsize"
'(("MULTIPLIER" 'number " ")))
(cons "samples"
'(("2D PLOT" 'number " ")
("3D PLOT" 'number " " ",")))
(cons "size"
'(("ASPECT" 'list " " "square" "nosquare"
"ratio" "noratio")
("X-SCALE OR RATIO" 'number " ")
("Y-SCALE" 'number " " ",")))
(cons "style"
'(("DATA TYPE" 'list " " "data" "function")
("PLOT STYLE" 'list " " "boxerrorbars" "boxes"
"boxxyerrorbars" "candlesticks" "dots"
"financebars" "fsteps" "histeps" "impulses"
"lines" "linespoints" "points" "steps" "vector"
"xerrorbars" "xyerrorbars" "yerrorbars")))
(cons "terminal"
'(("TERMINAL TYPE" 'list " " gnuplot-gui-terminal-list)))
(cons "tics"
'(("DIRECTION" 'list " " "in" "out")))
(cons "ticslevel"
'(("RELATIVE HEIGHT" 'number " ")))
(cons "ticscale"
'(("MAJOR" 'number " ")
("MINOR" 'number " ")))
(cons "timestamp"
'(("FORMAT STRING" 'format " ")
("WHERE" 'list " " "top" "bottom")
("ROTATE" 'list " " "rotate" "norotate")
("X-OFFSET" 'number " ")
("Y-OFFSET" 'number " " ",")
("FONTNAME" 'list " " gnuplot-gui-fontname-list)))
(cons "timefmt"
'(("FORMAT STRING" 'string " ")))
(cons "title"
'(("TITLE" 'string " ")))
(cons "view"
'(("X-ROTATION" 'number " ")
("Z-ROTATION" 'number " " ",")
("SCALE" 'number " " ",")
("Z-SCALE" 'number " " ",")))
;; ("SCALE" 'position " " "," 4)
; _data
(cons "xdata" gnuplot-gui-data-list)
(cons "ydata" gnuplot-gui-data-list)
(cons "zdata" gnuplot-gui-data-list)
(cons "x2data" gnuplot-gui-data-list)
(cons "y2data" gnuplot-gui-data-list)
; _label
(cons "xlabel" gnuplot-gui-label-list)
(cons "ylabel" gnuplot-gui-label-list)
(cons "zlabel" gnuplot-gui-label-list)
(cons "x2label" gnuplot-gui-label-list)
(cons "y2label" gnuplot-gui-label-list)
; _range, note that the [] syntax for
; the writeback argument is
; not properly supported
(cons "xrange" gnuplot-gui-range-list)
(cons "yrange" gnuplot-gui-range-list)
(cons "zrange" gnuplot-gui-range-list)
(cons "x2range" gnuplot-gui-range-list)
(cons "y2range" gnuplot-gui-range-list)
(cons "trange" gnuplot-gui-range-list)
(cons "rrange" gnuplot-gui-range-list)
(cons "urange" gnuplot-gui-range-list)
(cons "vrange" gnuplot-gui-range-list)
; _tics
(cons "xtics" gnuplot-gui-tics-list)
(cons "ytics" gnuplot-gui-tics-list)
(cons "ztics" gnuplot-gui-tics-list)
(cons "x2tics" gnuplot-gui-tics-list)
(cons "y2tics" gnuplot-gui-tics-list)
; zeroaxis
(cons "zeroaxis" gnuplot-gui-zeroaxis-list)
(cons "xzeroaxis" gnuplot-gui-zeroaxis-list)
(cons "yzeroaxis" gnuplot-gui-zeroaxis-list)
(cons "y2zeroaxis" gnuplot-gui-zeroaxis-list)
(cons "x2zeroaxis" gnuplot-gui-zeroaxis-list)
(cons "zero"
'(("THRESHOLD" 'number " ")))
))
(defvar gnuplot-gui-command-types nil
"Associated list of command descriptions.
See the doc-string for `gnuplot-gui-all-types'.")
(setq gnuplot-gui-command-types
(list (cons "cd"
'(("FILENAME" 'file " ")))
(cons "call"
'(("INPUT FILE" 'file " ")
("PARAMETER LIST" 'string " ")))
(cons "load"
'(("INPUT FILE" 'file " ")))
(cons "pause"
'(("TIME" 'number " ")
("MESSAGE" 'string " ")))
(cons "print"
'(("EXPRESSION" 'string " ")))
(cons "save"
'(("SAVE" 'list " " "functions" "variables" "set")
("FILE" 'file " ")))
(cons "update"
'(("INITIAL FILE" 'file " " t)
("UPDATED FILE" 'file " " t))) ))
(defcustom gnuplot-gui-plot-splot-fit-style 'simple
"Control the complexity of the GUI display for plot, splot, and fit.
The values are 'simple, which causes a limited set of plot, splot, or
fit options to be displayed, and 'complete, which attempts to display
all options. The 'complete setting is prone to making errors when
parsing values already in the script buffer."
:group 'gnuplot-gui
:type '(radio (const :tag "Simple listing" simple)
(const :tag "Complete listing" complete)))
(defconst gnuplot-gui-plot-simple-list
'(("X RANGE" 'range (" " . " ") ":")
("Y RANGE" 'range (" " . " ") ":")
("DATA FILE" 'file " ")
("THRU" 'string* " " "thru")
("USING" 'modifier " ")
("TITLE" 'string " ")
("WITH" 'list* " " "boxerrorbars" "boxes"
"boxxyerrorbars" "candlesticks" "dots" "financebars"
"fsteps" "histeps" "impulses" "lines" "linespoints"
"points" "steps" "vector" "xerrorbars" "xyerrorbars"
"yerrorbars")))
(defconst gnuplot-gui-plot-full-list
'(;;("T RANGE" 'range (" " . " ") ":")
("X RANGE" 'range (" " . " ") ":")
("Y RANGE" 'range (" " . " ") ":")
("xa" 'text "\t---------------------")
("FUNCTION" 'string " ")
("xc" 'text " or")
("DATA FILE" 'file " ")
("INDEX" 'modifier " ")
("EVERY" 'modifier " ")
("THRU" 'string* " " "thru")
("USING" 'modifier " ")
("SMOOTH" 'list* " " "unique" "csplines" "acsplines"
"bezier" "sbezier")
;; datafile modifiers
("AXES" 'list* " " "x1y1" "x2y2" "x1y2" "x2y1")
("TITLE" 'string " ")
("NOTITLE" 'list " " "notitle")
("xf" 'text "\t---------------------")
("xi" 'text "Select a standard plotting style")
("WITH" 'list* " " "boxerrorbars" "boxes"
"boxxyerrorbars" "candlesticks" "dots" "financebars"
"fsteps" "histeps" "impulses" "lines" "linespoints"
"points" "steps" "vector" "xerrorbars" "xyerrorbars"
"yerrorbars")
("xo" 'text " or a previously defined style")
("LINE STYLE " 'number " " "ls")
("xr" 'text " or specify a style in-line")
("LINE TYPE " 'number " " "lt")
("LINE WIDTH " 'number " " "lw")
("POINT TYPE " 'number " " "pt")
("POINT STYLE" 'number " " "ps")
))
(defconst gnuplot-gui-splot-simple-list
'(("DATA FILE" 'file " ")
("TITLE" 'string " ")
("WITH" 'list* " " "lines" "linespoints" "points" "dots" "impulses")))
(defconst gnuplot-gui-splot-full-list
'(;;("U RANGE" 'range (" " . " ") ":")
;;("V RANGE" 'range (" " . " ") ":")
("X RANGE" 'range (" " . " ") ":")
("Y RANGE" 'range (" " . " ") ":")
("Z RANGE" 'range (" " . " ") ":")
("xa" 'text "\t---------------------")
("FUNCTION" 'string " ")
("xc" 'text " or")
("DATA FILE" 'file " ")
("INDEX" 'modifier " ")
("EVERY" 'modifier " ")
("THRU" 'string* " " "thru")
("USING" 'modifier " ")
("SMOOTH" 'list* " " "unique" "csplines" "acsplines"
"bezier" "sbezier")
("TITLE" 'string " ")
("NOTITLE" 'list " " "notitle")
("WITH" 'list* " " "lines" "linespoints" "points" "dots" "impulses")))
(defconst gnuplot-gui-fit-simple-list
'(("FUNCTION" 'string* " " "")
("DATA FILE" 'file " ")
("VIA (params)" 'string* " " "via") ))
(defconst gnuplot-gui-fit-full-list
'(("X RANGE" 'range (" " . " ") ":")
("Y RANGE" 'range (" " . " ") ":")
("xa" 'text "----- fitting functionn and file --------")
("FUNCTION" 'string* " " "")
("DATA FILE" 'file " ")
("xb" 'text "----- datafile modifiers ----------------")
("INDEX" 'modifier " ")
("EVERY" 'modifier " ")
("THRU" 'string* " " "thru")
("USING" 'modifier " ")
("SMOOTH" 'list* " " "unique" "csplines" "acsplines"
"bezier" "sbezier")
("xc" 'text "----- parameters (file or parameters) ---")
("VIA (file)" 'string " " "via")
("VIA (params)" 'string* " " "via") ))
(defvar gnuplot-gui-plot-splot-fit nil
"Associated list of plot, splot, and fit descriptions.
See the doc-string for `gnuplot-gui-all-types'.")
(setq gnuplot-gui-plot-splot-fit
(list (cons "plot" (if (equal gnuplot-gui-plot-splot-fit-style 'complete)
gnuplot-gui-plot-full-list
gnuplot-gui-plot-simple-list))
(cons "splot" (if (equal gnuplot-gui-plot-splot-fit-style 'complete)
gnuplot-gui-splot-full-list
gnuplot-gui-splot-simple-list))
(cons "fit" (if (equal gnuplot-gui-plot-splot-fit-style 'complete)
gnuplot-gui-fit-full-list
gnuplot-gui-fit-simple-list))) )
(defvar gnuplot-gui-test-type nil)
(setq gnuplot-gui-test-type
(list (cons "test"
'(("TAG" 'tag " ")
("LIST" 'list " " "1" "2" "3")
("LIST*" 'list* " " "1" "2" "3")
("NUMBER" 'number " " "number")
("RANGE" 'range (" " . " ") ":")
("PAIR" 'pair (" " . " ") "pair")
("LABELS" 'labels ())
("FILE" 'file " ")
("TEXT" 'text "this is text")
("STRING" 'string " ")
("STRING*" 'string* " " "string*")
("FORMAT" 'format " ")
("POSITION" 'position " " "at" 3)
("FONTSIZE" 'fontsize " ") ))))
(defvar gnuplot-gui-all-types nil
"Associated list of terminal, set option, and command arguments.
Each entry in the list is a cons cell of the form
(OPTION . ALIST)
where OPTION is one of the recognized options in Gnuplot, either a
command, something that is set, or a terminal type. Only those
commands, set options, and terminal types that actually take arguments
are in this associated list.
ALIST is itself an associated list where each entry is of the form:
(TAG TYPE DEFAULT REST)
TAG is the name used on the widget and indicates one of the options
for this command, set option, or terminal type.
TYPE is one of
'list a menu-list of strings
'list* a menu-list of strings with a prefix
'number a number with an optional prefix
'tag like number but must be the first argument
'fontsize like number but must be the last argument
'range a pair of numbers like [#,#] or [#:#]
'pair a pair of numbers with no punctuation and a prefix
'file a quoted string and a file browser
'string a quoted string with an optional prefix
'string* an unquoted string with a prefix
'format a quoted string and an info-link to (gnuplot)format
'labels an array as needed for xtics, ytics, etc
'position 2 or 3 comma separated numbers with an optional prefix
DEFAULT is the default value for this option. Note that the default
for 'range and 'pair is a cons cell and the default for 'labels is a
list. For most things, the best choice of DEFAULT is a string of
white space or a cons cell of two strings of white space. Strings of
white space are better defaults than empty strings or nil.
The value of REST depends upon TYPE:
For 'list & REST is the list of options that will go into the
'list* menu-button. This can also be a symbol which
evaluates to a list containing the options to go into
the menu-button. This list variable must contain the
DEFAULT.
For 'number REST is the prefix string (if it exists) for that number.
For 'range REST is the separator, \":\" for plot ranges and
\",\" for plot dimensions (see for example the tgif
terminal type)
For 'string & REST may a number denoting the width of the editable-text
'string* field or it may be a string denoting a prefix. By
default, the width is half the width of the frame
and there is no prefix. It may be useful to
specify \"1\" when the input is a single character
as in 'set missing'.
For 'file REST determines the label placed before the file insertion
field. If non-nil, then TAG is used. If nil, then
the default \"File\" is used.
For 'position REST is the prefix and the number of comma separated numbers
For others REST is not used.
Here is an example entry for the png terminal type:
(cons \"png\"
'((\"SIZE\" 'list \" \" \"small\" \"medium\" \"large\")
(\"COLOR\" 'list \" \" \"monochrome\" \"gray\" \"color\")))
This alist is formed at load time by appending together
`gnuplot-gui-terminal-types', `gnuplot-gui-set-types' and
`gnuplot-gui-command-types'.")
(setq gnuplot-gui-all-types (append gnuplot-gui-terminal-types
gnuplot-gui-set-types
gnuplot-gui-command-types
gnuplot-gui-plot-splot-fit
gnuplot-gui-test-type
))
(defun gnuplot-gui-swap-simple-complete ()
(interactive)
(setq gnuplot-gui-plot-splot-fit-style
(if (equal gnuplot-gui-plot-splot-fit-style 'complete)
'simple 'complete))
(if (equal gnuplot-gui-plot-splot-fit-style 'complete)
(progn
(setcdr (assoc "plot" gnuplot-gui-all-types) gnuplot-gui-plot-full-list)
(setcdr (assoc "splot" gnuplot-gui-all-types) gnuplot-gui-splot-full-list)
(setcdr (assoc "fit" gnuplot-gui-all-types) gnuplot-gui-fit-full-list))
(setcdr (assoc "plot" gnuplot-gui-all-types) gnuplot-gui-plot-simple-list)
(setcdr (assoc "splot" gnuplot-gui-all-types) gnuplot-gui-splot-simple-list)
(setcdr (assoc "fit" gnuplot-gui-all-types) gnuplot-gui-fit-simple-list))
(message "Using %s lists for plot, splot, and fit."
gnuplot-gui-plot-splot-fit-style) )
;;; user interface to the widget-y stuff
(defun gnuplot-gui-mouse-set (event)
"Use the mouse to begin setting options using a GUI interface.
EVENT is a mouse event. Bound to \\[gnuplot-gui-mouse-set]
Note that \"plot\", \"splot\", \"fit\", and \"cntrparam\" are not
currently supported."
(interactive "@e")
(when (fboundp 'widget-create)
(save-excursion
(mouse-set-point event)
(gnuplot-gui-set-options-and-insert))))
(defun gnuplot-gui-get-frame-param (param)
(if gnuplot-xemacs-p
(plist-get gnuplot-gui-frame-plist param)
(cdr (assoc param gnuplot-gui-frame-parameters))))
(defun gnuplot-gui-set-frame-param (param value)
(if gnuplot-xemacs-p
(plist-put gnuplot-gui-frame-plist param value)
(setcdr (assoc param gnuplot-gui-frame-parameters) value)))
(defun gnuplot-gui-set-options-and-insert ()
"Insert arguments using a GUI interface.
Determine contents of current line and set up the appropriate GUI
frame. Bound to \\[gnuplot-gui-set-options-and-insert]
Note that \"cntrparam\" is not currently supported."
(interactive)
(when (fboundp 'widget-create)
(let ((begin (gnuplot-point-at-beginning-of-command))
(end (save-excursion (end-of-line) (point-marker)))
(termin (concat "\\(,\\s-*" (regexp-quote "\\") "\\|;\\)"))
(set nil) (term nil))
(save-excursion
;; there can be more then one command per line
(if (re-search-forward termin end "to_limit")
(progn (backward-char (length (match-string 1)))
(setq end (point-marker))))
(goto-char begin)
(skip-syntax-forward "-" end)
;; various constructions are recognized here. at the end of this
;; cond, point should be just after the word whose arguments are
;; to be set
(cond ((looking-at "set\\s-+")
(setq set t)
(goto-char (match-end 0))
(if (looking-at "\\sw+") (goto-char (match-end 0)))
(when (string-match "^ter" (gnuplot-this-word)) ; terminal?
(setq term t)
(forward-word 1))
(when (string-match "^\\(da\\|fu\\)" (gnuplot-this-word))
(unless (looking-at "\\s-+st")
(insert " style") (forward-word 1))
(forward-word 1)))
((looking-at (concat "\\(cd\\|ca\\|lo\\|pa\\|pr\\|sa\\|u\\)"
"\\w*"
"[\\s-\\']"))
(forward-word 1))
;;(goto-char (match-end 0)))
(t
(forward-word 1)))
(if (> (point) end) (goto-char end))
(let* ((w (gnuplot-this-word))
(wd (try-completion w gnuplot-gui-all-types))
(word "") wrd list)
(cond ((equal wd t) (setq word w))
((equal wd nil) (setq word w))
((assoc wd gnuplot-gui-all-types) (setq word wd))
(t (setq wd nil)))
(cond ((equal (string-match "^\\s-*$" w) 0)
(message "Blank line"))
((and wd (stringp word))
(gnuplot-gui-correct-command word set term begin)
(setq gnuplot-gui-alist nil
gnuplot-gui-current-string
(buffer-substring-no-properties (point) end))
(gnuplot-gui-set-alist word gnuplot-gui-current-string)
(let* ((old-height (gnuplot-gui-get-frame-param 'height))
(old-top (gnuplot-gui-get-frame-param 'top)))
(when (or
(and (equal gnuplot-gui-plot-splot-fit-style 'complete)
(member* word '("plot" "splot" "fit")
:test 'string=))
(equal word "test"))
(gnuplot-gui-set-frame-param 'height 32)
(gnuplot-gui-set-frame-param 'top 50))
(gnuplot-gui-prompt-for-frame word)
(when (or
(and (equal gnuplot-gui-plot-splot-fit-style 'complete)
(member* word '("plot" "splot" "fit")
:test 'string=))
(equal word "test"))
(gnuplot-gui-set-frame-param 'height old-height)
(gnuplot-gui-set-frame-param 'top old-top)) ))
((setq wrd (car (all-completions w '(("cntrparam")))))
(message
"Setting arguments for %S is currently unsuported in gnuplot-mode"
wrd))
((setq list (all-completions w gnuplot-gui-all-types))
(message "%S could be one of %S" w list))
(t
(message
"%S is not a gnuplot command which takes options" w)))) ))))
(defun gnuplot-gui-toggle-popup ()
(interactive)
(setq gnuplot-gui-popup-flag (not gnuplot-gui-popup-flag))
(message (if gnuplot-gui-popup-flag
"Argument popup will appear after insertions."
"Argument popup will no longer appear after insertions.")))