-
Notifications
You must be signed in to change notification settings - Fork 2
/
iron-main-panels.el
1620 lines (1270 loc) · 42.8 KB
/
iron-main-panels.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
;;; -*- Mode: Emacs-Lisp; lexical-binding: t -*-
;;; iron-main-panels.el --- IRON MAIN "panels" for mainframe interaction.
;;; iron-main-panels.el
;;
;; See the file COPYING license and copyright information.
;;
;; Author: Marco Antoniotti <marcoxa [at] gmail.com>
;;
;; Created: December 5th, 2020.
;;
;; Version: 2023-06-01.1
;;
;; Keywords: languages, operating systems.
;;; Commentary:
;;
;; This file contains the "panels" that are used to interact with a
;; "mainframe" (again, mostly a MVS 3.8j running on Hercules).
;;
;; The implementation is an interesteing use (or, one should say,
;; "abuse") of the Emacs `widget.el' library to give the "look and feel
;; of using a "mainframe" application in... Emacs (I know: I am a pervert).
;;
;; To use, just issue
;;
;; M-x iron-main-frame
;;
;; The functions in this file have 'iron-main-panels-' as prefix.
;;; Code:
(require 'cl-lib)
(eval-when-compile
(require 'widget)
(require 'wid-edit))
(require 'iron-main-vars)
(require 'iron-main-utils)
;;; IRON MAIN panels.
;;
;; "Panel" is mainframe-speak for "page", or in the context of Emacs,
;; "window/buffer".
;;
;; The code below uses several examples of the "widget" library found
;; in Emacs.
(defvar iron-main-panels--overline (make-string 72 175))
(defvar iron-main-panels--underline (make-string 72 ?_))
(defvar-local iron-main-panels--current-ds (make-iron-main-ds-rep))
(defvar-local iron-main-panels--dsname-widget nil)
(defvar-local iron-main-panels--recfm-widget nil)
(defvar-local iron-main-panels--lrecl-widget nil)
(defvar-local iron-main-panels--blksize-widget nil)
(defvar-local iron-main-panels--dsorg-widget nil)
(defvar-local iron-main-panels--vol-widget nil)
(defvar-local iron-main-panels--unit-widget nil)
(defvar-local iron-main-panels--space-unit-widget nil)
(defvar-local iron-main-panels--primary-widget nil)
(defvar-local iron-main-panels--secondary-widget nil)
(defvar-local iron-main-panels--dir-widget nil)
;;; IRON MAIN panel keymaps.
(defvar iron-main-panels-mode-keymap
(let ((km (make-sparse-keymap)))
(set-keymap-parent km widget-keymap)
(define-key km (kbd "<f3>") 'iron-main-panels--exit-panel)
(define-key km (kbd "q") 'iron-main-panels--exit-panel)
(define-key km (kbd "Q") 'iron-main-panels--exit-panel)
km
)
"The IRON MAIN Panel mode key map.
The key map inherits from `widget-keymap'. The keys '<f3>' (that is,
'PF3'), 'q' and 'Q' exit the current panel.")
(defvar iron-main-panels-editable-field-keymap
(let ((km (make-sparse-keymap "Iron Main Editable Field Keymap")))
(set-keymap-parent km widget-field-keymap)
;; Redefine F3; the original is
;; `kmacro-start-macro-or-insert-counter' from `global-map'.
(define-key km (kbd "<f3>") 'iron-main-panels--exit-panel)
km
)
"The IRON MAIN Editable Field key map.
The key map inherits from `widget-field-keymap'. The key '<f3>' (that
is, 'PF3') exits the current panel.")
;;; Buffer local variables.
;; Navigation.
(defvar-local iron-main-panels--back nil
"Local panel variable set by the `invoking' panel."
;; Pretty crude for the time being.
;; This just acts as a stack. Whever a panel is "closed", the
;; buffer is killed and the content of this variable, a buffer, if
;; not nil and live, is restored.
)
(defvar-local iron-main-panels--in-panel nil
"When non NIL, the buffer is an IRON MAIN panel.")
(defvar-local iron-main-panels--tag nil
"A tag that identifies the type of IRON MAIN panel.
The value can be either a string or a symbol.")
(defvar-local iron-main-panels--cmds ()
"The panel command alist.
This list contains a \"command alist\" which is a specification for
link widgets to insert in a panel. Each IRON MAIN panel (which is
eventually an Emacsbuffer) can initialize this variable as it wishes.
The format is of a \"command alist\" is the following:
(cmd function &rest keys)
Where CMD is a string, FUNCTION a \"panel invocation\" function and
KEYS a list of key-value pairs to be used for `widget-create'.
See Also:
`iron-main-panels--hercules-top-commands',
`iron-main-panels--hercules-dsfs-commands'
")
(defvar-local iron-main-panels--cmds-links ()
"List of \"link\" widgets for the commands available in the panel.")
;;; In-panel navigation.
;;
;; The following functions *assume* that the first and last character in a
;; panel are NOT part of a widget.
(cl-defun iron-main-panels--goto-first-widget ()
(goto-char (point-min))
(widget-forward 1))
(cl-defun iron-main-panels--goto-last-widget ()
(goto-char (point-max))
(widget-backward 1))
;;; Commands alists.
;;
;; Commands alists are lists of "specifications" for link widgets to
;; insert in a panel.
;; Their format is:
;;
;; (cmd function &rest keys)
;;
;; Where CMD is a string, FUNCTION a "panel invocation" function and
;; KEYS a list of key-value pairs to be used for `widget-create'.
(defvar iron-main-panels--hercules-top-commands
`(("System" iron-main-panels--hercules-system
:header "Inspect Hercules system/machine"
)
("Datasets" iron-main-panels--hercules-dsfs-utilities
:header "Handle files and datasets across systems"
)
("Help" iron-main-panels--hercules-help
:header "Hercules help"
)
("Exit" iron-main-panels--exit-panel
:header "Exit the IRON MAIN current panel or top-level"
:notify ,(lambda (w &rest args)
(ignore w args)
(iron-main-panels--exit-panel)))
)
"A 'commands alist' for the IRON MAIN top panel."
)
(defvar iron-main-panels--hercules-dsfs-commands
`(("Allocate" iron-main-panels--dataset-allocation
:header "Allocate a dataset on the mainframe"
)
("Upload" iron-main-panels--dataset-save
:header "Upload a local file on the mainframe"
)
("Edit" iron-main-panels--dataset-edit
:header "Edit a dataset member from the mainframe (if connected)"
)
("Edit local" iron-main-panels--dataset-edit-local
:header "Edit a local file"
)
("Exit" iron-main-panels--exit-panel
:header "Exit the IRON MAIN current panel or top-level"
:notify ,(lambda (w &rest args)
(ignore w args)
(iron-main-panels--exit-panel)))
)
"A 'commands alist' for the IRON MAIN dtaset and filesystem panel."
)
(cl-defun iron-main-panels--find-command (cmd commands-alist)
;; (assoc cmd commands-alist 'string=)
(assoc cmd commands-alist) ; Older Emacsen do not accept the third arg.
)
(cl-defun iron-main-panels--command-field ()
(widget-insert "Command")
(widget-create 'iron-main-natnum-widget
:size 3
:tag ""
:value ""
:validate
(lambda (cmd)
(<= 1 (widget-value cmd) (length iron-main-panels--cmds)))
:action
(lambda (cmd &optional event)
(ignore event)
(message ">>> notified")
;; (sleep-for 3)
(let* ((cmd-widget
(nth (1- (widget-value cmd))
iron-main-panels--cmds-links))
(cmd-notify
(iron-main-panels--widget-notify cmd-widget))
)
(message ">>> calling %s on %s"
cmd-notify
cmd-widget)
(when cmd-notify
(apply cmd-notify cmd-widget ()))
))
:keymap
iron-main-panels-editable-field-keymap
)
(widget-insert "\n\n")
)
(cl-defun iron-main-panels--insert-command-widgets (cmd-alist)
(cl-loop for option in cmd-alist
for opt-i from 1
for header = (plist-get option :header)
for notify = (plist-get option :notify)
do
(widget-insert (format "%3d. " opt-i))
collect
(widget-create 'link
:format "%[%t%]\t: %v"
:tag (cl-first option)
:value header
:button-prefix ""
:button-suffix ""
:notify
(if notify
notify
(lambda (w &rest args)
(ignore args)
(let ((panel-function
(cl-second
(iron-main-panels--find-command
(iron-main-panels--widget-tag w)
cmd-alist)))
)
(iron-main-panels--invoke-panel
(current-buffer)
panel-function)
))))
do
(widget-insert "\n")
))
;;; iron-main-panel-mode
;; The main mode (major) for the panels.
(define-derived-mode iron-main-panel-mode nil "//IRON-MAIN"
"IRON MAIN Panel Mode.
Major mode for IRON MAIN Panels. Mostly a container for variables
and a specialized keymap.
You an use the function key `F3' (i.e., `PF3') or the [Qq] keys to
exit a panel. Exiting the top panel will exit the IRON MAIN
interface.
Note that `overwrite-mode' is turned on in the panels."
(setq-local iron-main-panels--in-panel t)
(setq-local iron-main-panels--back nil)
(overwrite-mode 42) ; Turn on `overwrite-mode'.
(use-local-map iron-main-panels-mode-keymap)
)
;; Panels.
;; The actual panels available.
;; The "fields" (or "widgets") of each panel have (function) names
;; that end in "-field" or "-widget".
;; title-field
(cl-defun iron-main-panels--title-field (&optional title)
"Create the the IRON MAIN panel title using argument TITLE."
(unless title
(setq title "Top"))
;; (widget-insert "\n")
(widget-insert (propertize (format "IRON MAIN %s\n" title)
;; 'face 'fixed-pitch-serif
'face '(fixed-pitch-serif
:foreground "red"
:weight bold
)
))
(widget-insert iron-main-panels--overline) ; 175 is the "overline"
(widget-insert "\n")
)
;; help-field
;; Unused.
(cl-defun iron-main-panels--help-field ()
"Create the \"help\" field at the bottom of the window."
;; Call last before `widget-setup'.
;; The next one is a kludge to position the message on the "last"
;; window without resorting (as I probably should) to more
;; sophisticated Emacs techniques involving minibuffer-less windows
;; etc.
(let ((wh (window-total-height))
(lc (count-lines (window-start) (window-end)))
(lp-current (line-number-at-pos))
(lp-window-end (line-number-at-pos (window-end)))
)
(cond ((>= lc wh)
(move-to-window-line -1) ; Last visible line.
)
((< lc wh)
;; Kludgy part: pad the buffer with newlines.
(forward-line (- lp-window-end lp-current))
(widget-insert (make-string (- wh lc) ?\n))
(move-to-window-line -1)))
)
(widget-insert
(propertize (format "Use `[Qq]' or `PF3' to go back to previous panel.")
'face '(fixed-pitch-serif :weight bold)
))
)
;; Datasets and file system handling panel.
;; ----------------------------------------
(cl-defun iron-main-panels--dsname-item-field ()
"Create the `dsname' editable-field widget in the IRON MAIN panel."
(setq iron-main-panels--dsname-widget
(widget-create 'editable-field
:size 46 ; A name is at most 44 plus quotes.
:format "Data set name: %v " ; Text after the field!
:value
(iron-main-ds-rep-name iron-main-panels--current-ds)
;; (iron-main-ds-rep-name iron-main-panels--current-ds)
:notify
(lambda (w &rest ignore)
(ignore ignore)
(message "DSN: <%s>."
(widget-value w))
(setf (iron-main-ds-rep-name
iron-main-panels--current-ds)
(widget-value w)))
:keymap
iron-main-panels-editable-field-keymap
))
(widget-insert "\n")
(setf iron-main-panels--vol-widget
(widget-create 'editable-field
:size 6
:format "Volume serial: %v "
:value
(iron-main-ds-rep-vol iron-main-panels--current-ds)
:notify
(lambda (w &rest ignore)
(ignore ignore)
(message "VOL: <%s>."
(widget-value w))
(setf (iron-main-ds-rep-vol
iron-main-panels--current-ds)
(widget-value w)))
:keymap
iron-main-panels-editable-field-keymap
))
)
(defvar iron-main-ds-allocation-dsorg "PDS"
"The default data set organization (DSORG).")
(defvar-local iron-main-panels--hercules-dsfs-cmds-links ()
"List of link widgets created for DSFS panel commands.")
(cl-defun iron-main-panels--hercules-dsfs-utilities (session &rest args)
"Create the IRON MAIN datasets and file system utilities.
The panel presents the options regarding the handling of datasets
(files) on the connected, possibly hosted, operating system and the
file system(s) that Emacs has direct access to; most notably, the
\"host\" file system, say, Linux, Mac OS X or Windows."
(interactive)
(ignore args)
(cl-assert (iron-main-session-p session) nil
"SESSION %S is not a `iron-main-session'"
session)
(switch-to-buffer "*IRON MAIN dataset and file system handling.*")
(kill-all-local-variables)
(let ((inhibit-read-only t))
(erase-buffer))
(iron-main-panel-mode)
;; Now that we have the session, some of these are repetitions.
(setq-local iron-main-panels--session session)
(setq-local iron-main-machine
(iron-main-session-machine session))
(setq-local iron-main-os-flavor
(iron-main-session-os-flavor session))
(setq-local iron-main-panels--tag "Hercules datasets")
(setq-local iron-main-panels--cmds iron-main-panels--hercules-dsfs-commands)
(iron-main-panels--title-field
"Dataset and file system handling panel")
(widget-insert "\n")
;; Let's start!
(iron-main-panels--command-field)
(setq-local iron-main-panels--cmds-links
(iron-main-panels--insert-command-widgets
iron-main-panels--cmds))
(message "IMHS00I: Hercules datasets and file system utilities.")
(prog1 (widget-setup)
;; (widget-forward 1)
(iron-main-panels--goto-first-widget)
)
)
;; Dataset allocation.
;; -------------------
(cl-defun iron-main-panels--dataset-allocation (session &rest args)
"Create the IRON MAIN dataset allocation panel."
(interactive)
(ignore session args)
;; (cl-assert (iron-main-session-p session) t
;; "SESSION %S is not a `iron-main-session'"
;; session)
(switch-to-buffer "*IRON MAIN dataset allocation*")
(kill-all-local-variables)
(let ((inhibit-read-only t))
(erase-buffer))
(iron-main-panel-mode)
;; Init buffer local variables.
(setq-local iron-main-panels--tag "Allocation panel")
(setq-local iron-main-panels--cmds ())
;; Let's start!
(iron-main-panels--title-field "Dataset allocation panel")
(iron-main-panels--dsname-item-field)
(widget-insert "\n\n")
(setf iron-main-panels--recfm-widget
(widget-create 'editable-field
:format "Record format (RECFM): %v "
:value (iron-main-ds-rep-recfm
iron-main-panels--current-ds)
:size 3
:notify (lambda (w &rest ignore)
(ignore ignore)
(message "RECF: <%s>."
(widget-value w))
(setf (iron-main-ds-rep-recfm
iron-main-panels--current-ds)
(widget-value w)))
:keymap
iron-main-panels-editable-field-keymap
:help-echo "Please enter the record format: F, FB, V..."
))
(widget-insert "\n")
(message "IMPDSA1: RECFM widget created.")
(setf iron-main-panels--lrecl-widget
(widget-create 'iron-main-natnum-widget
:format "Logical record length (LRECL): %v "
:value (iron-main-ds-rep-lrecl
iron-main-panels--current-ds)
:size 4
;; :value-regexp "[0-9]+"
:notify (lambda (w &rest ignore)
(ignore ignore)
(message "LRECL: <%s>."
(widget-value w))
(setf (iron-main-ds-rep-lrecl
iron-main-panels--current-ds)
(widget-value w)))
:keymap
iron-main-panels-editable-field-keymap
:help-echo "Please enter the record length..."
))
(widget-insert "\n")
(message "IMPDSA2: LRECL widget created.")
(setf iron-main-panels--blksize-widget
(widget-create 'iron-main-natnum-widget
:format "Block size (BLKSIZE): %v "
:value (iron-main-ds-rep-blksize
iron-main-panels--current-ds)
:size 6
;; :value-regexp "[0-9]+"
:notify (lambda (w &rest ignore)
(ignore ignore)
(message "BLKSIZE: <%s>."
(widget-value w))
(setf (iron-main-ds-rep-blksize
iron-main-panels--current-ds)
(widget-value w)))
:keymap
iron-main-panels-editable-field-keymap
:help-echo "Please enter the block size..."
))
(widget-insert "\n\n")
(message "IMPDSA3: BLKSIZE widget created.")
(setf iron-main-panels--vol-widget
(widget-create 'editable-field
:format "Unit: %v "
:value (iron-main-ds-rep-unit
iron-main-panels--current-ds)
:size 6
:notify
(lambda (w &rest ignore)
(ignore ignore)
(message "UNIT: <%s>."
(widget-value w))
(setf (iron-main-ds-rep-unit
iron-main-panels--current-ds)
(widget-value w)))
:keymap
iron-main-panels-editable-field-keymap
:help-echo "Please enter the unit info..."
))
(widget-insert "\n\n")
(message "IMPDSA4: UNIT widget created.")
(widget-insert "Dataset organization (DSORG): \n")
(setf iron-main-panels--dsorg-widget
(widget-create 'radio-button-choice
:tag "Dataset organization (DSORG)"
:doc "Dataset organization (DSORG)"
;; :value "PO"
:void "PO"
:indent 4
:help-echo
"Please choose the dataset organization: PO, PS..."
:notify
(lambda (w &rest ignore)
(ignore ignore)
(message "Dataset organization: <%s>."
(widget-value w))
(setf (iron-main-ds-rep-dsorg
iron-main-panels--current-ds)
(widget-value w)))
'(item :tag "Partitioned Data Set (PO)"
:value "PO")
;; '(item :tag "Partitioned Data Set Extended (PDSE)"
;; :value "PDSE")
'(item :tag "Sequential (PS)"
:value "PS")
;; Add other ones.
))
(widget-insert "\n\n")
(message "IMPDSA5: DSORG widget created.")
(widget-insert "Space allocation:\n")
(setf iron-main-panels--space-unit-widget
(widget-create 'radio-button-choice
:tag "Dataset space unit (SPACE)"
;; :value "TRK"
:void "TRK"
:indent 4
:help-echo "Please choose the dataset space unit..."
:notify (lambda (w &rest ignore)
(ignore ignore)
(message "Dataset space unit: <%s>."
(widget-value w))
(setf (iron-main-ds-rep-space-unit
iron-main-panels--current-ds)
(widget-value w)))
'(item "TRK")
'(item "CYL")
'(item "BLK")
;; Add other ones.
))
(widget-insert "\n")
(message "IMPDSA6: SPACE widget created.")
(setf iron-main-panels--primary-widget
(widget-create 'iron-main-natnum-widget
:format "Primary: %v "
:value (iron-main-ds-rep-primary
iron-main-panels--current-ds)
:size 8
;; :value-regexp "[0-9]+"
:notify (lambda (w &rest ignore)
(ignore ignore)
(message "Primary: <%s>."
(widget-value w))
(setf (iron-main-ds-rep-primary
iron-main-panels--current-ds)
(widget-value w)))
:keymap
iron-main-panels-editable-field-keymap
:help-echo "Please the primary amount of space..."
))
(message "IMPDSA7: Primary widget created.")
(widget-insert " ")
(setf iron-main-panels--secondary-widget
(widget-create 'iron-main-natnum-widget
:format "Secondary: %v "
:value (iron-main-ds-rep-secondary
iron-main-panels--current-ds)
:size 8
;; :value-regexp "[0-9]+"
:notify (lambda (w &rest ignore)
(ignore ignore)
(message "Secondary: <%s>."
(widget-value w))
(setf (iron-main-ds-rep-secondary
iron-main-panels--current-ds)
(widget-value w)))
:keymap
iron-main-panels-editable-field-keymap
:help-echo
"Please the secondary amount of space..."
))
(message "IMPDSA8: Secondary widget created.")
(widget-insert " ")
(setf iron-main-panels--dir-widget
(widget-create 'iron-main-natnum-widget
:format "Directory blocks: %v "
:value (iron-main-ds-rep-directory
iron-main-panels--current-ds)
:size 4
;; :value-regexp "[0-9]+"
:notify (lambda (w &rest ignore)
(ignore ignore)
(message "Directory blocks: <%s>."
(widget-value w))
(setf (iron-main-ds-rep-directory
iron-main-panels--current-ds)
(widget-value w)))
:keymap
iron-main-panels-editable-field-keymap
:help-echo
"Please enter the number of directory blocks..."
))
(message "IMPDSA9: Directory blocks widget created.")
;; (widget-insert "\n\n\n")
(widget-insert "\n")
(widget-insert iron-main-panels--underline)
(widget-insert "\n")
(widget-create 'push-button
:value "Allocate"
:notify
(lambda (&rest ignore)
(ignore ignore)
(setf (iron-main-ds-rep-name
iron-main-panels--current-ds)
(widget-value iron-main-panels--dsname-widget)
(iron-main-ds-rep-dsorg
iron-main-panels--current-ds)
(widget-value iron-main-panels--dsorg-widget)
;; (iron-main-ds-rep-space-unit
;; iron-main-panels--current-ds)
;; (widget-value iron-main-panels--space-unit-widget)
)
(message "DD %s"
(iron-main-ds-to-string
iron-main-panels--current-ds)
))
)
(widget-insert " ")
(widget-create 'push-button
:value "View job buffer"
:notify
(lambda (&rest ignore)
(ignore ignore)
(message "JCL buffer for '%s': ...."
(iron-main-ds-rep-name
iron-main-panels--current-ds)
))
)
(widget-insert " ")
(widget-create 'push-button
:value "Allocate and Save"
:notify
(lambda (&rest ignore)
(ignore ignore)
(message "Data set name: %s."
(iron-main-ds-rep-name
iron-main-panels--current-ds)
)
(iron-main-panels--dataset-save session)
)
)
(widget-insert " ")
(widget-create 'push-button
:value "Cancel"
:notify
(lambda (&rest ignore)
(ignore ignore)
(message "Cancelled dataset '%s' mainframe allocation."
(iron-main-ds-rep-name
iron-main-panels--current-ds)
)
)
)
(widget-insert "\n")
(message "IMDS00I: Dataset allocation panel set up.")
(prog1 (widget-setup)
;; (widget-forward 1)
(iron-main-panels--goto-first-widget)
)
)
;; Dataset save panel.
;; -------------------
(defvar iron-main-panels--filename-widget "")
(cl-defun iron-main-panels--dataset-save (session &rest args)
"Create the IRON MAIN dataset save panel."
(interactive)
(ignore args session)
;; (cl-assert (iron-main-session-p session) t
;; "SESSION %S is not a `iron-main-session'"
;; session)
(switch-to-buffer "*IRON MAIN dataset save*")
(kill-all-local-variables)
(let ((inhibit-read-only t))
(erase-buffer))
(iron-main-panel-mode)
(iron-main-panels--title-field "Dataset member save")
(iron-main-panels--dsname-item-field)
(widget-insert "\n\n")
(setq iron-main-panels--filename-widget
(widget-create 'file
:format "File: %v\n"
:value (iron-main-ds-rep-name
iron-main-panels--current-ds)
:size (- 72 (length "File: "))
:keymap
iron-main-panels-editable-field-keymap))
(widget-insert iron-main-panels--underline)
(widget-insert "\n")
(widget-create 'push-button
:notify
(lambda (&rest ignore)
(ignore ignore)
(message "DD: <%s>."
(iron-main-ds-to-string
iron-main-panels--current-ds)
))
"Save to mainframe")
(widget-insert " ")
(widget-create 'push-button
:notify
(lambda (&rest ignore)
(ignore ignore)
(message "JCL buffer for '%s' and '%s': ...."
(iron-main-ds-rep-name
iron-main-panels--current-ds)
(widget-value
iron-main-panels--filename-widget)
))
"View job buffer")
(widget-insert " ")
(widget-create 'push-button
:notify
(lambda (&rest ignore)
(ignore ignore)
(message "Saving dataset '%s' to mainframe cancelled."
(iron-main-ds-rep-name
iron-main-panels--current-ds)
)
)
"Cancel")
(widget-insert "\n")
(message "IMDS00I: Dataset upload panel set up.")
(prog1 (widget-setup)
;; (widget-forward 1)
(iron-main-panels--goto-first-widget)
)
)
;; Dataset edit dataset member panel.
;; ----------------------------------
(cl-defun iron-main-panels--dataset-edit (session &rest args)
"Create the IRON MAIN dataset save panel."
(interactive)
(ignore session args)
;; (cl-assert (iron-main-session-p session) t
;; "SESSION %S is not a `iron-main-session'"
;; session)
(switch-to-buffer "*IRON MAIN dataset edit*")
(kill-all-local-variables)
(let ((inhibit-read-only t))
(erase-buffer))
(iron-main-panel-mode)
(iron-main-panels--title-field "Dataset member edit")
(iron-main-panels--dsname-item-field)
(widget-insert "\n\n")
(setq iron-main-panels--filename-widget
(widget-create 'file
:format "File: %v\n"
:value (iron-main-ds-rep-name
iron-main-panels--current-ds)
:size (- 72 (length "File: "))))
(widget-insert iron-main-panels--underline)
(widget-insert "\n")
(message "IMDS00I: Dataset edit panel set up.")
(prog1 (widget-setup)
;; (widget-forward 1)
(iron-main-panels--goto-first-widget)
)
)
;; IRON MAIN frame main, top panel.
;; --------------------------------
(defvar-local iron-main-hercules-pid nil
"The PID of the Hercules process. NIL if it is not running or reachable.")
(defvar-local iron-main-panels--session nil
"The session a panel is attached to.")
(cl-defun iron-main-panels--get-session (panel)
"Get the IRON MAIN session attached to PANEL.
PANEL must be a buffer or a buffer name."
(with-current-buffer panel
iron-main-panels--session))
;; Maybe use the widget "property" functions instead in the next functions:
;; i.e., `widget-get'.
(cl-defun iron-main-panels--widget-tag (w)
"Get the :tag of widget W.
Notes:
This function is necessary because it is inexplicably absent from the
`widget.el' library."
(plist-get (cdr w) :tag))
(cl-defun iron-main-panels--widget-notify (w)
"Get the :notify function of widget W.
Notes:
This function is necessary because it is inexplicably absent from the
`widget.el' library."
(plist-get (cdr w) :notify))