-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.c
4024 lines (3589 loc) · 87.9 KB
/
menu.c
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
/* $XTermId: menu.c,v 1.338 2016/05/30 20:58:39 tom Exp $ */
/*
* Copyright 1999-2015,2016 by Thomas E. Dickey
*
* All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name(s) of the above copyright
* holders shall not be used in advertising or otherwise to promote the
* sale, use or other dealings in this Software without prior written
* authorization.
*
*
* Copyright 1989 The Open Group
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of The Open Group shall not be
* used in advertising or otherwise to promote the sale, use or other dealings
* in this Software without prior written authorization from The Open Group.
*/
#include <xterm.h>
#include <data.h>
#include <menu.h>
#include <fontutils.h>
#include <xstrings.h>
#include <locale.h>
#include <X11/Xmu/CharSet.h>
#define app_con Xaw_app_con /* quiet a warning from SimpleMenu.h */
#if defined(HAVE_LIB_XAW)
#include <X11/Xaw/SimpleMenu.h>
#include <X11/Xaw/Box.h>
#include <X11/Xaw/SmeBSB.h>
#include <X11/Xaw/SmeLine.h>
#if OPT_TOOLBAR
#include <X11/Xaw/MenuButton.h>
#include <X11/Xaw/Form.h>
#endif
#elif defined(HAVE_LIB_XAW3D)
#include <X11/Xaw3d/SimpleMenu.h>
#include <X11/Xaw3d/Box.h>
#include <X11/Xaw3d/SmeBSB.h>
#include <X11/Xaw3d/SmeLine.h>
#if OPT_TOOLBAR
#include <X11/Xaw3d/MenuButton.h>
#include <X11/Xaw3d/Form.h>
#endif
#elif defined(HAVE_LIB_XAW3DXFT)
#include <X11/Xaw3dxft/SimpleMenu.h>
#include <X11/Xaw3dxft/Box.h>
#include <X11/Xaw3dxft/SmeBSB.h>
#include <X11/Xaw3dxft/SmeLine.h>
#if OPT_TOOLBAR
#include <X11/Xaw3dxft/MenuButton.h>
#include <X11/Xaw3dxft/Form.h>
#endif
#elif defined(HAVE_LIB_NEXTAW)
#include <X11/neXtaw/SimpleMenu.h>
#include <X11/neXtaw/Box.h>
#include <X11/neXtaw/SmeBSB.h>
#include <X11/neXtaw/SmeLine.h>
#if OPT_TOOLBAR
#include <X11/neXtaw/MenuButton.h>
#include <X11/neXtaw/Form.h>
#endif
#elif defined(HAVE_LIB_XAWPLUS)
#include <X11/XawPlus/SimpleMenu.h>
#include <X11/XawPlus/Box.h>
#include <X11/XawPlus/SmeBSB.h>
#include <X11/XawPlus/SmeLine.h>
#if OPT_TOOLBAR
#include <X11/XawPlus/MenuButton.h>
#include <X11/XawPlus/Form.h>
#endif
#endif
#undef app_con
#include <stdio.h>
#include <signal.h>
#if OPT_TRACE
#define UpdateCheckbox(func, mn, mi, val) UpdateMenuItem(func, mn, mi, val)
#else
#define UpdateCheckbox(func, mn, mi, val) UpdateMenuItem(mn, mi, val)
#endif
#define ToggleFlag(flag) flag = (Boolean) !flag
/* *INDENT-OFF* */
static void do_8bit_control PROTO_XT_CALLBACK_ARGS;
static void do_allow132 PROTO_XT_CALLBACK_ARGS;
static void do_allowBoldFonts PROTO_XT_CALLBACK_ARGS;
static void do_allowsends PROTO_XT_CALLBACK_ARGS;
static void do_altscreen PROTO_XT_CALLBACK_ARGS;
static void do_appcursor PROTO_XT_CALLBACK_ARGS;
static void do_appkeypad PROTO_XT_CALLBACK_ARGS;
static void do_autolinefeed PROTO_XT_CALLBACK_ARGS;
static void do_autowrap PROTO_XT_CALLBACK_ARGS;
static void do_backarrow PROTO_XT_CALLBACK_ARGS;
static void do_bellIsUrgent PROTO_XT_CALLBACK_ARGS;
static void do_clearsavedlines PROTO_XT_CALLBACK_ARGS;
static void do_continue PROTO_XT_CALLBACK_ARGS;
static void do_delete_del PROTO_XT_CALLBACK_ARGS;
#if OPT_SCREEN_DUMPS
static void do_dump_html PROTO_XT_CALLBACK_ARGS;
static void do_dump_svg PROTO_XT_CALLBACK_ARGS;
#endif
static void do_hardreset PROTO_XT_CALLBACK_ARGS;
static void do_interrupt PROTO_XT_CALLBACK_ARGS;
static void do_jumpscroll PROTO_XT_CALLBACK_ARGS;
static void do_keepClipboard PROTO_XT_CALLBACK_ARGS;
static void do_keepSelection PROTO_XT_CALLBACK_ARGS;
static void do_kill PROTO_XT_CALLBACK_ARGS;
static void do_old_fkeys PROTO_XT_CALLBACK_ARGS;
static void do_poponbell PROTO_XT_CALLBACK_ARGS;
static void do_print PROTO_XT_CALLBACK_ARGS;
static void do_print_redir PROTO_XT_CALLBACK_ARGS;
static void do_quit PROTO_XT_CALLBACK_ARGS;
static void do_redraw PROTO_XT_CALLBACK_ARGS;
static void do_reversevideo PROTO_XT_CALLBACK_ARGS;
static void do_reversewrap PROTO_XT_CALLBACK_ARGS;
static void do_scrollbar PROTO_XT_CALLBACK_ARGS;
static void do_scrollkey PROTO_XT_CALLBACK_ARGS;
static void do_scrollttyoutput PROTO_XT_CALLBACK_ARGS;
static void do_securekbd PROTO_XT_CALLBACK_ARGS;
static void do_selectClipboard PROTO_XT_CALLBACK_ARGS;
static void do_softreset PROTO_XT_CALLBACK_ARGS;
static void do_suspend PROTO_XT_CALLBACK_ARGS;
static void do_terminate PROTO_XT_CALLBACK_ARGS;
static void do_titeInhibit PROTO_XT_CALLBACK_ARGS;
static void do_visualbell PROTO_XT_CALLBACK_ARGS;
static void do_vtfont PROTO_XT_CALLBACK_ARGS;
#ifdef ALLOWLOGGING
static void do_logging PROTO_XT_CALLBACK_ARGS;
#endif
#ifndef NO_ACTIVE_ICON
static void do_activeicon PROTO_XT_CALLBACK_ARGS;
#endif /* NO_ACTIVE_ICON */
#if OPT_ALLOW_XXX_OPS
static void enable_allow_xxx_ops (Bool);
static void do_allowColorOps PROTO_XT_CALLBACK_ARGS;
static void do_allowFontOps PROTO_XT_CALLBACK_ARGS;
static void do_allowTcapOps PROTO_XT_CALLBACK_ARGS;
static void do_allowTitleOps PROTO_XT_CALLBACK_ARGS;
static void do_allowWindowOps PROTO_XT_CALLBACK_ARGS;
#endif
#if OPT_BLINK_CURS
static void do_cursorblink PROTO_XT_CALLBACK_ARGS;
#endif
#if OPT_BOX_CHARS
static void do_font_boxchars PROTO_XT_CALLBACK_ARGS;
static void do_font_packed PROTO_XT_CALLBACK_ARGS;
#endif
#if OPT_DEC_CHRSET
static void do_font_doublesize PROTO_XT_CALLBACK_ARGS;
#endif
#if OPT_DEC_SOFTFONT
static void do_font_loadable PROTO_XT_CALLBACK_ARGS;
#endif
#if OPT_HP_FUNC_KEYS
static void do_hp_fkeys PROTO_XT_CALLBACK_ARGS;
#endif
#if OPT_MAXIMIZE
static void do_fullscreen PROTO_XT_CALLBACK_ARGS;
#endif
#if OPT_NUM_LOCK
static void do_alt_esc PROTO_XT_CALLBACK_ARGS;
static void do_num_lock PROTO_XT_CALLBACK_ARGS;
static void do_meta_esc PROTO_XT_CALLBACK_ARGS;
#endif
#if OPT_PRINT_ON_EXIT
static void do_write_now PROTO_XT_CALLBACK_ARGS;
static void do_write_error PROTO_XT_CALLBACK_ARGS;
#endif
#if OPT_RENDERFONT
static void do_font_renderfont PROTO_XT_CALLBACK_ARGS;
#endif
#if OPT_SCO_FUNC_KEYS
static void do_sco_fkeys PROTO_XT_CALLBACK_ARGS;
#endif
#if OPT_SIXEL_GRAPHICS
static void do_sixelscrolling PROTO_XT_CALLBACK_ARGS;
#endif
#if OPT_GRAPHICS
static void do_privatecolorregisters PROTO_XT_CALLBACK_ARGS;
#endif
#if OPT_SUN_FUNC_KEYS
static void do_sun_fkeys PROTO_XT_CALLBACK_ARGS;
#endif
#if OPT_SUNPC_KBD
static void do_sun_kbd PROTO_XT_CALLBACK_ARGS;
#endif
#if OPT_TCAP_FKEYS
static void do_tcap_fkeys PROTO_XT_CALLBACK_ARGS;
#endif
#if OPT_TEK4014
static void do_tekcopy PROTO_XT_CALLBACK_ARGS;
static void do_tekhide PROTO_XT_CALLBACK_ARGS;
static void do_tekmode PROTO_XT_CALLBACK_ARGS;
static void do_tekonoff PROTO_XT_CALLBACK_ARGS;
static void do_tekpage PROTO_XT_CALLBACK_ARGS;
static void do_tekreset PROTO_XT_CALLBACK_ARGS;
static void do_tekshow PROTO_XT_CALLBACK_ARGS;
static void do_tektext2 PROTO_XT_CALLBACK_ARGS;
static void do_tektext3 PROTO_XT_CALLBACK_ARGS;
static void do_tektextlarge PROTO_XT_CALLBACK_ARGS;
static void do_tektextsmall PROTO_XT_CALLBACK_ARGS;
static void do_vthide PROTO_XT_CALLBACK_ARGS;
static void do_vtmode PROTO_XT_CALLBACK_ARGS;
static void do_vtonoff PROTO_XT_CALLBACK_ARGS;
static void do_vtshow PROTO_XT_CALLBACK_ARGS;
static void handle_tekshow (Widget gw, Bool allowswitch);
static void handle_vtshow (Widget gw, Bool allowswitch);
#endif
#if OPT_TOOLBAR
static void do_toolbar PROTO_XT_CALLBACK_ARGS;
#endif
#if OPT_WIDE_CHARS
static void do_font_utf8_mode PROTO_XT_CALLBACK_ARGS;
static void do_font_utf8_fonts PROTO_XT_CALLBACK_ARGS;
static void do_font_utf8_title PROTO_XT_CALLBACK_ARGS;
#endif
/*
* The order of entries MUST match the values given in menu.h
*/
MenuEntry mainMenuEntries[] = {
#if OPT_TOOLBAR
{ "toolbar", do_toolbar, NULL },
#endif
#if OPT_MAXIMIZE
{ "fullscreen", do_fullscreen, NULL },
#endif
{ "securekbd", do_securekbd, NULL },
{ "allowsends", do_allowsends, NULL },
{ "redraw", do_redraw, NULL },
{ "line1", NULL, NULL },
#ifdef ALLOWLOGGING
{ "logging", do_logging, NULL },
#endif
#ifdef OPT_PRINT_ON_EXIT
{ "print-immediate", do_write_now, NULL },
{ "print-on-error", do_write_error, NULL },
#endif
{ "print", do_print, NULL },
{ "print-redir", do_print_redir, NULL },
#if OPT_SCREEN_DUMPS
{ "dump-html", do_dump_html, NULL },
{ "dump-svg", do_dump_svg, NULL },
#endif
{ "line2", NULL, NULL },
{ "8-bit control", do_8bit_control,NULL },
{ "backarrow key", do_backarrow, NULL },
#if OPT_NUM_LOCK
{ "num-lock", do_num_lock, NULL },
{ "alt-esc", do_alt_esc, NULL },
{ "meta-esc", do_meta_esc, NULL },
#endif
{ "delete-is-del", do_delete_del, NULL },
{ "oldFunctionKeys",do_old_fkeys, NULL },
#if OPT_TCAP_FKEYS
{ "tcapFunctionKeys",do_tcap_fkeys, NULL },
#endif
#if OPT_HP_FUNC_KEYS
{ "hpFunctionKeys", do_hp_fkeys, NULL },
#endif
#if OPT_SCO_FUNC_KEYS
{ "scoFunctionKeys",do_sco_fkeys, NULL },
#endif
#if OPT_SUN_FUNC_KEYS
{ "sunFunctionKeys",do_sun_fkeys, NULL },
#endif
#if OPT_SUNPC_KBD
{ "sunKeyboard", do_sun_kbd, NULL },
#endif
{ "line3", NULL, NULL },
{ "suspend", do_suspend, NULL },
{ "continue", do_continue, NULL },
{ "interrupt", do_interrupt, NULL },
{ "hangup", do_hangup, NULL },
{ "terminate", do_terminate, NULL },
{ "kill", do_kill, NULL },
{ "line4", NULL, NULL },
{ "quit", do_quit, NULL }};
MenuEntry vtMenuEntries[] = {
{ "scrollbar", do_scrollbar, NULL },
{ "jumpscroll", do_jumpscroll, NULL },
{ "reversevideo", do_reversevideo, NULL },
{ "autowrap", do_autowrap, NULL },
{ "reversewrap", do_reversewrap, NULL },
{ "autolinefeed", do_autolinefeed, NULL },
{ "appcursor", do_appcursor, NULL },
{ "appkeypad", do_appkeypad, NULL },
{ "scrollkey", do_scrollkey, NULL },
{ "scrollttyoutput",do_scrollttyoutput, NULL },
{ "allow132", do_allow132, NULL },
{ "keepSelection", do_keepSelection, NULL },
{ "selectToClipboard",do_selectClipboard, NULL },
{ "visualbell", do_visualbell, NULL },
{ "bellIsUrgent", do_bellIsUrgent, NULL },
{ "poponbell", do_poponbell, NULL },
#if OPT_BLINK_CURS
{ "cursorblink", do_cursorblink, NULL },
#endif
{ "titeInhibit", do_titeInhibit, NULL },
#ifndef NO_ACTIVE_ICON
{ "activeicon", do_activeicon, NULL },
#endif /* NO_ACTIVE_ICON */
{ "line1", NULL, NULL },
{ "softreset", do_softreset, NULL },
{ "hardreset", do_hardreset, NULL },
{ "clearsavedlines",do_clearsavedlines, NULL },
{ "line2", NULL, NULL },
#if OPT_TEK4014
{ "tekshow", do_tekshow, NULL },
{ "tekmode", do_tekmode, NULL },
{ "vthide", do_vthide, NULL },
#endif
{ "altscreen", do_altscreen, NULL },
#if OPT_SIXEL_GRAPHICS
{ "sixelScrolling", do_sixelscrolling, NULL },
#endif
#if OPT_GRAPHICS
{ "privateColorRegisters", do_privatecolorregisters, NULL },
#endif
};
MenuEntry fontMenuEntries[] = {
{ "fontdefault", do_vtfont, NULL },
{ "font1", do_vtfont, NULL },
{ "font2", do_vtfont, NULL },
{ "font3", do_vtfont, NULL },
{ "font4", do_vtfont, NULL },
{ "font5", do_vtfont, NULL },
{ "font6", do_vtfont, NULL },
/* this is after the last builtin font; the other entries are special */
{ "fontescape", do_vtfont, NULL },
{ "fontsel", do_vtfont, NULL },
/* down to here should match NMENUFONTS in ptyx.h */
#if OPT_DEC_CHRSET || OPT_BOX_CHARS || OPT_DEC_SOFTFONT
{ "line1", NULL, NULL },
{ "allow-bold-fonts", do_allowBoldFonts, NULL },
#if OPT_BOX_CHARS
{ "font-linedrawing",do_font_boxchars,NULL },
{ "font-packed", do_font_packed,NULL },
#endif
#if OPT_DEC_CHRSET
{ "font-doublesize",do_font_doublesize,NULL },
#endif
#if OPT_DEC_SOFTFONT
{ "font-loadable", do_font_loadable,NULL },
#endif
#endif /* toggles for DEC font extensions */
#if OPT_RENDERFONT || OPT_WIDE_CHARS
{ "line2", NULL, NULL },
#if OPT_RENDERFONT
{ "render-font", do_font_renderfont,NULL },
#endif
#if OPT_WIDE_CHARS
{ "utf8-mode", do_font_utf8_mode,NULL },
{ "utf8-fonts", do_font_utf8_fonts,NULL },
{ "utf8-title", do_font_utf8_title,NULL },
#endif
#endif /* toggles for other font extensions */
#if OPT_ALLOW_XXX_OPS
{ "line3", NULL, NULL },
{ "allow-color-ops",do_allowColorOps,NULL },
{ "allow-font-ops", do_allowFontOps,NULL },
{ "allow-tcap-ops", do_allowTcapOps,NULL },
{ "allow-title-ops",do_allowTitleOps,NULL },
{ "allow-window-ops",do_allowWindowOps,NULL },
#endif
};
#if OPT_TEK4014
MenuEntry tekMenuEntries[] = {
{ "tektextlarge", do_tektextlarge, NULL },
{ "tektext2", do_tektext2, NULL },
{ "tektext3", do_tektext3, NULL },
{ "tektextsmall", do_tektextsmall, NULL },
{ "line1", NULL, NULL },
{ "tekpage", do_tekpage, NULL },
{ "tekreset", do_tekreset, NULL },
{ "tekcopy", do_tekcopy, NULL },
{ "line2", NULL, NULL },
{ "vtshow", do_vtshow, NULL },
{ "vtmode", do_vtmode, NULL },
{ "tekhide", do_tekhide, NULL }};
#endif
typedef struct {
char *internal_name;
MenuEntry *entry_list;
Cardinal entry_len;
} MenuHeader;
/* This table is ordered to correspond with MenuIndex */
static const MenuHeader menu_names[] = {
{ "mainMenu", mainMenuEntries, XtNumber(mainMenuEntries) },
{ "vtMenu", vtMenuEntries, XtNumber(vtMenuEntries) },
{ "fontMenu", fontMenuEntries, XtNumber(fontMenuEntries) },
#if OPT_TEK4014
{ "tekMenu", tekMenuEntries, XtNumber(tekMenuEntries) },
#endif
{ 0, 0, 0 },
};
/* *INDENT-ON* */
/*
* FIXME: These are global data rather than in the xterm widget because they
* are initialized before the widget is created.
*/
typedef struct {
Widget b; /* the toolbar's buttons */
Widget w; /* the popup shell activated by the button */
Cardinal entries;
} MenuList;
static MenuList vt_shell[NUM_POPUP_MENUS];
#if OPT_TEK4014 && OPT_TOOLBAR
static MenuList tek_shell[NUM_POPUP_MENUS];
#endif
static String
setMenuLocale(Bool before, String substitute)
{
String result = setlocale(LC_CTYPE, 0);
if (before) {
result = x_strdup(result);
}
(void) setlocale(LC_CTYPE, substitute);
TRACE(("setMenuLocale %s:%s\n",
(before
? "before"
: "after"),
NonNull(result)));
if (!before) {
free((void *) substitute);
}
return result;
}
/*
* Returns a pointer to the MenuList entry that matches the popup menu.
*/
static MenuList *
select_menu(Widget w GCC_UNUSED, MenuIndex num)
{
#if OPT_TEK4014 && OPT_TOOLBAR
while (w != 0) {
if (w == tekshellwidget) {
return &tek_shell[num];
}
w = XtParent(w);
}
#endif
return &vt_shell[num];
}
/*
* Returns a pointer to the given popup menu shell
*/
static Widget
obtain_menu(Widget w, MenuIndex num)
{
return select_menu(w, num)->w;
}
/*
* Returns the number of entries in the given popup menu shell
*/
static Cardinal
sizeof_menu(Widget w, MenuIndex num)
{
return select_menu(w, num)->entries;
}
/*
* Return an array of flags telling if a given menu item is never going to
* be used, so we can reduce the size of menus.
*/
static Boolean *
unusedEntries(XtermWidget xw, MenuIndex num)
{
static Boolean result[XtNumber(mainMenuEntries)
+ XtNumber(vtMenuEntries)
+ XtNumber(fontMenuEntries)
#if OPT_TEK4014
+ XtNumber(tekMenuEntries)
#endif
];
TScreen *screen = TScreenOf(xw);
memset(result, 0, sizeof(result));
switch (num) {
case mainMenu:
#if OPT_MAXIMIZE
if (resource.fullscreen > 1) {
result[mainMenu_fullscreen] = True;
}
#endif
#if OPT_NUM_LOCK
if (!screen->alt_is_not_meta) {
result[mainMenu_alt_esc] = True;
}
#endif
if (!xtermHasPrinter(xw)) {
result[mainMenu_print] = True;
result[mainMenu_print_redir] = True;
}
if (screen->terminal_id < 200) {
result[mainMenu_8bit_ctrl] = True;
}
#if !defined(SIGTSTP)
result[mainMenu_suspend] = True;
#endif
#if !defined(SIGCONT)
result[mainMenu_continue] = True;
#endif
#ifdef ALLOWLOGGING
if (screen->inhibit & I_LOG) {
result[mainMenu_logging] = True;
}
#endif
if (screen->inhibit & I_SIGNAL) {
int n;
for (n = (int) mainMenu_suspend; n <= (int) mainMenu_quit; ++n) {
result[n] = True;
}
}
break;
case vtMenu:
#ifndef NO_ACTIVE_ICON
if (!screen->fnt_icon.fs || !screen->iconVwin.window) {
result[vtMenu_activeicon] = True;
}
#endif /* NO_ACTIVE_ICON */
#if OPT_TEK4014
if (screen->inhibit & I_TEK) {
int n;
for (n = (int) vtMenu_tekshow; n <= (int) vtMenu_vthide; ++n) {
result[n] = True;
}
}
#endif
break;
case fontMenu:
break;
#if OPT_TEK4014
case tekMenu:
break;
#endif
case noMenu:
break;
}
return result;
}
/*
* create_menu - create a popup shell and stuff the menu into it.
*/
static Widget
create_menu(Widget w, XtermWidget xw, MenuIndex num)
{
static XtCallbackRec cb[2] =
{
{NULL, NULL},
{NULL, NULL}};
static Arg arg =
{XtNcallback, (XtArgVal) cb};
TScreen *screen = TScreenOf(xw);
const MenuHeader *data = &menu_names[num];
MenuList *list = select_menu(w, num);
struct _MenuEntry *entries = data->entry_list;
Cardinal nentries = data->entry_len;
#if !OPT_TOOLBAR
String saveLocale;
#endif
if (screen->menu_item_bitmap == None) {
/*
* we really want to do these dynamically
*/
#define check_width 9
#define check_height 8
static unsigned char check_bits[] =
{
0x00, 0x01, 0x80, 0x01, 0xc0, 0x00, 0x60, 0x00,
0x31, 0x00, 0x1b, 0x00, 0x0e, 0x00, 0x04, 0x00
};
screen->menu_item_bitmap =
XCreateBitmapFromData(XtDisplay(xw),
RootWindowOfScreen(XtScreen(xw)),
(char *) check_bits, check_width, check_height);
}
#if !OPT_TOOLBAR
saveLocale = setMenuLocale(True, resource.menuLocale);
list->w = XtCreatePopupShell(data->internal_name,
simpleMenuWidgetClass,
toplevel,
NULL, 0);
#endif
if (list->w != 0) {
Boolean *unused = unusedEntries(xw, num);
Cardinal n;
list->entries = 0;
for (n = 0; n < nentries; ++n) {
if (!unused[n]) {
cb[0].callback = (XtCallbackProc) entries[n].function;
cb[0].closure = (XtPointer) entries[n].name;
entries[n].widget = XtCreateManagedWidget(entries[n].name,
(entries[n].function
? smeBSBObjectClass
: smeLineObjectClass),
list->w,
&arg, (Cardinal) 1);
list->entries++;
}
}
}
#if !OPT_TOOLBAR
(void) setMenuLocale(False, saveLocale);
#endif
/* do not realize at this point */
return list->w;
}
static MenuIndex
indexOfMenu(String menuName)
{
MenuIndex me;
switch (*menuName) {
case 'm':
me = mainMenu;
break;
case 'v':
me = vtMenu;
break;
case 'f':
me = fontMenu;
break;
#if OPT_TEK4014
case 't':
me = tekMenu;
break;
#endif
default:
me = noMenu;
}
return (me);
}
/* ARGSUSED */
static Bool
domenu(Widget w,
XEvent *event GCC_UNUSED,
String *params, /* mainMenu, vtMenu, or tekMenu */
Cardinal *param_count) /* 0 or 1 */
{
XtermWidget xw = term;
TScreen *screen = TScreenOf(xw);
MenuIndex me;
Bool created = False;
Widget mw;
if (*param_count != 1) {
Bell(xw, XkbBI_MinorError, 0);
return False;
}
if ((me = indexOfMenu(params[0])) == noMenu) {
Bell(xw, XkbBI_MinorError, 0);
return False;
}
if ((mw = obtain_menu(w, me)) == 0
|| sizeof_menu(w, me) == 0) {
mw = create_menu(w, xw, me);
created = (mw != 0);
}
if (mw == 0)
return False;
TRACE(("domenu(%s) %s\n", params[0], created ? "create" : "update"));
switch (me) {
case mainMenu:
if (created) {
update_toolbar();
update_fullscreen();
update_securekbd();
update_allowsends();
update_logging();
update_print_redir();
update_8bit_control();
update_decbkm();
update_num_lock();
update_alt_esc();
update_meta_esc();
update_delete_del();
update_keyboard_type();
#ifdef OPT_PRINT_ON_EXIT
screen->write_error = !IsEmpty(resource.printFileOnXError);
SetItemSensitivity(mainMenuEntries[mainMenu_write_now].widget, False);
SetItemSensitivity(mainMenuEntries[mainMenu_write_error].widget, screen->write_error);
#endif
}
break;
case vtMenu:
if (created) {
update_scrollbar();
update_jumpscroll();
update_reversevideo();
update_autowrap();
update_reversewrap();
update_autolinefeed();
update_appcursor();
update_appkeypad();
update_scrollkey();
update_scrollttyoutput();
update_allow132();
update_cursesemul();
update_keepSelection();
update_selectToClipboard();
update_visualbell();
update_poponbell();
update_bellIsUrgent();
update_cursorblink();
update_altscreen();
update_decsdm(); /* Sixel Display Mode */
update_titeInhibit();
#ifndef NO_ACTIVE_ICON
update_activeicon();
#endif /* NO_ACTIVE_ICON */
update_privatecolorregisters();
}
break;
case fontMenu:
if (created) {
int n;
set_menu_font(True);
for (n = fontMenu_font1; n <= fontMenu_font6; ++n) {
if (IsEmpty(screen->menu_font_names[n][fNorm]))
SetItemSensitivity(fontMenuEntries[n].widget, False);
}
update_font_escape();
update_menu_allowBoldFonts();
#if OPT_BOX_CHARS
update_font_boxchars();
SetItemSensitivity(
fontMenuEntries[fontMenu_font_boxchars].widget,
True);
update_font_packed();
SetItemSensitivity(
fontMenuEntries[fontMenu_font_packedfont].widget,
True);
#endif
#if OPT_DEC_SOFTFONT /* FIXME: not implemented */
update_font_loadable();
SetItemSensitivity(
fontMenuEntries[fontMenu_font_loadable].widget,
False);
#endif
#if OPT_DEC_CHRSET
update_font_doublesize();
if (TScreenOf(xw)->cache_doublesize == 0)
SetItemSensitivity(
fontMenuEntries[fontMenu_font_doublesize].widget,
False);
#endif
#if OPT_RENDERFONT
update_font_renderfont();
#endif
#if OPT_WIDE_CHARS
update_font_utf8_mode();
update_font_utf8_fonts();
update_font_utf8_title();
#endif
#if OPT_ALLOW_XXX_OPS
update_menu_allowColorOps();
update_menu_allowFontOps();
update_menu_allowTcapOps();
update_menu_allowTitleOps();
update_menu_allowWindowOps();
enable_allow_xxx_ops(!(screen->allowSendEvents));
#endif
}
#if OPT_TOOLBAR
/* menus for toolbar are initialized once only */
SetItemSensitivity(fontMenuEntries[fontMenu_fontsel].widget, True);
#else
FindFontSelection(xw, NULL, True);
SetItemSensitivity(fontMenuEntries[fontMenu_fontsel].widget,
(screen->SelectFontName()
? True
: False));
#endif
break;
#if OPT_TEK4014
case tekMenu:
if (created && tekWidget) {
set_tekfont_menu_item(TekScreenOf(tekWidget)->cur.fontsize, True);
update_vtshow();
}
break;
#endif
case noMenu:
default:
break;
}
return True;
}
/*
* public interfaces
*/
void
HandleCreateMenu(Widget w,
XEvent *event,
String *params, /* mainMenu, vtMenu, or tekMenu */
Cardinal *param_count) /* 0 or 1 */
{
TRACE(("HandleCreateMenu\n"));
(void) domenu(w, event, params, param_count);
}
void
HandlePopupMenu(Widget w,
XEvent *event,
String *params, /* mainMenu, vtMenu, or tekMenu */
Cardinal *param_count) /* 0 or 1 */
{
TRACE(("HandlePopupMenu\n"));
if (domenu(w, event, params, param_count)) {
XtermWidget xw = term;
TScreen *screen = TScreenOf(xw);
#if OPT_TOOLBAR
w = select_menu(w, mainMenu)->w;
#endif
/*
* The action procedure in SimpleMenu.c, PositionMenu does not expect a
* key translation event when we are popping up a menu. In particular,
* if the pointer is outside the menu, then the action procedure will
* fail in its attempt to determine the location of the pointer within
* the menu. Anticipate that by warping the pointer into the menu when
* a key event is detected.
*/
switch (event->type) {
case KeyPress:
case KeyRelease:
XWarpPointer(screen->display, None, XtWindow(w), 0, 0, 0, 0, 0, 0);
break;
default:
XtCallActionProc(w, "XawPositionSimpleMenu", event, params, 1);
break;
}
XtCallActionProc(w, "MenuPopup", event, params, 1);
}
}
/*
* private interfaces - keep out!
*/
/* ARGSUSED */
static void
handle_send_signal(Widget gw GCC_UNUSED, int sig)
{
#ifndef VMS
TScreen *screen = TScreenOf(term);
if (hold_screen > 1)
hold_screen = 0;
if (screen->pid > 1)
kill_process_group(screen->pid, sig);
#endif
}
static void
UpdateMenuItem(
#if OPT_TRACE
const char *func,
#endif
MenuEntry * menu,
int which,
Bool val)
{
static Arg menuArgs =
{XtNleftBitmap, (XtArgVal) 0};
Widget mi = menu[which].widget;
if (mi) {
menuArgs.value = (XtArgVal) ((val)
? TScreenOf(term)->menu_item_bitmap
: None);
XtSetValues(mi, &menuArgs, (Cardinal) 1);
}
TRACE(("%s(%d): %s\n", func, which, MtoS(val)));
}
void
SetItemSensitivity(Widget mi, Bool val)
{
static Arg menuArgs =
{XtNsensitive, (XtArgVal) 0};
if (mi) {
menuArgs.value = (XtArgVal) (val);