1 /* $XTermId: menu.c,v 1.367 2021/06/03 21:23:40 tom Exp $ */
2
3 /*
4 * Copyright 1999-2020,2021 by Thomas E. Dickey
5 *
6 * All Rights Reserved
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sublicense, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
23 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 *
27 * Except as contained in this notice, the name(s) of the above copyright
28 * holders shall not be used in advertising or otherwise to promote the
29 * sale, use or other dealings in this Software without prior written
30 * authorization.
31 *
32 *
33 * Copyright 1989 X Consortium
34 *
35 * Permission to use, copy, modify, distribute, and sell this software and its
36 * documentation for any purpose is hereby granted without fee, provided that
37 * the above copyright notice appear in all copies and that both that
38 * copyright notice and this permission notice appear in supporting
39 * documentation.
40 *
41 * The above copyright notice and this permission notice shall be included in
42 * all copies or substantial portions of the Software.
43 *
44 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
46 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
47 * OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
48 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
49 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
50 *
51 * Except as contained in this notice, the name of the X Consortium shall not be
52 * used in advertising or otherwise to promote the sale, use or other dealings
53 * in this Software without prior written authorization from the X Consortium.
54 */
55
56 #include <xterm.h>
57 #include <data.h>
58 #include <menu.h>
59 #include <fontutils.h>
60 #include <xstrings.h>
61
62 #include <X11/Xmu/CharSet.h>
63
64 #define app_con Xaw_app_con /* quiet a warning from SimpleMenu.h */
65
66 #if defined(HAVE_LIB_XAW)
67
68 #include <X11/Xaw/SimpleMenu.h>
69 #include <X11/Xaw/Box.h>
70 #include <X11/Xaw/SmeBSB.h>
71 #include <X11/Xaw/SmeLine.h>
72
73 #if OPT_TOOLBAR
74 #include <X11/Xaw/MenuButton.h>
75 #include <X11/Xaw/Form.h>
76 #endif
77
78 #elif defined(HAVE_LIB_XAW3D)
79
80 #include <X11/Xaw3d/SimpleMenu.h>
81 #include <X11/Xaw3d/Box.h>
82 #include <X11/Xaw3d/SmeBSB.h>
83 #include <X11/Xaw3d/SmeLine.h>
84
85 #if OPT_TOOLBAR
86 #include <X11/Xaw3d/MenuButton.h>
87 #include <X11/Xaw3d/Form.h>
88 #endif
89
90 #elif defined(HAVE_LIB_XAW3DXFT)
91
92 #include <X11/Xaw3dxft/SimpleMenu.h>
93 #include <X11/Xaw3dxft/Box.h>
94 #include <X11/Xaw3dxft/SmeBSB.h>
95 #include <X11/Xaw3dxft/SmeLine.h>
96
97 #if OPT_TOOLBAR
98 #include <X11/Xaw3dxft/MenuButton.h>
99 #include <X11/Xaw3dxft/Form.h>
100 #endif
101
102 #elif defined(HAVE_LIB_NEXTAW)
103
104 #include <X11/neXtaw/SimpleMenu.h>
105 #include <X11/neXtaw/Box.h>
106 #include <X11/neXtaw/SmeBSB.h>
107 #include <X11/neXtaw/SmeLine.h>
108
109 #if OPT_TOOLBAR
110 #include <X11/neXtaw/MenuButton.h>
111 #include <X11/neXtaw/Form.h>
112 #endif
113
114 #elif defined(HAVE_LIB_XAWPLUS)
115
116 #include <X11/XawPlus/SimpleMenu.h>
117 #include <X11/XawPlus/Box.h>
118 #include <X11/XawPlus/SmeBSB.h>
119 #include <X11/XawPlus/SmeLine.h>
120
121 #if OPT_TOOLBAR
122 #include <X11/XawPlus/MenuButton.h>
123 #include <X11/XawPlus/Form.h>
124 #endif
125
126 #endif
127
128 #undef app_con
129
130 #include <stdio.h>
131 #include <signal.h>
132
133 #if OPT_TRACE
134 #define UpdateCheckbox(func, mn, mi, val) UpdateMenuItem(func, mn, mi, val)
135 #else
136 #define UpdateCheckbox(func, mn, mi, val) UpdateMenuItem(mn, mi, val)
137 #endif
138
139 #define ToggleFlag(flag) flag = (Boolean) !flag
140 /* *INDENT-OFF* */
141 static void do_8bit_control PROTO_XT_CALLBACK_ARGS;
142 static void do_allow132 PROTO_XT_CALLBACK_ARGS;
143 static void do_allowBoldFonts PROTO_XT_CALLBACK_ARGS;
144 static void do_allowsends PROTO_XT_CALLBACK_ARGS;
145 static void do_altscreen PROTO_XT_CALLBACK_ARGS;
146 static void do_appcursor PROTO_XT_CALLBACK_ARGS;
147 static void do_appkeypad PROTO_XT_CALLBACK_ARGS;
148 static void do_autolinefeed PROTO_XT_CALLBACK_ARGS;
149 static void do_autowrap PROTO_XT_CALLBACK_ARGS;
150 static void do_backarrow PROTO_XT_CALLBACK_ARGS;
151 static void do_bellIsUrgent PROTO_XT_CALLBACK_ARGS;
152 static void do_continue PROTO_XT_CALLBACK_ARGS;
153 static void do_delete_del PROTO_XT_CALLBACK_ARGS;
154 #if OPT_SCREEN_DUMPS
155 static void do_dump_html PROTO_XT_CALLBACK_ARGS;
156 static void do_dump_svg PROTO_XT_CALLBACK_ARGS;
157 #endif
158 static void do_interrupt PROTO_XT_CALLBACK_ARGS;
159 static void do_jumpscroll PROTO_XT_CALLBACK_ARGS;
160 static void do_keepClipboard PROTO_XT_CALLBACK_ARGS;
161 static void do_keepSelection PROTO_XT_CALLBACK_ARGS;
162 static void do_kill PROTO_XT_CALLBACK_ARGS;
163 static void do_old_fkeys PROTO_XT_CALLBACK_ARGS;
164 static void do_poponbell PROTO_XT_CALLBACK_ARGS;
165 static void do_print PROTO_XT_CALLBACK_ARGS;
166 static void do_print_redir PROTO_XT_CALLBACK_ARGS;
167 static void do_redraw PROTO_XT_CALLBACK_ARGS;
168 static void do_reversevideo PROTO_XT_CALLBACK_ARGS;
169 static void do_reversewrap PROTO_XT_CALLBACK_ARGS;
170 static void do_scrollbar PROTO_XT_CALLBACK_ARGS;
171 static void do_scrollkey PROTO_XT_CALLBACK_ARGS;
172 static void do_scrollttyoutput PROTO_XT_CALLBACK_ARGS;
173 static void do_securekbd PROTO_XT_CALLBACK_ARGS;
174 static void do_selectClipboard PROTO_XT_CALLBACK_ARGS;
175 static void do_suspend PROTO_XT_CALLBACK_ARGS;
176 static void do_terminate PROTO_XT_CALLBACK_ARGS;
177 static void do_titeInhibit PROTO_XT_CALLBACK_ARGS;
178 static void do_visualbell PROTO_XT_CALLBACK_ARGS;
179 static void do_vtfont PROTO_XT_CALLBACK_ARGS;
180
181 static GCC_NORETURN void do_clearsavedlines PROTO_XT_CALLBACK_ARGS;
182 static GCC_NORETURN void do_hardreset PROTO_XT_CALLBACK_ARGS;
183 static GCC_NORETURN void do_quit PROTO_XT_CALLBACK_ARGS;
184 static GCC_NORETURN void do_softreset PROTO_XT_CALLBACK_ARGS;
185
186 #ifdef ALLOWLOGGING
187 static void do_logging PROTO_XT_CALLBACK_ARGS;
188 #endif
189
190 #ifndef NO_ACTIVE_ICON
191 static void do_activeicon PROTO_XT_CALLBACK_ARGS;
192 #endif /* NO_ACTIVE_ICON */
193
194 #if OPT_ALLOW_XXX_OPS
195 static void enable_allow_xxx_ops (Bool);
196 static void do_allowColorOps PROTO_XT_CALLBACK_ARGS;
197 static void do_allowFontOps PROTO_XT_CALLBACK_ARGS;
198 static void do_allowMouseOps PROTO_XT_CALLBACK_ARGS;
199 static void do_allowTcapOps PROTO_XT_CALLBACK_ARGS;
200 static void do_allowTitleOps PROTO_XT_CALLBACK_ARGS;
201 static void do_allowWindowOps PROTO_XT_CALLBACK_ARGS;
202 #endif
203
204 #if OPT_BLINK_CURS
205 static void do_cursorblink PROTO_XT_CALLBACK_ARGS;
206 #endif
207
208 #if OPT_BOX_CHARS
209 static void do_font_boxchars PROTO_XT_CALLBACK_ARGS;
210 static void do_font_packed PROTO_XT_CALLBACK_ARGS;
211 #endif
212
213 #if OPT_DEC_CHRSET
214 static void do_font_doublesize PROTO_XT_CALLBACK_ARGS;
215 #endif
216
217 #if OPT_DEC_SOFTFONT
218 static void do_font_loadable PROTO_XT_CALLBACK_ARGS;
219 #endif
220
221 #if OPT_HP_FUNC_KEYS
222 static void do_hp_fkeys PROTO_XT_CALLBACK_ARGS;
223 #endif
224
225 #if OPT_MAXIMIZE
226 static void do_fullscreen PROTO_XT_CALLBACK_ARGS;
227 #endif
228
229 #if OPT_NUM_LOCK
230 static void do_alt_esc PROTO_XT_CALLBACK_ARGS;
231 static void do_num_lock PROTO_XT_CALLBACK_ARGS;
232 static void do_meta_esc PROTO_XT_CALLBACK_ARGS;
233 #endif
234
235 #if OPT_PRINT_ON_EXIT
236 static void do_write_now PROTO_XT_CALLBACK_ARGS;
237 static void do_write_error PROTO_XT_CALLBACK_ARGS;
238 #endif
239
240 #if OPT_RENDERFONT
241 static void do_font_renderfont PROTO_XT_CALLBACK_ARGS;
242 #endif
243
244 #if OPT_SCO_FUNC_KEYS
245 static void do_sco_fkeys PROTO_XT_CALLBACK_ARGS;
246 #endif
247
248 #if OPT_SIXEL_GRAPHICS
249 static void do_sixelscrolling PROTO_XT_CALLBACK_ARGS;
250 #endif
251
252 #if OPT_GRAPHICS
253 static void do_privatecolorregisters PROTO_XT_CALLBACK_ARGS;
254 #endif
255
256 #if OPT_SUN_FUNC_KEYS
257 static void do_sun_fkeys PROTO_XT_CALLBACK_ARGS;
258 #endif
259
260 #if OPT_SUNPC_KBD
261 static void do_sun_kbd PROTO_XT_CALLBACK_ARGS;
262 #endif
263
264 #if OPT_TCAP_FKEYS
265 static void do_tcap_fkeys PROTO_XT_CALLBACK_ARGS;
266 #endif
267
268 #if OPT_TEK4014
269 static void do_tekcopy PROTO_XT_CALLBACK_ARGS;
270 static void do_tekhide PROTO_XT_CALLBACK_ARGS;
271 static void do_tekmode PROTO_XT_CALLBACK_ARGS;
272 static void do_tekonoff PROTO_XT_CALLBACK_ARGS;
273 static void do_tekpage PROTO_XT_CALLBACK_ARGS;
274 static void do_tekreset PROTO_XT_CALLBACK_ARGS;
275 static void do_tekshow PROTO_XT_CALLBACK_ARGS;
276 static void do_tektext2 PROTO_XT_CALLBACK_ARGS;
277 static void do_tektext3 PROTO_XT_CALLBACK_ARGS;
278 static void do_tektextlarge PROTO_XT_CALLBACK_ARGS;
279 static void do_tektextsmall PROTO_XT_CALLBACK_ARGS;
280 static void do_vthide PROTO_XT_CALLBACK_ARGS;
281 static void do_vtmode PROTO_XT_CALLBACK_ARGS;
282 static void do_vtonoff PROTO_XT_CALLBACK_ARGS;
283 static void do_vtshow PROTO_XT_CALLBACK_ARGS;
284 static void handle_tekshow (Widget gw, Bool allowswitch);
285 static void handle_vtshow (Widget gw, Bool allowswitch);
286 #endif
287
288 #if OPT_TOOLBAR
289 static void do_toolbar PROTO_XT_CALLBACK_ARGS;
290 #endif
291
292 #if OPT_WIDE_CHARS
293 static void do_font_utf8_mode PROTO_XT_CALLBACK_ARGS;
294 static void do_font_utf8_fonts PROTO_XT_CALLBACK_ARGS;
295 static void do_font_utf8_title PROTO_XT_CALLBACK_ARGS;
296 #endif
297
298 /*
299 * The order of entries MUST match the values given in menu.h
300 */
301 MenuEntry mainMenuEntries[] = {
302 #if OPT_TOOLBAR
303 { "toolbar", do_toolbar, NULL },
304 #endif
305 #if OPT_MAXIMIZE
306 { "fullscreen", do_fullscreen, NULL },
307 #endif
308 { "securekbd", do_securekbd, NULL },
309 { "allowsends", do_allowsends, NULL },
310 { "redraw", do_redraw, NULL },
311 { "line1", NULL, NULL },
312 #ifdef ALLOWLOGGING
313 { "logging", do_logging, NULL },
314 #endif
315 #ifdef OPT_PRINT_ON_EXIT
316 { "print-immediate", do_write_now, NULL },
317 { "print-on-error", do_write_error, NULL },
318 #endif
319 { "print", do_print, NULL },
320 { "print-redir", do_print_redir, NULL },
321 #if OPT_SCREEN_DUMPS
322 { "dump-html", do_dump_html, NULL },
323 { "dump-svg", do_dump_svg, NULL },
324 #endif
325 { "line2", NULL, NULL },
326 { "8-bit control", do_8bit_control,NULL },
327 { "backarrow key", do_backarrow, NULL },
328 #if OPT_NUM_LOCK
329 { "num-lock", do_num_lock, NULL },
330 { "alt-esc", do_alt_esc, NULL },
331 { "meta-esc", do_meta_esc, NULL },
332 #endif
333 { "delete-is-del", do_delete_del, NULL },
334 { "oldFunctionKeys",do_old_fkeys, NULL },
335 #if OPT_TCAP_FKEYS
336 { "tcapFunctionKeys",do_tcap_fkeys, NULL },
337 #endif
338 #if OPT_HP_FUNC_KEYS
339 { "hpFunctionKeys", do_hp_fkeys, NULL },
340 #endif
341 #if OPT_SCO_FUNC_KEYS
342 { "scoFunctionKeys",do_sco_fkeys, NULL },
343 #endif
344 #if OPT_SUN_FUNC_KEYS
345 { "sunFunctionKeys",do_sun_fkeys, NULL },
346 #endif
347 #if OPT_SUNPC_KBD
348 { "sunKeyboard", do_sun_kbd, NULL },
349 #endif
350 { "line3", NULL, NULL },
351 { "suspend", do_suspend, NULL },
352 { "continue", do_continue, NULL },
353 { "interrupt", do_interrupt, NULL },
354 { "hangup", do_hangup, NULL },
355 { "terminate", do_terminate, NULL },
356 { "kill", do_kill, NULL },
357 { "line4", NULL, NULL },
358 { "quit", do_quit, NULL }};
359
360 MenuEntry vtMenuEntries[] = {
361 { "scrollbar", do_scrollbar, NULL },
362 { "jumpscroll", do_jumpscroll, NULL },
363 { "reversevideo", do_reversevideo, NULL },
364 { "autowrap", do_autowrap, NULL },
365 { "reversewrap", do_reversewrap, NULL },
366 { "autolinefeed", do_autolinefeed, NULL },
367 { "appcursor", do_appcursor, NULL },
368 { "appkeypad", do_appkeypad, NULL },
369 { "scrollkey", do_scrollkey, NULL },
370 { "scrollttyoutput",do_scrollttyoutput, NULL },
371 { "allow132", do_allow132, NULL },
372 { "keepSelection", do_keepSelection, NULL },
373 #if OPT_MENU_KEEPCLIPBOARD
374 { "keepClipboard", do_keepClipboard, NULL },
375 #endif
376 { "selectToClipboard",do_selectClipboard, NULL },
377 { "visualbell", do_visualbell, NULL },
378 { "bellIsUrgent", do_bellIsUrgent, NULL },
379 { "poponbell", do_poponbell, NULL },
380 #if OPT_BLINK_CURS
381 { "cursorblink", do_cursorblink, NULL },
382 #endif
383 { "titeInhibit", do_titeInhibit, NULL },
384 #ifndef NO_ACTIVE_ICON
385 { "activeicon", do_activeicon, NULL },
386 #endif /* NO_ACTIVE_ICON */
387 { "line1", NULL, NULL },
388 { "softreset", do_softreset, NULL },
389 { "hardreset", do_hardreset, NULL },
390 { "clearsavedlines",do_clearsavedlines, NULL },
391 { "line2", NULL, NULL },
392 #if OPT_TEK4014
393 { "tekshow", do_tekshow, NULL },
394 { "tekmode", do_tekmode, NULL },
395 { "vthide", do_vthide, NULL },
396 #endif
397 { "altscreen", do_altscreen, NULL },
398 #if OPT_SIXEL_GRAPHICS
399 { "sixelScrolling", do_sixelscrolling, NULL },
400 #endif
401 #if OPT_GRAPHICS
402 { "privateColorRegisters", do_privatecolorregisters, NULL },
403 #endif
404 };
405
406 MenuEntry fontMenuEntries[] = {
407 { "fontdefault", do_vtfont, NULL },
408 { "font1", do_vtfont, NULL },
409 { "font2", do_vtfont, NULL },
410 { "font3", do_vtfont, NULL },
411 { "font4", do_vtfont, NULL },
412 { "font5", do_vtfont, NULL },
413 { "font6", do_vtfont, NULL },
414 { "font7", do_vtfont, NULL },
415 /* this is after the last builtin font; the other entries are special */
416 { "fontescape", do_vtfont, NULL },
417 { "fontsel", do_vtfont, NULL },
418 /* down to here should match NMENUFONTS in ptyx.h */
419
420 #if OPT_DEC_CHRSET || OPT_BOX_CHARS || OPT_DEC_SOFTFONT
421 { "line1", NULL, NULL },
422 { "allow-bold-fonts", do_allowBoldFonts, NULL },
423 #if OPT_BOX_CHARS
424 { "font-linedrawing",do_font_boxchars,NULL },
425 { "font-packed", do_font_packed,NULL },
426 #endif
427 #if OPT_DEC_CHRSET
428 { "font-doublesize",do_font_doublesize,NULL },
429 #endif
430 #if OPT_DEC_SOFTFONT
431 { "font-loadable", do_font_loadable,NULL },
432 #endif
433 #endif /* toggles for DEC font extensions */
434
435 #if OPT_RENDERFONT || OPT_WIDE_CHARS
436 { "line2", NULL, NULL },
437 #if OPT_RENDERFONT
438 { "render-font", do_font_renderfont,NULL },
439 #endif
440 #if OPT_WIDE_CHARS
441 { "utf8-mode", do_font_utf8_mode,NULL },
442 { "utf8-fonts", do_font_utf8_fonts,NULL },
443 { "utf8-title", do_font_utf8_title,NULL },
444 #endif
445 #endif /* toggles for other font extensions */
446
447 #if OPT_ALLOW_XXX_OPS
448 { "line3", NULL, NULL },
449 { "allow-color-ops",do_allowColorOps,NULL },
450 { "allow-font-ops", do_allowFontOps,NULL },
451 { "allow-mouse-ops",do_allowMouseOps,NULL },
452 { "allow-tcap-ops", do_allowTcapOps,NULL },
453 { "allow-title-ops",do_allowTitleOps,NULL },
454 { "allow-window-ops",do_allowWindowOps,NULL },
455 #endif
456
457 };
458
459 #if OPT_TEK4014
460 MenuEntry tekMenuEntries[] = {
461 { "tektextlarge", do_tektextlarge, NULL },
462 { "tektext2", do_tektext2, NULL },
463 { "tektext3", do_tektext3, NULL },
464 { "tektextsmall", do_tektextsmall, NULL },
465 { "line1", NULL, NULL },
466 { "tekpage", do_tekpage, NULL },
467 { "tekreset", do_tekreset, NULL },
468 { "tekcopy", do_tekcopy, NULL },
469 { "line2", NULL, NULL },
470 { "vtshow", do_vtshow, NULL },
471 { "vtmode", do_vtmode, NULL },
472 { "tekhide", do_tekhide, NULL }};
473 #endif
474
475 typedef struct {
476 char *internal_name;
477 MenuEntry *entry_list;
478 Cardinal entry_len;
479 } MenuHeader;
480
481 /* This table is ordered to correspond with MenuIndex */
482 #define DATA(name) { (char *)#name, name ## Entries, XtNumber(name ## Entries ) }
483 static const MenuHeader menu_names[] = {
484 DATA( mainMenu),
485 DATA( vtMenu),
486 DATA( fontMenu),
487 #if OPT_TEK4014
488 DATA( tekMenu),
489 #endif
490 { NULL, 0, 0 },
491 };
492 #undef DATA
493 /* *INDENT-ON* */
494
495 /*
496 * FIXME: These are global data rather than in the xterm widget because they
497 * are initialized before the widget is created.
498 */
499 typedef struct {
500 Widget b; /* the toolbar's buttons */
501 Widget w; /* the popup shell activated by the button */
502 Cardinal entries;
503 } MenuList;
504
505 static MenuList vt_shell[NUM_POPUP_MENUS];
506
507 #if OPT_TEK4014 && OPT_TOOLBAR
508 static MenuList tek_shell[NUM_POPUP_MENUS];
509 #endif
510
511 /*
512 * Returns a pointer to the MenuList entry that matches the popup menu.
513 */
514 static MenuList *
select_menu(Widget w,MenuIndex num)515 select_menu(Widget w, MenuIndex num)
516 {
517 #if OPT_TEK4014 && OPT_TOOLBAR
518 while (w != 0) {
519 if (w == tekshellwidget) {
520 return &tek_shell[num];
521 }
522 w = XtParent(w);
523 }
524 #else
525 (void) w;
526 #endif
527 return &vt_shell[num];
528 }
529
530 /*
531 * Returns a pointer to the given popup menu shell
532 */
533 static Widget
obtain_menu(Widget w,MenuIndex num)534 obtain_menu(Widget w, MenuIndex num)
535 {
536 return select_menu(w, num)->w;
537 }
538
539 /*
540 * Returns the number of entries in the given popup menu shell
541 */
542 static Cardinal
sizeof_menu(Widget w,MenuIndex num)543 sizeof_menu(Widget w, MenuIndex num)
544 {
545 return select_menu(w, num)->entries;
546 }
547
548 /*
549 * Return an array of flags telling if a given menu item is never going to
550 * be used, so we can reduce the size of menus.
551 */
552 static Boolean *
unusedEntries(XtermWidget xw,MenuIndex num)553 unusedEntries(XtermWidget xw, MenuIndex num)
554 {
555 static Boolean result[XtNumber(mainMenuEntries)
556 + XtNumber(vtMenuEntries)
557 + XtNumber(fontMenuEntries)
558 #if OPT_TEK4014
559 + XtNumber(tekMenuEntries)
560 #endif
561 ];
562 TScreen *screen = TScreenOf(xw);
563
564 memset(result, 0, sizeof(result));
565 switch (num) {
566 case mainMenu:
567 #if OPT_MAXIMIZE
568 if (resource.fullscreen > 1) {
569 result[mainMenu_fullscreen] = True;
570 }
571 #endif
572 #if OPT_NUM_LOCK
573 if (!screen->alt_is_not_meta) {
574 result[mainMenu_alt_esc] = True;
575 }
576 #endif
577 if (!xtermHasPrinter(xw)) {
578 result[mainMenu_print] = True;
579 result[mainMenu_print_redir] = True;
580 }
581 if (screen->terminal_id < 200) {
582 result[mainMenu_8bit_ctrl] = True;
583 }
584 #if !defined(SIGTSTP)
585 result[mainMenu_suspend] = True;
586 #endif
587 #if !defined(SIGCONT)
588 result[mainMenu_continue] = True;
589 #endif
590 #ifdef ALLOWLOGGING
591 if (screen->inhibit & I_LOG) {
592 result[mainMenu_logging] = True;
593 }
594 #endif
595 if (screen->inhibit & I_SIGNAL) {
596 int n;
597 for (n = (int) mainMenu_suspend; n <= (int) mainMenu_quit; ++n) {
598 result[n] = True;
599 }
600 }
601 break;
602 case vtMenu:
603 #if !defined(NO_ACTIVE_ICON) && !OPT_TOOLBAR
604 if (!getIconicFont(screen)->fs || !screen->iconVwin.window) {
605 result[vtMenu_activeicon] = True;
606 }
607 #endif /* NO_ACTIVE_ICON */
608 #if OPT_TEK4014
609 if (screen->inhibit & I_TEK) {
610 int n;
611 for (n = (int) vtMenu_tekshow; n <= (int) vtMenu_vthide; ++n) {
612 result[n] = True;
613 }
614 }
615 #endif
616 break;
617 case fontMenu:
618 break;
619 #if OPT_TEK4014
620 case tekMenu:
621 break;
622 #endif
623 case noMenu:
624 break;
625 }
626 return result;
627 }
628
629 /*
630 * When using the toolbar configuration, some systems (seen with Solaris 11)
631 * give a warning that (Xt) cannot find a usable font-set. This does not stop
632 * the toolbars from working - ignore for now.
633 */
634 #if OPT_TOOLBAR
635 static void
ignoreWarning(String p_name,String p_type,String p_class,String p_default,String * p_params,Cardinal * p_num_params)636 ignoreWarning(
637 String p_name,
638 String p_type,
639 String p_class,
640 String p_default,
641 String *p_params,
642 Cardinal *p_num_params)
643 {
644 (void) p_name;
645 (void) p_type;
646 (void) p_class;
647 (void) p_default;
648 (void) p_params;
649 (void) p_num_params;
650 }
651 #endif
652
653 /*
654 * create_menu - create a popup shell and stuff the menu into it.
655 */
656 static Widget
create_menu(Widget w,XtermWidget xw,MenuIndex num)657 create_menu(Widget w, XtermWidget xw, MenuIndex num)
658 {
659 static XtCallbackRec cb[2] =
660 {
661 {NULL, NULL},
662 {NULL, NULL}};
663 static Arg arg =
664 {XtNcallback, (XtArgVal) cb};
665
666 TScreen *screen = TScreenOf(xw);
667 const MenuHeader *data = &menu_names[num];
668 MenuList *list = select_menu(w, num);
669 struct _MenuEntry *entries = data->entry_list;
670 Cardinal nentries = data->entry_len;
671 #if !OPT_TOOLBAR
672 char *saveLocale;
673 #endif
674
675 if (screen->menu_item_bitmap == None) {
676 /*
677 * we really want to do these dynamically
678 */
679 #define check_width 9
680 #define check_height 8
681 static unsigned char check_bits[] =
682 {
683 0x00, 0x01, 0x80, 0x01, 0xc0, 0x00, 0x60, 0x00,
684 0x31, 0x00, 0x1b, 0x00, 0x0e, 0x00, 0x04, 0x00
685 };
686
687 screen->menu_item_bitmap =
688 XCreateBitmapFromData(XtDisplay(xw),
689 RootWindowOfScreen(XtScreen(xw)),
690 (char *) check_bits, check_width, check_height);
691 }
692 #if !OPT_TOOLBAR
693 saveLocale = xtermSetLocale(LC_CTYPE, resource.menuLocale);
694 list->w = XtCreatePopupShell(data->internal_name,
695 simpleMenuWidgetClass,
696 toplevel,
697 NULL, 0);
698 TRACE(("created popupShell(%s) widget %p, window %#lx\n",
699 data->internal_name, list->w, XtWindow(list->w)));
700 #endif
701 if (list->w != 0) {
702 Boolean *unused = unusedEntries(xw, num);
703 Cardinal n;
704 #if OPT_TOOLBAR
705 Boolean useLocale = !strcmp(resource.menuLocale, "");
706 XtErrorMsgHandler warningHandler = 0;
707 if (!useLocale)
708 warningHandler = XtAppSetWarningMsgHandler(app_con, ignoreWarning);
709 #endif
710
711 list->entries = 0;
712
713 for (n = 0; n < nentries; ++n) {
714 if (!unused[n]) {
715 cb[0].callback = (XtCallbackProc) entries[n].function;
716 cb[0].closure = (XtPointer) entries[n].name;
717 entries[n].widget = XtCreateManagedWidget(entries[n].name,
718 (entries[n].function
719 ? smeBSBObjectClass
720 : smeLineObjectClass),
721 list->w,
722 &arg, (Cardinal) 1);
723 TRACE(("created menuEntry[%d] widget %p, window %#lx\n",
724 n, (void *) entries[n].widget, XtWindow(entries[n].widget)));
725 list->entries++;
726 }
727 }
728 #if OPT_TOOLBAR
729 if (!useLocale)
730 XtAppSetWarningMsgHandler(app_con, warningHandler);
731 #endif
732 }
733 #if !OPT_TOOLBAR
734 xtermResetLocale(LC_CTYPE, saveLocale);
735 #endif
736
737 /* do not realize at this point */
738 return list->w;
739 }
740
741 static MenuIndex
indexOfMenu(String menuName)742 indexOfMenu(String menuName)
743 {
744 MenuIndex me;
745 switch (*menuName) {
746 case 'm':
747 me = mainMenu;
748 break;
749 case 'v':
750 me = vtMenu;
751 break;
752 case 'f':
753 me = fontMenu;
754 break;
755 #if OPT_TEK4014
756 case 't':
757 me = tekMenu;
758 break;
759 #endif
760 default:
761 me = noMenu;
762 }
763 return (me);
764 }
765
766 /* ARGSUSED */
767 static Bool
domenu(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)768 domenu(Widget w,
769 XEvent *event GCC_UNUSED,
770 String *params, /* mainMenu, vtMenu, or tekMenu */
771 Cardinal *param_count) /* 0 or 1 */
772 {
773 XtermWidget xw = term;
774 TScreen *screen = TScreenOf(xw);
775 MenuIndex me;
776 Bool created = False;
777 Widget mw;
778
779 if (*param_count != 1) {
780 Bell(xw, XkbBI_MinorError, 0);
781 return False;
782 }
783
784 if ((me = indexOfMenu(params[0])) == noMenu) {
785 Bell(xw, XkbBI_MinorError, 0);
786 return False;
787 }
788
789 if ((mw = obtain_menu(w, me)) == 0
790 || sizeof_menu(w, me) == 0) {
791 mw = create_menu(w, xw, me);
792 created = (mw != 0);
793 }
794 if (mw == 0)
795 return False;
796
797 TRACE(("domenu(%s) %s\n", params[0], created ? "create" : "update"));
798 switch (me) {
799 case mainMenu:
800 if (created) {
801 update_toolbar();
802 update_fullscreen();
803 update_securekbd();
804 update_allowsends();
805 update_logging();
806 update_print_redir();
807 update_8bit_control();
808 update_decbkm();
809 update_num_lock();
810 update_alt_esc();
811 update_meta_esc();
812 update_delete_del();
813 update_keyboard_type();
814 #ifdef OPT_PRINT_ON_EXIT
815 screen->write_error = !IsEmpty(resource.printFileOnXError);
816 SetItemSensitivity(mainMenuEntries[mainMenu_write_now].widget, True);
817 SetItemSensitivity(mainMenuEntries[mainMenu_write_error].widget, screen->write_error);
818 #endif
819 }
820 break;
821
822 case vtMenu:
823 if (created) {
824 update_scrollbar();
825 update_jumpscroll();
826 update_reversevideo();
827 update_autowrap();
828 update_reversewrap();
829 update_autolinefeed();
830 update_appcursor();
831 update_appkeypad();
832 update_scrollkey();
833 update_scrollttyoutput();
834 update_allow132();
835 update_cursesemul();
836 update_keepSelection();
837 update_selectToClipboard();
838 update_visualbell();
839 update_poponbell();
840 update_bellIsUrgent();
841 update_cursorblink();
842 update_altscreen();
843 update_decsdm(); /* Sixel Display Mode */
844 update_titeInhibit();
845 #ifndef NO_ACTIVE_ICON
846 update_activeicon();
847 #endif /* NO_ACTIVE_ICON */
848 update_privatecolorregisters();
849 }
850 break;
851
852 case fontMenu:
853 if (created) {
854 int n;
855
856 set_menu_font(True);
857 for (n = fontMenu_font1; n <= fontMenu_font7; ++n) {
858 if (IsEmpty(screen->menu_font_names[n][fNorm]))
859 SetItemSensitivity(fontMenuEntries[n].widget, False);
860 }
861 update_font_escape();
862 update_menu_allowBoldFonts();
863 #if OPT_BOX_CHARS
864 update_font_boxchars();
865 update_font_packed();
866 SetItemSensitivity(
867 fontMenuEntries[fontMenu_font_packedfont].widget,
868 True);
869 #endif
870 #if OPT_DEC_SOFTFONT /* FIXME: not implemented */
871 update_font_loadable();
872 SetItemSensitivity(
873 fontMenuEntries[fontMenu_font_loadable].widget,
874 False);
875 #endif
876 #if OPT_DEC_CHRSET
877 update_font_doublesize();
878 if (TScreenOf(xw)->cache_doublesize == 0)
879 SetItemSensitivity(
880 fontMenuEntries[fontMenu_font_doublesize].widget,
881 False);
882 #endif
883 #if OPT_RENDERFONT
884 update_font_renderfont();
885 #endif
886 #if OPT_WIDE_CHARS
887 update_font_utf8_mode();
888 update_font_utf8_fonts();
889 update_font_utf8_title();
890 #endif
891 #if OPT_ALLOW_XXX_OPS
892 update_menu_allowColorOps();
893 update_menu_allowFontOps();
894 update_menu_allowMouseOps();
895 update_menu_allowTcapOps();
896 update_menu_allowTitleOps();
897 update_menu_allowWindowOps();
898 enable_allow_xxx_ops(!(screen->allowSendEvents));
899 #endif
900 }
901 #if OPT_TOOLBAR
902 /* menus for toolbar are initialized once only */
903 SetItemSensitivity(fontMenuEntries[fontMenu_fontsel].widget, True);
904 #else
905 FindFontSelection(xw, NULL, True);
906 SetItemSensitivity(fontMenuEntries[fontMenu_fontsel].widget,
907 (screen->SelectFontName()
908 ? True
909 : False));
910 #endif
911 break;
912
913 #if OPT_TEK4014
914 case tekMenu:
915 if (created && tekWidget) {
916 set_tekfont_menu_item(TekScreenOf(tekWidget)->cur.fontsize, True);
917 update_vtshow();
918 }
919 break;
920 #endif
921 case noMenu:
922 default:
923 break;
924 }
925
926 return True;
927 }
928
929 /*
930 * public interfaces
931 */
932
933 void
HandleCreateMenu(Widget w,XEvent * event,String * params,Cardinal * param_count)934 HandleCreateMenu(Widget w,
935 XEvent *event,
936 String *params, /* mainMenu, vtMenu, or tekMenu */
937 Cardinal *param_count) /* 0 or 1 */
938 {
939 TRACE(("HandleCreateMenu\n"));
940 (void) domenu(w, event, params, param_count);
941 }
942
943 void
HandlePopupMenu(Widget w,XEvent * event,String * params,Cardinal * param_count)944 HandlePopupMenu(Widget w,
945 XEvent *event,
946 String *params, /* mainMenu, vtMenu, or tekMenu */
947 Cardinal *param_count) /* 0 or 1 */
948 {
949 TRACE(("HandlePopupMenu\n"));
950 if (domenu(w, event, params, param_count)) {
951 XtermWidget xw = term;
952 TScreen *screen = TScreenOf(xw);
953
954 #if OPT_TOOLBAR
955 w = select_menu(w, mainMenu)->w;
956 #endif
957 /*
958 * The action procedure in SimpleMenu.c, PositionMenu does not expect a
959 * key translation event when we are popping up a menu. In particular,
960 * if the pointer is outside the menu, then the action procedure will
961 * fail in its attempt to determine the location of the pointer within
962 * the menu. Anticipate that by warping the pointer into the menu when
963 * a key event is detected.
964 */
965 switch (event->type) {
966 case KeyPress:
967 case KeyRelease:
968 XWarpPointer(screen->display, None, XtWindow(w), 0, 0, 0, 0, 0, 0);
969 break;
970 default:
971 XtCallActionProc(w, "XawPositionSimpleMenu", event, params, 1);
972 break;
973 }
974 XtCallActionProc(w, "MenuPopup", event, params, 1);
975 }
976 }
977
978 /*
979 * private interfaces - keep out!
980 */
981
982 /* ARGSUSED */
983 static void
handle_send_signal(Widget gw GCC_UNUSED,int sig)984 handle_send_signal(Widget gw GCC_UNUSED, int sig)
985 {
986 #ifndef VMS
987 TScreen *screen = TScreenOf(term);
988
989 if (hold_screen > 1)
990 hold_screen = 0;
991 if (screen->pid > 1)
992 kill_process_group(screen->pid, sig);
993 #endif
994 }
995
996 #if OPT_VT52_MODE
997 static void
DisableIfVT52(MenuEntry * menu,int which)998 DisableIfVT52(MenuEntry * menu, int which)
999 {
1000 Widget mi = menu[which].widget;
1001 SetItemSensitivity(mi, TScreenOf(term)->vtXX_level != 0);
1002 }
1003
1004 #else
1005 #define DisableIfVT52(which,val) /* nothing */
1006 #endif
1007
1008 static void
UpdateMenuItem(const char * func,MenuEntry * menu,int which,Bool val)1009 UpdateMenuItem(
1010 #if OPT_TRACE
1011 const char *func,
1012 #endif
1013 MenuEntry * menu,
1014 int which,
1015 Bool val)
1016 {
1017 static Arg menuArgs =
1018 {XtNleftBitmap, (XtArgVal) 0};
1019 Widget mi = menu[which].widget;
1020
1021 if (mi) {
1022 menuArgs.value = (XtArgVal) ((val)
1023 ? TScreenOf(term)->menu_item_bitmap
1024 : None);
1025 XtSetValues(mi, &menuArgs, (Cardinal) 1);
1026 }
1027 TRACE(("%s(%d): %s\n", func, which, MtoS(val)));
1028 }
1029
1030 void
SetItemSensitivity(Widget mi,Bool val)1031 SetItemSensitivity(Widget mi, Bool val)
1032 {
1033 static Arg menuArgs =
1034 {XtNsensitive, (XtArgVal) 0};
1035
1036 if (mi) {
1037 menuArgs.value = (XtArgVal) (val);
1038 XtSetValues(mi, &menuArgs, (Cardinal) 1);
1039 }
1040 }
1041
1042 /*
1043 * action routines
1044 */
1045
1046 static void
do_securekbd(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1047 do_securekbd(Widget gw GCC_UNUSED,
1048 XtPointer closure GCC_UNUSED,
1049 XtPointer data GCC_UNUSED)
1050 {
1051 XtermWidget xw = term;
1052 TScreen *screen = TScreenOf(xw);
1053 Time now = CurrentTime; /* XXX - wrong */
1054
1055 if (screen->grabbedKbd) {
1056 XUngrabKeyboard(screen->display, now);
1057 ReverseVideo(xw);
1058 screen->grabbedKbd = False;
1059 } else {
1060 if (XGrabKeyboard(screen->display, XtWindow(CURRENT_EMU()),
1061 True, GrabModeAsync, GrabModeAsync, now)
1062 != GrabSuccess) {
1063 Bell(xw, XkbBI_MinorError, 100);
1064 } else {
1065 ReverseVideo(xw);
1066 screen->grabbedKbd = True;
1067 }
1068 }
1069 update_securekbd();
1070 }
1071
1072 /* ARGSUSED */
1073 void
HandleSecure(Widget w GCC_UNUSED,XEvent * event GCC_UNUSED,String * params GCC_UNUSED,Cardinal * param_count GCC_UNUSED)1074 HandleSecure(Widget w GCC_UNUSED,
1075 XEvent *event GCC_UNUSED, /* unused */
1076 String *params GCC_UNUSED, /* [0] = volume */
1077 Cardinal *param_count GCC_UNUSED) /* 0 or 1 */
1078 {
1079 do_securekbd(vt_shell[mainMenu].w, (XtPointer) 0, (XtPointer) 0);
1080 }
1081
1082 static void
do_allowsends(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1083 do_allowsends(Widget gw GCC_UNUSED,
1084 XtPointer closure GCC_UNUSED,
1085 XtPointer data GCC_UNUSED)
1086 {
1087 TScreen *screen = TScreenOf(term);
1088
1089 ToggleFlag(screen->allowSendEvents);
1090 update_allowsends();
1091 #if OPT_ALLOW_XXX_OPS
1092 enable_allow_xxx_ops(!(screen->allowSendEvents));
1093 #endif
1094 }
1095
1096 static void
do_visualbell(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1097 do_visualbell(Widget gw GCC_UNUSED,
1098 XtPointer closure GCC_UNUSED,
1099 XtPointer data GCC_UNUSED)
1100 {
1101 TScreen *screen = TScreenOf(term);
1102
1103 ToggleFlag(screen->visualbell);
1104 update_visualbell();
1105 }
1106
1107 static void
do_bellIsUrgent(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1108 do_bellIsUrgent(Widget gw GCC_UNUSED,
1109 XtPointer closure GCC_UNUSED,
1110 XtPointer data GCC_UNUSED)
1111 {
1112 TScreen *screen = TScreenOf(term);
1113
1114 ToggleFlag(screen->bellIsUrgent);
1115 update_bellIsUrgent();
1116 }
1117
1118 static void
do_poponbell(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1119 do_poponbell(Widget gw GCC_UNUSED,
1120 XtPointer closure GCC_UNUSED,
1121 XtPointer data GCC_UNUSED)
1122 {
1123 TScreen *screen = TScreenOf(term);
1124
1125 ToggleFlag(screen->poponbell);
1126 update_poponbell();
1127 }
1128
1129 #ifdef ALLOWLOGGING
1130 static void
do_logging(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1131 do_logging(Widget gw GCC_UNUSED,
1132 XtPointer closure GCC_UNUSED,
1133 XtPointer data GCC_UNUSED)
1134 {
1135 XtermWidget xw = term;
1136 TScreen *screen = TScreenOf(xw);
1137
1138 if (screen->logging) {
1139 CloseLog(xw);
1140 } else {
1141 StartLog(xw);
1142 }
1143 /* update_logging done by CloseLog and StartLog */
1144 }
1145 #endif
1146
1147 #ifdef OPT_PRINT_ON_EXIT
1148 static void
do_write_now(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1149 do_write_now(Widget gw GCC_UNUSED,
1150 XtPointer closure GCC_UNUSED,
1151 XtPointer data GCC_UNUSED)
1152 {
1153 XtermWidget xw = term;
1154
1155 xtermPrintImmediately(xw,
1156 (IsEmpty(resource.printFileNow)
1157 ? (String) "XTerm"
1158 : resource.printFileNow),
1159 resource.printOptsNow,
1160 resource.printModeNow);
1161 }
1162
1163 void
HandlePrintImmediate(Widget w GCC_UNUSED,XEvent * event GCC_UNUSED,String * params GCC_UNUSED,Cardinal * param_count GCC_UNUSED)1164 HandlePrintImmediate(Widget w GCC_UNUSED,
1165 XEvent *event GCC_UNUSED,
1166 String *params GCC_UNUSED,
1167 Cardinal *param_count GCC_UNUSED)
1168 {
1169 do_write_now((Widget) 0, (XtPointer) 0, (XtPointer) 0);
1170 }
1171
1172 static void
do_write_error(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1173 do_write_error(Widget gw GCC_UNUSED,
1174 XtPointer closure GCC_UNUSED,
1175 XtPointer data GCC_UNUSED)
1176 {
1177 XtermWidget xw = term;
1178
1179 if (IsEmpty(resource.printFileOnXError)) {
1180 resource.printFileOnXError = "XTermError";
1181 }
1182 TScreenOf(xw)->write_error = (Boolean) (!TScreenOf(xw)->write_error);
1183 update_write_error();
1184 }
1185
1186 void
HandlePrintOnError(Widget w GCC_UNUSED,XEvent * event GCC_UNUSED,String * params GCC_UNUSED,Cardinal * param_count GCC_UNUSED)1187 HandlePrintOnError(Widget w GCC_UNUSED,
1188 XEvent *event GCC_UNUSED,
1189 String *params GCC_UNUSED,
1190 Cardinal *param_count GCC_UNUSED)
1191 {
1192 do_write_error((Widget) 0, (XtPointer) 0, (XtPointer) 0);
1193 }
1194 #endif
1195
1196 static void
do_print(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1197 do_print(Widget gw GCC_UNUSED,
1198 XtPointer closure GCC_UNUSED,
1199 XtPointer data GCC_UNUSED)
1200 {
1201 xtermPrintScreen(term, True, getPrinterFlags(term, NULL, 0));
1202 }
1203
1204 static void
do_print_redir(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1205 do_print_redir(Widget gw GCC_UNUSED,
1206 XtPointer closure GCC_UNUSED,
1207 XtPointer data GCC_UNUSED)
1208 {
1209 setPrinterControlMode(term,
1210 (PrinterOf(TScreenOf(term)).printer_controlmode
1211 ? 0
1212 : 2));
1213 }
1214
1215 #if OPT_SCREEN_DUMPS
1216 static void
do_dump_html(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1217 do_dump_html(Widget gw GCC_UNUSED,
1218 XtPointer closure GCC_UNUSED,
1219 XtPointer data GCC_UNUSED)
1220 {
1221 xtermDumpHtml(term);
1222 }
1223
1224 static void
do_dump_svg(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1225 do_dump_svg(Widget gw GCC_UNUSED,
1226 XtPointer closure GCC_UNUSED,
1227 XtPointer data GCC_UNUSED)
1228 {
1229 xtermDumpSvg(term);
1230 }
1231 #endif
1232
1233 static void
do_redraw(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1234 do_redraw(Widget gw GCC_UNUSED,
1235 XtPointer closure GCC_UNUSED,
1236 XtPointer data GCC_UNUSED)
1237 {
1238 Redraw();
1239 }
1240
1241 void
show_8bit_control(Bool value)1242 show_8bit_control(Bool value)
1243 {
1244 if (TScreenOf(term)->control_eight_bits != value) {
1245 TScreenOf(term)->control_eight_bits = (Boolean) value;
1246 update_8bit_control();
1247 }
1248 }
1249
1250 static void
do_8bit_control(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1251 do_8bit_control(Widget gw GCC_UNUSED,
1252 XtPointer closure GCC_UNUSED,
1253 XtPointer data GCC_UNUSED)
1254 {
1255 show_8bit_control(!TScreenOf(term)->control_eight_bits);
1256 }
1257
1258 static void
do_backarrow(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1259 do_backarrow(Widget gw GCC_UNUSED,
1260 XtPointer closure GCC_UNUSED,
1261 XtPointer data GCC_UNUSED)
1262 {
1263 term->keyboard.flags ^= MODE_DECBKM;
1264 update_decbkm();
1265 }
1266
1267 #if OPT_NUM_LOCK
1268 static void
do_num_lock(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1269 do_num_lock(Widget gw GCC_UNUSED,
1270 XtPointer closure GCC_UNUSED,
1271 XtPointer data GCC_UNUSED)
1272 {
1273 ToggleFlag(term->misc.real_NumLock);
1274 update_num_lock();
1275 }
1276
1277 static void
do_alt_esc(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1278 do_alt_esc(Widget gw GCC_UNUSED,
1279 XtPointer closure GCC_UNUSED,
1280 XtPointer data GCC_UNUSED)
1281 {
1282 ToggleFlag(TScreenOf(term)->alt_sends_esc);
1283 update_alt_esc();
1284 }
1285
1286 static void
do_meta_esc(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1287 do_meta_esc(Widget gw GCC_UNUSED,
1288 XtPointer closure GCC_UNUSED,
1289 XtPointer data GCC_UNUSED)
1290 {
1291 ToggleFlag(TScreenOf(term)->meta_sends_esc);
1292 update_meta_esc();
1293 }
1294 #endif
1295
1296 static void
do_delete_del(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1297 do_delete_del(Widget gw GCC_UNUSED,
1298 XtPointer closure GCC_UNUSED,
1299 XtPointer data GCC_UNUSED)
1300 {
1301 if (xtermDeleteIsDEL(term))
1302 TScreenOf(term)->delete_is_del = False;
1303 else
1304 TScreenOf(term)->delete_is_del = True;
1305 update_delete_del();
1306 }
1307
1308 static void
do_old_fkeys(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1309 do_old_fkeys(Widget gw GCC_UNUSED,
1310 XtPointer closure GCC_UNUSED,
1311 XtPointer data GCC_UNUSED)
1312 {
1313 toggle_keyboard_type(term, keyboardIsLegacy);
1314 }
1315
1316 #if OPT_HP_FUNC_KEYS
1317 static void
do_hp_fkeys(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1318 do_hp_fkeys(Widget gw GCC_UNUSED,
1319 XtPointer closure GCC_UNUSED,
1320 XtPointer data GCC_UNUSED)
1321 {
1322 toggle_keyboard_type(term, keyboardIsHP);
1323 }
1324 #endif
1325
1326 #if OPT_SCO_FUNC_KEYS
1327 static void
do_sco_fkeys(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1328 do_sco_fkeys(Widget gw GCC_UNUSED,
1329 XtPointer closure GCC_UNUSED,
1330 XtPointer data GCC_UNUSED)
1331 {
1332 toggle_keyboard_type(term, keyboardIsSCO);
1333 }
1334 #endif
1335
1336 #if OPT_SUN_FUNC_KEYS
1337 static void
do_sun_fkeys(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1338 do_sun_fkeys(Widget gw GCC_UNUSED,
1339 XtPointer closure GCC_UNUSED,
1340 XtPointer data GCC_UNUSED)
1341 {
1342 toggle_keyboard_type(term, keyboardIsSun);
1343 }
1344 #endif
1345
1346 #if OPT_SUNPC_KBD
1347 /*
1348 * This really means "Sun/PC keyboard emulating VT220".
1349 */
1350 static void
do_sun_kbd(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1351 do_sun_kbd(Widget gw GCC_UNUSED,
1352 XtPointer closure GCC_UNUSED,
1353 XtPointer data GCC_UNUSED)
1354 {
1355 toggle_keyboard_type(term, keyboardIsVT220);
1356 }
1357 #endif
1358
1359 #if OPT_TCAP_FKEYS
1360 static void
do_tcap_fkeys(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1361 do_tcap_fkeys(Widget gw GCC_UNUSED,
1362 XtPointer closure GCC_UNUSED,
1363 XtPointer data GCC_UNUSED)
1364 {
1365 toggle_keyboard_type(term, keyboardIsTermcap);
1366 }
1367 #endif
1368
1369 /*
1370 * The following cases use the pid instead of the process group so that we
1371 * don't get hosed by programs that change their process group
1372 */
1373
1374 /* ARGSUSED */
1375 static void
do_suspend(Widget gw,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1376 do_suspend(Widget gw,
1377 XtPointer closure GCC_UNUSED,
1378 XtPointer data GCC_UNUSED)
1379 {
1380 #if defined(SIGTSTP)
1381 handle_send_signal(gw, SIGTSTP);
1382 #endif
1383 }
1384
1385 /* ARGSUSED */
1386 static void
do_continue(Widget gw,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1387 do_continue(Widget gw,
1388 XtPointer closure GCC_UNUSED,
1389 XtPointer data GCC_UNUSED)
1390 {
1391 #if defined(SIGCONT)
1392 handle_send_signal(gw, SIGCONT);
1393 #endif
1394 }
1395
1396 /* ARGSUSED */
1397 static void
do_interrupt(Widget gw,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1398 do_interrupt(Widget gw,
1399 XtPointer closure GCC_UNUSED,
1400 XtPointer data GCC_UNUSED)
1401 {
1402 handle_send_signal(gw, SIGINT);
1403 }
1404
1405 /* ARGSUSED */
1406 void
do_hangup(Widget gw,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1407 do_hangup(Widget gw,
1408 XtPointer closure GCC_UNUSED,
1409 XtPointer data GCC_UNUSED)
1410 {
1411 handle_send_signal(gw, SIGHUP);
1412 }
1413
1414 /* ARGSUSED */
1415 static void
do_terminate(Widget gw,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1416 do_terminate(Widget gw,
1417 XtPointer closure GCC_UNUSED,
1418 XtPointer data GCC_UNUSED)
1419 {
1420 handle_send_signal(gw, SIGTERM);
1421 }
1422
1423 /* ARGSUSED */
1424 static void
do_kill(Widget gw,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1425 do_kill(Widget gw,
1426 XtPointer closure GCC_UNUSED,
1427 XtPointer data GCC_UNUSED)
1428 {
1429 handle_send_signal(gw, SIGKILL);
1430 }
1431
1432 static void
do_quit(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1433 do_quit(Widget gw GCC_UNUSED,
1434 XtPointer closure GCC_UNUSED,
1435 XtPointer data GCC_UNUSED)
1436 {
1437 Cleanup(SIGHUP);
1438 }
1439
1440 /*
1441 * vt menu callbacks
1442 */
1443
1444 static void
do_scrollbar(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1445 do_scrollbar(Widget gw GCC_UNUSED,
1446 XtPointer closure GCC_UNUSED,
1447 XtPointer data GCC_UNUSED)
1448 {
1449 ToggleScrollBar(term);
1450 }
1451
1452 static void
do_jumpscroll(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1453 do_jumpscroll(Widget gw GCC_UNUSED,
1454 XtPointer closure GCC_UNUSED,
1455 XtPointer data GCC_UNUSED)
1456 {
1457 TScreen *screen = TScreenOf(term);
1458
1459 term->flags ^= SMOOTHSCROLL;
1460 if (term->flags & SMOOTHSCROLL) {
1461 screen->jumpscroll = False;
1462 if (screen->scroll_amt)
1463 FlushScroll(term);
1464 } else {
1465 screen->jumpscroll = True;
1466 }
1467 update_jumpscroll();
1468 }
1469
1470 static void
do_reversevideo(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1471 do_reversevideo(Widget gw GCC_UNUSED,
1472 XtPointer closure GCC_UNUSED,
1473 XtPointer data GCC_UNUSED)
1474 {
1475 ReverseVideo(term);
1476 }
1477
1478 static void
do_autowrap(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1479 do_autowrap(Widget gw GCC_UNUSED,
1480 XtPointer closure GCC_UNUSED,
1481 XtPointer data GCC_UNUSED)
1482 {
1483 term->flags ^= WRAPAROUND;
1484 update_autowrap();
1485 }
1486
1487 static void
do_reversewrap(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1488 do_reversewrap(Widget gw GCC_UNUSED,
1489 XtPointer closure GCC_UNUSED,
1490 XtPointer data GCC_UNUSED)
1491 {
1492 term->flags ^= REVERSEWRAP;
1493 update_reversewrap();
1494 }
1495
1496 static void
do_autolinefeed(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1497 do_autolinefeed(Widget gw GCC_UNUSED,
1498 XtPointer closure GCC_UNUSED,
1499 XtPointer data GCC_UNUSED)
1500 {
1501 term->flags ^= LINEFEED;
1502 update_autolinefeed();
1503 }
1504
1505 static void
do_appcursor(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1506 do_appcursor(Widget gw GCC_UNUSED,
1507 XtPointer closure GCC_UNUSED,
1508 XtPointer data GCC_UNUSED)
1509 {
1510 term->keyboard.flags ^= MODE_DECCKM;
1511 update_appcursor();
1512 }
1513
1514 static void
do_appkeypad(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1515 do_appkeypad(Widget gw GCC_UNUSED,
1516 XtPointer closure GCC_UNUSED,
1517 XtPointer data GCC_UNUSED)
1518 {
1519 term->keyboard.flags ^= MODE_DECKPAM;
1520 update_appkeypad();
1521 }
1522
1523 static void
do_scrollkey(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1524 do_scrollkey(Widget gw GCC_UNUSED,
1525 XtPointer closure GCC_UNUSED,
1526 XtPointer data GCC_UNUSED)
1527 {
1528 TScreen *screen = TScreenOf(term);
1529
1530 ToggleFlag(screen->scrollkey);
1531 update_scrollkey();
1532 }
1533
1534 static void
do_scrollttyoutput(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1535 do_scrollttyoutput(Widget gw GCC_UNUSED,
1536 XtPointer closure GCC_UNUSED,
1537 XtPointer data GCC_UNUSED)
1538 {
1539 TScreen *screen = TScreenOf(term);
1540
1541 ToggleFlag(screen->scrollttyoutput);
1542 update_scrollttyoutput();
1543 }
1544
1545 #if OPT_MENU_KEEPCLIPBOARD
1546 void
update_keepClipboard(void)1547 update_keepClipboard(void)
1548 {
1549 UpdateCheckbox("update_keepClipboard",
1550 vtMenuEntries,
1551 vtMenu_keepClipboard,
1552 TScreenOf(term)->keepClipboard);
1553 }
1554 #endif
1555
1556 static void
do_keepClipboard(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1557 do_keepClipboard(Widget gw GCC_UNUSED,
1558 XtPointer closure GCC_UNUSED,
1559 XtPointer data GCC_UNUSED)
1560 {
1561 TScreen *screen = TScreenOf(term);
1562
1563 ToggleFlag(screen->keepClipboard);
1564 update_keepClipboard();
1565 }
1566
1567 static void
do_keepSelection(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1568 do_keepSelection(Widget gw GCC_UNUSED,
1569 XtPointer closure GCC_UNUSED,
1570 XtPointer data GCC_UNUSED)
1571 {
1572 TScreen *screen = TScreenOf(term);
1573
1574 ToggleFlag(screen->keepSelection);
1575 update_keepSelection();
1576 }
1577
1578 static void
do_selectClipboard(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1579 do_selectClipboard(Widget gw GCC_UNUSED,
1580 XtPointer closure GCC_UNUSED,
1581 XtPointer data GCC_UNUSED)
1582 {
1583 TScreen *screen = TScreenOf(term);
1584
1585 ToggleFlag(screen->selectToClipboard);
1586 update_selectToClipboard();
1587 }
1588
1589 static void
do_allow132(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1590 do_allow132(Widget gw GCC_UNUSED,
1591 XtPointer closure GCC_UNUSED,
1592 XtPointer data GCC_UNUSED)
1593 {
1594 TScreen *screen = TScreenOf(term);
1595
1596 ToggleFlag(screen->c132);
1597 update_allow132();
1598 }
1599
1600 static void
do_cursesemul(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1601 do_cursesemul(Widget gw GCC_UNUSED,
1602 XtPointer closure GCC_UNUSED,
1603 XtPointer data GCC_UNUSED)
1604 {
1605 TScreen *screen = TScreenOf(term);
1606
1607 ToggleFlag(screen->curses);
1608 update_cursesemul();
1609 }
1610
1611 static void
do_marginbell(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1612 do_marginbell(Widget gw GCC_UNUSED,
1613 XtPointer closure GCC_UNUSED,
1614 XtPointer data GCC_UNUSED)
1615 {
1616 TScreen *screen = TScreenOf(term);
1617
1618 if ((ToggleFlag(screen->marginbell)) == 0)
1619 screen->bellArmed = -1;
1620 update_marginbell();
1621 }
1622
1623 #if OPT_TEK4014
1624 static void
handle_tekshow(Widget gw GCC_UNUSED,Bool allowswitch)1625 handle_tekshow(Widget gw GCC_UNUSED, Bool allowswitch)
1626 {
1627 XtermWidget xw = term;
1628 TScreen *screen = TScreenOf(xw);
1629
1630 TRACE(("Show tek-window\n"));
1631 if (!TEK4014_SHOWN(xw)) { /* not showing, turn on */
1632 set_tek_visibility(True);
1633 } else if (screen->Vshow || allowswitch) { /* is showing, turn off */
1634 set_tek_visibility(False);
1635 end_tek_mode(); /* WARNING: this does a longjmp */
1636 } else
1637 Bell(xw, XkbBI_MinorError, 0);
1638 }
1639
1640 /* ARGSUSED */
1641 static void
do_tekshow(Widget gw,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1642 do_tekshow(Widget gw,
1643 XtPointer closure GCC_UNUSED,
1644 XtPointer data GCC_UNUSED)
1645 {
1646 handle_tekshow(gw, True);
1647 }
1648
1649 /* ARGSUSED */
1650 static void
do_tekonoff(Widget gw,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1651 do_tekonoff(Widget gw,
1652 XtPointer closure GCC_UNUSED,
1653 XtPointer data GCC_UNUSED)
1654 {
1655 handle_tekshow(gw, False);
1656 }
1657 #endif /* OPT_TEK4014 */
1658
1659 #if OPT_BLINK_CURS
1660 /* ARGSUSED */
1661 static void
do_cursorblink(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1662 do_cursorblink(Widget gw GCC_UNUSED,
1663 XtPointer closure GCC_UNUSED,
1664 XtPointer data GCC_UNUSED)
1665 {
1666 ToggleCursorBlink(term);
1667 }
1668 #endif
1669
1670 /* ARGSUSED */
1671 static void
do_altscreen(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1672 do_altscreen(Widget gw GCC_UNUSED,
1673 XtPointer closure GCC_UNUSED,
1674 XtPointer data GCC_UNUSED)
1675 {
1676 ToggleAlternate(term);
1677 }
1678
1679 /* ARGSUSED */
1680 static void
do_titeInhibit(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1681 do_titeInhibit(Widget gw GCC_UNUSED,
1682 XtPointer closure GCC_UNUSED,
1683 XtPointer data GCC_UNUSED)
1684 {
1685 ToggleFlag(term->misc.titeInhibit);
1686 update_titeInhibit();
1687 }
1688
1689 #ifndef NO_ACTIVE_ICON
1690 /* ARGSUSED */
1691 static void
do_activeicon(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1692 do_activeicon(Widget gw GCC_UNUSED,
1693 XtPointer closure GCC_UNUSED,
1694 XtPointer data GCC_UNUSED)
1695 {
1696 TScreen *screen = TScreenOf(term);
1697
1698 if (screen->iconVwin.window) {
1699 Widget shell = XtParent(term);
1700 ToggleFlag(term->work.active_icon);
1701 XtVaSetValues(shell, XtNiconWindow,
1702 term->work.active_icon ? screen->iconVwin.window : None,
1703 (XtPointer) 0);
1704 update_activeicon();
1705 }
1706 }
1707 #endif /* NO_ACTIVE_ICON */
1708
1709 static void
do_softreset(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1710 do_softreset(Widget gw GCC_UNUSED,
1711 XtPointer closure GCC_UNUSED,
1712 XtPointer data GCC_UNUSED)
1713 {
1714 VTReset(term, False, False);
1715 }
1716
1717 static void
do_hardreset(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1718 do_hardreset(Widget gw GCC_UNUSED,
1719 XtPointer closure GCC_UNUSED,
1720 XtPointer data GCC_UNUSED)
1721 {
1722 VTReset(term, True, False);
1723 }
1724
1725 static void
do_clearsavedlines(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1726 do_clearsavedlines(Widget gw GCC_UNUSED,
1727 XtPointer closure GCC_UNUSED,
1728 XtPointer data GCC_UNUSED)
1729 {
1730 VTReset(term, True, True);
1731 }
1732
1733 #if OPT_TEK4014
1734 static void
do_tekmode(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1735 do_tekmode(Widget gw GCC_UNUSED,
1736 XtPointer closure GCC_UNUSED,
1737 XtPointer data GCC_UNUSED)
1738 {
1739 switch_modes(TEK4014_ACTIVE(term)); /* switch to tek mode */
1740 }
1741
1742 /* ARGSUSED */
1743 static void
do_vthide(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1744 do_vthide(Widget gw GCC_UNUSED,
1745 XtPointer closure GCC_UNUSED,
1746 XtPointer data GCC_UNUSED)
1747 {
1748 hide_vt_window();
1749 }
1750 #endif /* OPT_TEK4014 */
1751
1752 /*
1753 * vtfont menu
1754 */
1755
1756 static void
do_vtfont(Widget gw GCC_UNUSED,XtPointer closure,XtPointer data GCC_UNUSED)1757 do_vtfont(Widget gw GCC_UNUSED,
1758 XtPointer closure,
1759 XtPointer data GCC_UNUSED)
1760 {
1761 XtermWidget xw = term;
1762 char *entryname = (char *) closure;
1763 int i;
1764
1765 TRACE(("do_vtfont(%s)\n", entryname));
1766 for (i = 0; i < NMENUFONTS; i++) {
1767 if (strcmp(entryname, fontMenuEntries[i].name) == 0) {
1768 SetVTFont(xw, i, True, NULL);
1769 return;
1770 }
1771 }
1772 Bell(xw, XkbBI_MinorError, 0);
1773 }
1774
1775 #if OPT_DEC_CHRSET
1776 static void
do_font_doublesize(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1777 do_font_doublesize(Widget gw GCC_UNUSED,
1778 XtPointer closure GCC_UNUSED,
1779 XtPointer data GCC_UNUSED)
1780 {
1781 XtermWidget xw = term;
1782
1783 if (TScreenOf(xw)->cache_doublesize != 0)
1784 ToggleFlag(TScreenOf(xw)->font_doublesize);
1785 update_font_doublesize();
1786 Redraw();
1787 }
1788 #endif
1789
1790 #if OPT_BOX_CHARS
1791 static void
do_font_boxchars(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1792 do_font_boxchars(Widget gw GCC_UNUSED,
1793 XtPointer closure GCC_UNUSED,
1794 XtPointer data GCC_UNUSED)
1795 {
1796 ToggleFlag(TScreenOf(term)->force_box_chars);
1797 update_font_boxchars();
1798 Redraw();
1799 }
1800
1801 static void
do_font_packed(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1802 do_font_packed(Widget gw GCC_UNUSED,
1803 XtPointer closure GCC_UNUSED,
1804 XtPointer data GCC_UNUSED)
1805 {
1806 ToggleFlag(TScreenOf(term)->force_packed);
1807 update_font_packed();
1808 SetVTFont(term, TScreenOf(term)->menu_font_number, True, NULL);
1809 }
1810 #endif
1811
1812 #if OPT_DEC_SOFTFONT
1813 static void
do_font_loadable(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1814 do_font_loadable(Widget gw GCC_UNUSED,
1815 XtPointer closure GCC_UNUSED,
1816 XtPointer data GCC_UNUSED)
1817 {
1818 ToggleFlag(term->misc.font_loadable);
1819 update_font_loadable();
1820 }
1821 #endif
1822
1823 #if OPT_RENDERFONT
1824 static void
do_font_renderfont(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1825 do_font_renderfont(Widget gw GCC_UNUSED,
1826 XtPointer closure GCC_UNUSED,
1827 XtPointer data GCC_UNUSED)
1828 {
1829 XtermWidget xw = (XtermWidget) term;
1830 TScreen *screen = TScreenOf(xw);
1831 int fontnum = screen->menu_font_number;
1832 String name = TScreenOf(xw)->MenuFontName(fontnum);
1833
1834 DefaultRenderFont(xw);
1835 ToggleFlag(xw->work.render_font);
1836 update_font_renderfont();
1837 xtermLoadFont(xw, xtermFontName(name), True, fontnum);
1838 ScrnRefresh(term, 0, 0,
1839 MaxRows(screen),
1840 MaxCols(screen), True);
1841 }
1842 #endif
1843
1844 #if OPT_WIDE_CHARS
1845 static void
setup_wide_fonts(XtermWidget xw)1846 setup_wide_fonts(XtermWidget xw)
1847 {
1848 TScreen *screen = TScreenOf(xw);
1849
1850 if (screen->wide_chars) {
1851 if (xtermLoadWideFonts(xw, True)) {
1852 SetVTFont(xw, screen->menu_font_number, True, NULL);
1853 }
1854 } else {
1855 ChangeToWide(xw);
1856 }
1857 }
1858
1859 static void
setup_narrow_fonts(XtermWidget xw)1860 setup_narrow_fonts(XtermWidget xw)
1861 {
1862 TScreen *screen = TScreenOf(xw);
1863
1864 if (xtermLoadDefaultFonts(xw)) {
1865 SetVTFont(xw, screen->menu_font_number, True, NULL);
1866 }
1867 }
1868
1869 static void
do_font_utf8_mode(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1870 do_font_utf8_mode(Widget gw GCC_UNUSED,
1871 XtPointer closure GCC_UNUSED,
1872 XtPointer data GCC_UNUSED)
1873 {
1874 XtermWidget xw = term;
1875 TScreen *screen = TScreenOf(xw);
1876
1877 /*
1878 * If xterm was started with -wc option, it might not have the wide fonts.
1879 * If xterm was not started with -wc, it might not have wide cells.
1880 */
1881 if (!screen->utf8_mode) {
1882 setup_wide_fonts(xw);
1883 }
1884 switchPtyData(screen, !screen->utf8_mode);
1885 /*
1886 * We don't repaint the screen when switching UTF-8 on/off. When switching
1887 * on - the Latin-1 codes should paint as-is. When switching off, that's
1888 * hard to do properly.
1889 */
1890 }
1891
1892 static void
do_font_utf8_fonts(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1893 do_font_utf8_fonts(Widget gw GCC_UNUSED,
1894 XtPointer closure GCC_UNUSED,
1895 XtPointer data GCC_UNUSED)
1896 {
1897 XtermWidget xw = term;
1898 TScreen *screen = TScreenOf(xw);
1899
1900 ToggleFlag(screen->utf8_fonts);
1901 update_font_utf8_fonts();
1902
1903 if (screen->utf8_fonts) {
1904 setup_wide_fonts(xw);
1905 } else {
1906 setup_narrow_fonts(xw);
1907 }
1908 }
1909
1910 static void
do_font_utf8_title(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1911 do_font_utf8_title(Widget gw GCC_UNUSED,
1912 XtPointer closure GCC_UNUSED,
1913 XtPointer data GCC_UNUSED)
1914 {
1915 TScreen *screen = TScreenOf(term);
1916
1917 ToggleFlag(screen->utf8_title);
1918 update_font_utf8_title();
1919 }
1920 #endif
1921
1922 /*
1923 * tek menu
1924 */
1925
1926 #if OPT_TEK4014
1927 static void
do_tektextlarge(Widget gw,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1928 do_tektextlarge(Widget gw,
1929 XtPointer closure GCC_UNUSED,
1930 XtPointer data GCC_UNUSED)
1931 {
1932 TekSetFontSize(getTekWidget(gw), True, tekMenu_tektextlarge);
1933 }
1934
1935 static void
do_tektext2(Widget gw,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1936 do_tektext2(Widget gw,
1937 XtPointer closure GCC_UNUSED,
1938 XtPointer data GCC_UNUSED)
1939 {
1940 TekSetFontSize(getTekWidget(gw), True, tekMenu_tektext2);
1941 }
1942
1943 static void
do_tektext3(Widget gw,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1944 do_tektext3(Widget gw,
1945 XtPointer closure GCC_UNUSED,
1946 XtPointer data GCC_UNUSED)
1947 {
1948 TekSetFontSize(getTekWidget(gw), True, tekMenu_tektext3);
1949 }
1950
1951 static void
do_tektextsmall(Widget gw,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1952 do_tektextsmall(Widget gw,
1953 XtPointer closure GCC_UNUSED,
1954 XtPointer data GCC_UNUSED)
1955 {
1956 TekSetFontSize(getTekWidget(gw), True, tekMenu_tektextsmall);
1957 }
1958
1959 static void
do_tekpage(Widget gw,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1960 do_tekpage(Widget gw,
1961 XtPointer closure GCC_UNUSED,
1962 XtPointer data GCC_UNUSED)
1963 {
1964 TekSimulatePageButton(getTekWidget(gw), False);
1965 }
1966
1967 static void
do_tekreset(Widget gw,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1968 do_tekreset(Widget gw,
1969 XtPointer closure GCC_UNUSED,
1970 XtPointer data GCC_UNUSED)
1971 {
1972 TekSimulatePageButton(getTekWidget(gw), True);
1973 }
1974
1975 static void
do_tekcopy(Widget gw,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)1976 do_tekcopy(Widget gw,
1977 XtPointer closure GCC_UNUSED,
1978 XtPointer data GCC_UNUSED)
1979 {
1980 TekCopy(getTekWidget(gw));
1981 }
1982
1983 static void
handle_vtshow(Widget gw GCC_UNUSED,Bool allowswitch)1984 handle_vtshow(Widget gw GCC_UNUSED, Bool allowswitch)
1985 {
1986 XtermWidget xw = term;
1987 TScreen *screen = TScreenOf(xw);
1988
1989 TRACE(("Show vt-window\n"));
1990 if (!screen->Vshow) { /* not showing, turn on */
1991 set_vt_visibility(True);
1992 } else if (TEK4014_SHOWN(xw) || allowswitch) { /* is showing, turn off */
1993 set_vt_visibility(False);
1994 if (!TEK4014_ACTIVE(xw) && tekRefreshList)
1995 TekRefresh(tekWidget);
1996 end_vt_mode(); /* WARNING: this does a longjmp... */
1997 } else
1998 Bell(xw, XkbBI_MinorError, 0);
1999 }
2000
2001 static void
do_vtshow(Widget gw,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)2002 do_vtshow(Widget gw,
2003 XtPointer closure GCC_UNUSED,
2004 XtPointer data GCC_UNUSED)
2005 {
2006 handle_vtshow(gw, True);
2007 }
2008
2009 static void
do_vtonoff(Widget gw,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)2010 do_vtonoff(Widget gw,
2011 XtPointer closure GCC_UNUSED,
2012 XtPointer data GCC_UNUSED)
2013 {
2014 handle_vtshow(gw, False);
2015 }
2016
2017 static void
do_vtmode(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)2018 do_vtmode(Widget gw GCC_UNUSED,
2019 XtPointer closure GCC_UNUSED,
2020 XtPointer data GCC_UNUSED)
2021 {
2022 switch_modes(TEK4014_ACTIVE(term)); /* switch to vt, or from */
2023 }
2024
2025 /* ARGSUSED */
2026 static void
do_tekhide(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)2027 do_tekhide(Widget gw GCC_UNUSED,
2028 XtPointer closure GCC_UNUSED,
2029 XtPointer data GCC_UNUSED)
2030 {
2031 hide_tek_window();
2032 }
2033 #endif /* OPT_TEK4014 */
2034
2035 /*
2036 * public handler routines
2037 */
2038 int
decodeToggle(XtermWidget xw,String * params,Cardinal nparams)2039 decodeToggle(XtermWidget xw, String *params, Cardinal nparams)
2040 {
2041 int dir = toggleErr;
2042
2043 switch (nparams) {
2044 case 0:
2045 dir = toggleAll;
2046 break;
2047 case 1:
2048 if (XmuCompareISOLatin1(params[0], "on") == 0)
2049 dir = toggleOn;
2050 else if (XmuCompareISOLatin1(params[0], "off") == 0)
2051 dir = toggleOff;
2052 else if (XmuCompareISOLatin1(params[0], "toggle") == 0)
2053 dir = toggleAll;
2054 break;
2055 }
2056
2057 if (dir == toggleErr) {
2058 Bell(xw, XkbBI_MinorError, 0);
2059 }
2060
2061 return dir;
2062 }
2063
2064 static void
handle_toggle(void (* proc)PROTO_XT_CALLBACK_ARGS,int var,String * params,Cardinal nparams,Widget w,XtPointer closure,XtPointer data)2065 handle_toggle(void (*proc) PROTO_XT_CALLBACK_ARGS,
2066 int var,
2067 String *params,
2068 Cardinal nparams,
2069 Widget w,
2070 XtPointer closure,
2071 XtPointer data)
2072 {
2073 XtermWidget xw = term;
2074
2075 switch (decodeToggle(xw, params, nparams)) {
2076
2077 case toggleAll:
2078 (*proc) (w, closure, data);
2079 break;
2080
2081 case toggleOff:
2082 if (var)
2083 (*proc) (w, closure, data);
2084 else
2085 Bell(xw, XkbBI_MinorError, 0);
2086 break;
2087
2088 case toggleOn:
2089 if (!var)
2090 (*proc) (w, closure, data);
2091 else
2092 Bell(xw, XkbBI_MinorError, 0);
2093 break;
2094 }
2095 return;
2096 }
2097
2098 #define handle_vt_toggle(proc, var, params, nparams, w) \
2099 handle_toggle(proc, (int) (var), params, nparams, w, (XtPointer)0, (XtPointer)0)
2100
2101 #define HANDLE_VT_TOGGLE(name) \
2102 handle_vt_toggle(do_##name, TScreenOf(term)->name, params, *param_count, w)
2103
2104 #define handle_tek_toggle(proc, var, params, nparams, w) \
2105 handle_toggle(proc, (int) (var), params, nparams, w, (XtPointer)0, (XtPointer)0)
2106
2107 void
HandleAllowSends(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2108 HandleAllowSends(Widget w,
2109 XEvent *event GCC_UNUSED,
2110 String *params,
2111 Cardinal *param_count)
2112 {
2113 handle_vt_toggle(do_allowsends, TScreenOf(term)->allowSendEvents,
2114 params, *param_count, w);
2115 }
2116
2117 void
HandleSetVisualBell(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2118 HandleSetVisualBell(Widget w,
2119 XEvent *event GCC_UNUSED,
2120 String *params,
2121 Cardinal *param_count)
2122 {
2123 HANDLE_VT_TOGGLE(visualbell);
2124 }
2125
2126 void
HandleSetPopOnBell(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2127 HandleSetPopOnBell(Widget w,
2128 XEvent *event GCC_UNUSED,
2129 String *params,
2130 Cardinal *param_count)
2131 {
2132 HANDLE_VT_TOGGLE(poponbell);
2133 }
2134
2135 #ifdef ALLOWLOGGING
2136 void
HandleLogging(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2137 HandleLogging(Widget w,
2138 XEvent *event GCC_UNUSED,
2139 String *params,
2140 Cardinal *param_count)
2141 {
2142 HANDLE_VT_TOGGLE(logging);
2143 }
2144 #endif
2145
2146 #if OPT_PRINT_ON_EXIT
2147 void
HandleWriteNow(Widget w,XEvent * event GCC_UNUSED,String * params GCC_UNUSED,Cardinal * param_count GCC_UNUSED)2148 HandleWriteNow(Widget w,
2149 XEvent *event GCC_UNUSED,
2150 String *params GCC_UNUSED,
2151 Cardinal *param_count GCC_UNUSED)
2152 {
2153 do_write_now(w, 0, 0);
2154 }
2155
2156 void
HandleWriteError(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2157 HandleWriteError(Widget w,
2158 XEvent *event GCC_UNUSED,
2159 String *params,
2160 Cardinal *param_count)
2161 {
2162 HANDLE_VT_TOGGLE(write_error);
2163 }
2164 #endif
2165
2166 /* ARGSUSED */
2167 void
HandlePrintScreen(Widget w GCC_UNUSED,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2168 HandlePrintScreen(Widget w GCC_UNUSED,
2169 XEvent *event GCC_UNUSED,
2170 String *params,
2171 Cardinal *param_count)
2172 {
2173 xtermPrintScreen(term, True, getPrinterFlags(term, params, param_count));
2174 }
2175
2176 /* ARGSUSED */
2177 void
HandlePrintEverything(Widget w GCC_UNUSED,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2178 HandlePrintEverything(Widget w GCC_UNUSED,
2179 XEvent *event GCC_UNUSED,
2180 String *params,
2181 Cardinal *param_count)
2182 {
2183 xtermPrintEverything(term, getPrinterFlags(term, params, param_count));
2184 }
2185
2186 /* ARGSUSED */
2187 void
HandlePrintControlMode(Widget w,XEvent * event GCC_UNUSED,String * params GCC_UNUSED,Cardinal * param_count GCC_UNUSED)2188 HandlePrintControlMode(Widget w,
2189 XEvent *event GCC_UNUSED,
2190 String *params GCC_UNUSED,
2191 Cardinal *param_count GCC_UNUSED)
2192 {
2193 do_print_redir(w, (XtPointer) 0, (XtPointer) 0);
2194 }
2195
2196 /* ARGSUSED */
2197 void
HandleRedraw(Widget w,XEvent * event GCC_UNUSED,String * params GCC_UNUSED,Cardinal * param_count GCC_UNUSED)2198 HandleRedraw(Widget w,
2199 XEvent *event GCC_UNUSED,
2200 String *params GCC_UNUSED,
2201 Cardinal *param_count GCC_UNUSED)
2202 {
2203 do_redraw(w, (XtPointer) 0, (XtPointer) 0);
2204 }
2205
2206 /* ARGSUSED */
2207 void
HandleSendSignal(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2208 HandleSendSignal(Widget w,
2209 XEvent *event GCC_UNUSED,
2210 String *params,
2211 Cardinal *param_count)
2212 {
2213 /* *INDENT-OFF* */
2214 static const struct sigtab {
2215 const char *name;
2216 int sig;
2217 } signals[] = {
2218 #ifdef SIGTSTP
2219 { "suspend", SIGTSTP },
2220 { "tstp", SIGTSTP },
2221 #endif
2222 #ifdef SIGCONT
2223 { "cont", SIGCONT },
2224 #endif
2225 { "int", SIGINT },
2226 { "hup", SIGHUP },
2227 { "quit", SIGQUIT },
2228 { "alrm", SIGALRM },
2229 { "alarm", SIGALRM },
2230 { "term", SIGTERM },
2231 { "kill", SIGKILL },
2232 { NULL, 0 },
2233 };
2234 /* *INDENT-ON* */
2235
2236 if (*param_count == 1) {
2237 const struct sigtab *st;
2238
2239 for (st = signals; st->name; st++) {
2240 if (XmuCompareISOLatin1(st->name, params[0]) == 0) {
2241 handle_send_signal(w, st->sig);
2242 return;
2243 }
2244 }
2245 /* one could allow numeric values, but that would be a security hole */
2246 }
2247
2248 Bell(term, XkbBI_MinorError, 0);
2249 }
2250
2251 /* ARGSUSED */
2252 void
HandleQuit(Widget w,XEvent * event GCC_UNUSED,String * params GCC_UNUSED,Cardinal * param_count GCC_UNUSED)2253 HandleQuit(Widget w,
2254 XEvent *event GCC_UNUSED,
2255 String *params GCC_UNUSED,
2256 Cardinal *param_count GCC_UNUSED)
2257 {
2258 do_quit(w, (XtPointer) 0, (XtPointer) 0);
2259 }
2260
2261 void
Handle8BitControl(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2262 Handle8BitControl(Widget w,
2263 XEvent *event GCC_UNUSED,
2264 String *params,
2265 Cardinal *param_count)
2266 {
2267 handle_vt_toggle(do_8bit_control, TScreenOf(term)->control_eight_bits,
2268 params, *param_count, w);
2269 }
2270
2271 void
HandleBackarrow(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2272 HandleBackarrow(Widget w,
2273 XEvent *event GCC_UNUSED,
2274 String *params,
2275 Cardinal *param_count)
2276 {
2277 handle_vt_toggle(do_backarrow, term->keyboard.flags & MODE_DECBKM,
2278 params, *param_count, w);
2279 }
2280
2281 #if OPT_MAXIMIZE
2282 #if OPT_TEK4014
2283 #define WhichEWMH (TEK4014_ACTIVE(xw) != 0)
2284 #else
2285 #define WhichEWMH 0
2286 #endif
2287 static void
do_fullscreen(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)2288 do_fullscreen(Widget gw GCC_UNUSED,
2289 XtPointer closure GCC_UNUSED,
2290 XtPointer data GCC_UNUSED)
2291 {
2292 XtermWidget xw = term;
2293
2294 if (resource.fullscreen != esNever)
2295 FullScreen(xw, !xw->work.ewmh[WhichEWMH].mode);
2296 }
2297
2298 /* ARGSUSED */
2299 void
HandleFullscreen(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2300 HandleFullscreen(Widget w,
2301 XEvent *event GCC_UNUSED,
2302 String *params,
2303 Cardinal *param_count)
2304 {
2305 XtermWidget xw = term;
2306
2307 if (resource.fullscreen != esNever) {
2308 handle_vt_toggle(do_fullscreen, xw->work.ewmh[WhichEWMH].mode,
2309 params, *param_count, w);
2310 }
2311 }
2312
2313 void
update_fullscreen(void)2314 update_fullscreen(void)
2315 {
2316 XtermWidget xw = term;
2317
2318 if (resource.fullscreen <= 1) {
2319 UpdateCheckbox("update_fullscreen",
2320 mainMenuEntries,
2321 mainMenu_fullscreen,
2322 xw->work.ewmh[WhichEWMH].mode);
2323 } else {
2324 SetItemSensitivity(mainMenuEntries[mainMenu_fullscreen].widget,
2325 False);
2326 }
2327 }
2328
2329 #endif /* OPT_MAXIMIZE */
2330
2331 #if OPT_SIXEL_GRAPHICS
2332 static void
do_sixelscrolling(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)2333 do_sixelscrolling(Widget gw GCC_UNUSED,
2334 XtPointer closure GCC_UNUSED,
2335 XtPointer data GCC_UNUSED)
2336 {
2337 term->keyboard.flags ^= MODE_DECSDM;
2338 update_decsdm();
2339 }
2340
2341 void
update_decsdm(void)2342 update_decsdm(void)
2343 {
2344 UpdateCheckbox("update_decsdm",
2345 vtMenuEntries,
2346 vtMenu_sixelscrolling,
2347 (term->keyboard.flags & MODE_DECSDM) != 0);
2348 }
2349
2350 void
HandleSixelScrolling(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2351 HandleSixelScrolling(Widget w,
2352 XEvent *event GCC_UNUSED,
2353 String *params,
2354 Cardinal *param_count)
2355 {
2356 handle_vt_toggle(do_sixelscrolling, term->keyboard.flags & MODE_DECSDM,
2357 params, *param_count, w);
2358 }
2359 #endif
2360
2361 #if OPT_GRAPHICS
2362 static void
do_privatecolorregisters(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)2363 do_privatecolorregisters(Widget gw GCC_UNUSED,
2364 XtPointer closure GCC_UNUSED,
2365 XtPointer data GCC_UNUSED)
2366 {
2367 TScreen *screen = TScreenOf(term);
2368
2369 ToggleFlag(screen->privatecolorregisters);
2370 update_privatecolorregisters();
2371 }
2372
2373 void
update_privatecolorregisters(void)2374 update_privatecolorregisters(void)
2375 {
2376 UpdateCheckbox("update_privatecolorregisters",
2377 vtMenuEntries,
2378 vtMenu_privatecolorregisters,
2379 TScreenOf(term)->privatecolorregisters);
2380 }
2381
2382 void
HandleSetPrivateColorRegisters(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2383 HandleSetPrivateColorRegisters(Widget w,
2384 XEvent *event GCC_UNUSED,
2385 String *params,
2386 Cardinal *param_count)
2387 {
2388 HANDLE_VT_TOGGLE(privatecolorregisters);
2389 }
2390 #endif
2391
2392 #if OPT_SUN_FUNC_KEYS
2393 void
HandleSunFunctionKeys(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2394 HandleSunFunctionKeys(Widget w,
2395 XEvent *event GCC_UNUSED,
2396 String *params,
2397 Cardinal *param_count)
2398 {
2399 handle_vt_toggle(do_sun_fkeys, term->keyboard.type == keyboardIsSun,
2400 params, *param_count, w);
2401 }
2402 #endif
2403
2404 #if OPT_NUM_LOCK
2405 void
HandleNumLock(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2406 HandleNumLock(Widget w,
2407 XEvent *event GCC_UNUSED,
2408 String *params,
2409 Cardinal *param_count)
2410 {
2411 handle_vt_toggle(do_num_lock, term->misc.real_NumLock,
2412 params, *param_count, w);
2413 }
2414
2415 void
HandleAltEsc(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2416 HandleAltEsc(Widget w,
2417 XEvent *event GCC_UNUSED,
2418 String *params,
2419 Cardinal *param_count)
2420 {
2421 handle_vt_toggle(do_alt_esc, !TScreenOf(term)->alt_sends_esc,
2422 params, *param_count, w);
2423 }
2424
2425 void
HandleMetaEsc(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2426 HandleMetaEsc(Widget w,
2427 XEvent *event GCC_UNUSED,
2428 String *params,
2429 Cardinal *param_count)
2430 {
2431 handle_vt_toggle(do_meta_esc, TScreenOf(term)->meta_sends_esc,
2432 params, *param_count, w);
2433 }
2434 #endif
2435
2436 void
HandleDeleteIsDEL(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2437 HandleDeleteIsDEL(Widget w,
2438 XEvent *event GCC_UNUSED,
2439 String *params,
2440 Cardinal *param_count)
2441 {
2442 handle_vt_toggle(do_delete_del, TScreenOf(term)->delete_is_del,
2443 params, *param_count, w);
2444 }
2445
2446 void
HandleOldFunctionKeys(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2447 HandleOldFunctionKeys(Widget w,
2448 XEvent *event GCC_UNUSED,
2449 String *params,
2450 Cardinal *param_count)
2451 {
2452 handle_vt_toggle(do_old_fkeys, term->keyboard.type == keyboardIsLegacy,
2453 params, *param_count, w);
2454 }
2455
2456 #if OPT_SUNPC_KBD
2457 void
HandleSunKeyboard(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2458 HandleSunKeyboard(Widget w,
2459 XEvent *event GCC_UNUSED,
2460 String *params,
2461 Cardinal *param_count)
2462 {
2463 handle_vt_toggle(do_sun_kbd, term->keyboard.type == keyboardIsVT220,
2464 params, *param_count, w);
2465 }
2466 #endif
2467
2468 #if OPT_HP_FUNC_KEYS
2469 void
HandleHpFunctionKeys(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2470 HandleHpFunctionKeys(Widget w,
2471 XEvent *event GCC_UNUSED,
2472 String *params,
2473 Cardinal *param_count)
2474 {
2475 handle_vt_toggle(do_hp_fkeys, term->keyboard.type == keyboardIsHP,
2476 params, *param_count, w);
2477 }
2478 #endif
2479
2480 #if OPT_SCO_FUNC_KEYS
2481 void
HandleScoFunctionKeys(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2482 HandleScoFunctionKeys(Widget w,
2483 XEvent *event GCC_UNUSED,
2484 String *params,
2485 Cardinal *param_count)
2486 {
2487 handle_vt_toggle(do_sco_fkeys, term->keyboard.type == keyboardIsSCO,
2488 params, *param_count, w);
2489 }
2490 #endif
2491
2492 void
HandleScrollbar(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2493 HandleScrollbar(Widget w,
2494 XEvent *event GCC_UNUSED,
2495 String *params,
2496 Cardinal *param_count)
2497 {
2498 XtermWidget xw = term;
2499
2500 if (IsIcon(TScreenOf(xw))) {
2501 Bell(xw, XkbBI_MinorError, 0);
2502 } else {
2503 handle_vt_toggle(do_scrollbar, TScreenOf(xw)->fullVwin.sb_info.width,
2504 params, *param_count, w);
2505 }
2506 }
2507
2508 void
HandleJumpscroll(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2509 HandleJumpscroll(Widget w,
2510 XEvent *event GCC_UNUSED,
2511 String *params,
2512 Cardinal *param_count)
2513 {
2514 HANDLE_VT_TOGGLE(jumpscroll);
2515 }
2516
2517 void
HandleKeepClipboard(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2518 HandleKeepClipboard(Widget w,
2519 XEvent *event GCC_UNUSED,
2520 String *params,
2521 Cardinal *param_count)
2522 {
2523 HANDLE_VT_TOGGLE(keepClipboard);
2524 }
2525
2526 void
HandleKeepSelection(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2527 HandleKeepSelection(Widget w,
2528 XEvent *event GCC_UNUSED,
2529 String *params,
2530 Cardinal *param_count)
2531 {
2532 HANDLE_VT_TOGGLE(keepSelection);
2533 }
2534
2535 void
HandleSetSelect(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2536 HandleSetSelect(Widget w,
2537 XEvent *event GCC_UNUSED,
2538 String *params,
2539 Cardinal *param_count)
2540 {
2541 handle_vt_toggle(do_selectClipboard, TScreenOf(term)->selectToClipboard,
2542 params, *param_count, w);
2543 }
2544
2545 void
HandleReverseVideo(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2546 HandleReverseVideo(Widget w,
2547 XEvent *event GCC_UNUSED,
2548 String *params,
2549 Cardinal *param_count)
2550 {
2551 handle_vt_toggle(do_reversevideo, (term->misc.re_verse0),
2552 params, *param_count, w);
2553 }
2554
2555 void
HandleAutoWrap(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2556 HandleAutoWrap(Widget w,
2557 XEvent *event GCC_UNUSED,
2558 String *params,
2559 Cardinal *param_count)
2560 {
2561 handle_vt_toggle(do_autowrap, (term->flags & WRAPAROUND),
2562 params, *param_count, w);
2563 }
2564
2565 void
HandleReverseWrap(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2566 HandleReverseWrap(Widget w,
2567 XEvent *event GCC_UNUSED,
2568 String *params,
2569 Cardinal *param_count)
2570 {
2571 handle_vt_toggle(do_reversewrap, (term->flags & REVERSEWRAP),
2572 params, *param_count, w);
2573 }
2574
2575 void
HandleAutoLineFeed(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2576 HandleAutoLineFeed(Widget w,
2577 XEvent *event GCC_UNUSED,
2578 String *params,
2579 Cardinal *param_count)
2580 {
2581 handle_vt_toggle(do_autolinefeed, (term->flags & LINEFEED),
2582 params, *param_count, w);
2583 }
2584
2585 void
HandleAppCursor(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2586 HandleAppCursor(Widget w,
2587 XEvent *event GCC_UNUSED,
2588 String *params,
2589 Cardinal *param_count)
2590 {
2591 handle_vt_toggle(do_appcursor, (term->keyboard.flags & MODE_DECCKM),
2592 params, *param_count, w);
2593 }
2594
2595 void
HandleAppKeypad(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2596 HandleAppKeypad(Widget w,
2597 XEvent *event GCC_UNUSED,
2598 String *params,
2599 Cardinal *param_count)
2600 {
2601 handle_vt_toggle(do_appkeypad, (term->keyboard.flags & MODE_DECKPAM),
2602 params, *param_count, w);
2603 }
2604
2605 void
HandleScrollKey(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2606 HandleScrollKey(Widget w,
2607 XEvent *event GCC_UNUSED,
2608 String *params,
2609 Cardinal *param_count)
2610 {
2611 HANDLE_VT_TOGGLE(scrollkey);
2612 }
2613
2614 void
HandleScrollTtyOutput(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2615 HandleScrollTtyOutput(Widget w,
2616 XEvent *event GCC_UNUSED,
2617 String *params,
2618 Cardinal *param_count)
2619 {
2620 HANDLE_VT_TOGGLE(scrollttyoutput);
2621 }
2622
2623 void
HandleAllow132(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2624 HandleAllow132(Widget w,
2625 XEvent *event GCC_UNUSED,
2626 String *params,
2627 Cardinal *param_count)
2628 {
2629 handle_vt_toggle(do_allow132, TScreenOf(term)->c132,
2630 params, *param_count, w);
2631 }
2632
2633 void
HandleCursesEmul(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2634 HandleCursesEmul(Widget w,
2635 XEvent *event GCC_UNUSED,
2636 String *params,
2637 Cardinal *param_count)
2638 {
2639 handle_vt_toggle(do_cursesemul, TScreenOf(term)->curses,
2640 params, *param_count, w);
2641 }
2642
2643 void
HandleBellIsUrgent(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2644 HandleBellIsUrgent(Widget w,
2645 XEvent *event GCC_UNUSED,
2646 String *params,
2647 Cardinal *param_count)
2648 {
2649 HANDLE_VT_TOGGLE(bellIsUrgent);
2650 }
2651
2652 void
HandleMarginBell(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2653 HandleMarginBell(Widget w,
2654 XEvent *event GCC_UNUSED,
2655 String *params,
2656 Cardinal *param_count)
2657 {
2658 HANDLE_VT_TOGGLE(marginbell);
2659 }
2660
2661 #if OPT_BLINK_CURS
2662 void
HandleCursorBlink(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2663 HandleCursorBlink(Widget w,
2664 XEvent *event GCC_UNUSED,
2665 String *params,
2666 Cardinal *param_count)
2667 {
2668 handle_vt_toggle(do_cursorblink, TScreenOf(term)->cursor_blink,
2669 params, *param_count, w);
2670 }
2671 #endif
2672
2673 void
HandleAltScreen(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2674 HandleAltScreen(Widget w,
2675 XEvent *event GCC_UNUSED,
2676 String *params,
2677 Cardinal *param_count)
2678 {
2679 /* eventually want to see if sensitive or not */
2680 handle_vt_toggle(do_altscreen, TScreenOf(term)->whichBuf,
2681 params, *param_count, w);
2682 }
2683
2684 void
HandleTiteInhibit(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2685 HandleTiteInhibit(Widget w,
2686 XEvent *event GCC_UNUSED,
2687 String *params,
2688 Cardinal *param_count)
2689 {
2690 /* eventually want to see if sensitive or not */
2691 handle_vt_toggle(do_titeInhibit, !(term->misc.titeInhibit),
2692 params, *param_count, w);
2693 }
2694
2695 /* ARGSUSED */
2696 void
HandleSoftReset(Widget w,XEvent * event GCC_UNUSED,String * params GCC_UNUSED,Cardinal * param_count GCC_UNUSED)2697 HandleSoftReset(Widget w,
2698 XEvent *event GCC_UNUSED,
2699 String *params GCC_UNUSED,
2700 Cardinal *param_count GCC_UNUSED)
2701 {
2702 do_softreset(w, (XtPointer) 0, (XtPointer) 0);
2703 }
2704
2705 /* ARGSUSED */
2706 void
HandleHardReset(Widget w,XEvent * event GCC_UNUSED,String * params GCC_UNUSED,Cardinal * param_count GCC_UNUSED)2707 HandleHardReset(Widget w,
2708 XEvent *event GCC_UNUSED,
2709 String *params GCC_UNUSED,
2710 Cardinal *param_count GCC_UNUSED)
2711 {
2712 do_hardreset(w, (XtPointer) 0, (XtPointer) 0);
2713 }
2714
2715 /* ARGSUSED */
2716 void
HandleClearSavedLines(Widget w,XEvent * event GCC_UNUSED,String * params GCC_UNUSED,Cardinal * param_count GCC_UNUSED)2717 HandleClearSavedLines(Widget w,
2718 XEvent *event GCC_UNUSED,
2719 String *params GCC_UNUSED,
2720 Cardinal *param_count GCC_UNUSED)
2721 {
2722 do_clearsavedlines(w, (XtPointer) 0, (XtPointer) 0);
2723 }
2724
2725 void
HandleAllowBoldFonts(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2726 HandleAllowBoldFonts(Widget w,
2727 XEvent *event GCC_UNUSED,
2728 String *params,
2729 Cardinal *param_count)
2730 {
2731 HANDLE_VT_TOGGLE(allowBoldFonts);
2732 }
2733
2734 #if OPT_LOAD_VTFONTS
2735 void
update_font_escape(void)2736 update_font_escape(void)
2737 {
2738 TScreen *screen = TScreenOf(term);
2739
2740 SetItemSensitivity(fontMenuEntries[fontMenu_fontescape].widget,
2741 ((screen->allowFontOps &&
2742 screen->EscapeFontName())
2743 ? True : False));
2744 }
2745 #endif
2746
2747 #if OPT_DEC_CHRSET
2748 void
HandleFontDoublesize(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2749 HandleFontDoublesize(Widget w,
2750 XEvent *event GCC_UNUSED,
2751 String *params,
2752 Cardinal *param_count)
2753 {
2754 HANDLE_VT_TOGGLE(font_doublesize);
2755 }
2756 #endif
2757
2758 #if OPT_BOX_CHARS
2759 void
HandleFontBoxChars(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2760 HandleFontBoxChars(Widget w,
2761 XEvent *event GCC_UNUSED,
2762 String *params,
2763 Cardinal *param_count)
2764 {
2765 handle_vt_toggle(do_font_boxchars, TScreenOf(term)->force_box_chars,
2766 params, *param_count, w);
2767 }
2768
2769 void
HandleFontPacked(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2770 HandleFontPacked(Widget w,
2771 XEvent *event GCC_UNUSED,
2772 String *params,
2773 Cardinal *param_count)
2774 {
2775 handle_vt_toggle(do_font_packed, TScreenOf(term)->force_packed,
2776 params, *param_count, w);
2777 }
2778 #endif
2779
2780 #if OPT_DEC_SOFTFONT
2781 void
HandleFontLoading(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2782 HandleFontLoading(Widget w,
2783 XEvent *event GCC_UNUSED,
2784 String *params,
2785 Cardinal *param_count)
2786 {
2787 handle_vt_toggle(do_font_loadable, term->misc.font_loadable,
2788 params, *param_count, w);
2789 }
2790 #endif
2791
2792 #if OPT_RENDERFONT
2793 static void
update_fontmenu(XtermWidget xw)2794 update_fontmenu(XtermWidget xw)
2795 {
2796 TScreen *screen = TScreenOf(xw);
2797 int n;
2798
2799 for (n = 0; n <= fontMenu_lastBuiltin; ++n) {
2800 Boolean active = (Boolean) (xw->work.render_font ||
2801 (screen->menu_font_sizes[n] >= 0));
2802 SetItemSensitivity(fontMenuEntries[n].widget, active);
2803 }
2804 }
2805
2806 void
HandleRenderFont(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2807 HandleRenderFont(Widget w,
2808 XEvent *event GCC_UNUSED,
2809 String *params,
2810 Cardinal *param_count)
2811 {
2812 XtermWidget xw = (XtermWidget) term;
2813
2814 DefaultRenderFont(xw);
2815
2816 handle_vt_toggle(do_font_renderfont, xw->work.render_font,
2817 params, *param_count, w);
2818
2819 update_fontmenu(xw);
2820 }
2821 #endif
2822
2823 #if OPT_WIDE_CHARS
2824 void
HandleUTF8Mode(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2825 HandleUTF8Mode(Widget w,
2826 XEvent *event GCC_UNUSED,
2827 String *params,
2828 Cardinal *param_count)
2829 {
2830 handle_vt_toggle(do_font_utf8_mode, TScreenOf(term)->utf8_mode,
2831 params, *param_count, w);
2832 }
2833
2834 void
HandleUTF8Fonts(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2835 HandleUTF8Fonts(Widget w,
2836 XEvent *event GCC_UNUSED,
2837 String *params,
2838 Cardinal *param_count)
2839 {
2840 handle_vt_toggle(do_font_utf8_fonts, TScreenOf(term)->utf8_fonts,
2841 params, *param_count, w);
2842 }
2843
2844 void
HandleUTF8Title(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2845 HandleUTF8Title(Widget w,
2846 XEvent *event GCC_UNUSED,
2847 String *params,
2848 Cardinal *param_count)
2849 {
2850 handle_vt_toggle(do_font_utf8_title, TScreenOf(term)->utf8_title,
2851 params, *param_count, w);
2852 }
2853 #endif
2854
2855 #if OPT_SCREEN_DUMPS
2856 void
HandleDumpHtml(Widget w GCC_UNUSED,XEvent * event GCC_UNUSED,String * params GCC_UNUSED,Cardinal * param_count GCC_UNUSED)2857 HandleDumpHtml(Widget w GCC_UNUSED,
2858 XEvent *event GCC_UNUSED,
2859 String *params GCC_UNUSED,
2860 Cardinal *param_count GCC_UNUSED)
2861 {
2862 xtermDumpHtml(term);
2863 }
2864
2865 void
HandleDumpSvg(Widget w GCC_UNUSED,XEvent * event GCC_UNUSED,String * params GCC_UNUSED,Cardinal * param_count GCC_UNUSED)2866 HandleDumpSvg(Widget w GCC_UNUSED,
2867 XEvent *event GCC_UNUSED,
2868 String *params GCC_UNUSED,
2869 Cardinal *param_count GCC_UNUSED)
2870 {
2871 xtermDumpSvg(term);
2872 }
2873 #endif
2874
2875 #if OPT_TEK4014
2876 void
HandleSetTerminalType(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2877 HandleSetTerminalType(Widget w,
2878 XEvent *event GCC_UNUSED,
2879 String *params,
2880 Cardinal *param_count)
2881 {
2882 XtermWidget xw = term;
2883
2884 if (*param_count == 1) {
2885 switch (params[0][0]) {
2886 case 'v':
2887 case 'V':
2888 if (TEK4014_ACTIVE(xw))
2889 do_vtmode(w, (XtPointer) 0, (XtPointer) 0);
2890 break;
2891 case 't':
2892 case 'T':
2893 if (!TEK4014_ACTIVE(xw))
2894 do_tekmode(w, (XtPointer) 0, (XtPointer) 0);
2895 break;
2896 default:
2897 Bell(xw, XkbBI_MinorError, 0);
2898 }
2899 } else {
2900 Bell(xw, XkbBI_MinorError, 0);
2901 }
2902 }
2903
2904 void
HandleVisibility(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2905 HandleVisibility(Widget w,
2906 XEvent *event GCC_UNUSED,
2907 String *params,
2908 Cardinal *param_count)
2909 {
2910 XtermWidget xw = term;
2911
2912 if (*param_count == 2) {
2913 switch (params[0][0]) {
2914 case 'v':
2915 case 'V':
2916 handle_tek_toggle(do_vtonoff, (int) TScreenOf(xw)->Vshow,
2917 params + 1, (*param_count) - 1, w);
2918 break;
2919 case 't':
2920 case 'T':
2921 handle_tek_toggle(do_tekonoff, (int) TEK4014_SHOWN(xw),
2922 params + 1, (*param_count) - 1, w);
2923 break;
2924 default:
2925 Bell(xw, XkbBI_MinorError, 0);
2926 }
2927 } else {
2928 Bell(xw, XkbBI_MinorError, 0);
2929 }
2930 }
2931
2932 /* ARGSUSED */
2933 void
HandleSetTekText(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)2934 HandleSetTekText(Widget w,
2935 XEvent *event GCC_UNUSED,
2936 String *params,
2937 Cardinal *param_count)
2938 {
2939 XtermWidget xw = term;
2940 void (*proc) PROTO_XT_CALLBACK_ARGS = 0;
2941
2942 switch (*param_count) {
2943 case 0:
2944 proc = do_tektextlarge;
2945 break;
2946 case 1:
2947 switch (TekGetFontSize(params[0])) {
2948 case TEK_FONT_LARGE:
2949 proc = do_tektextlarge;
2950 break;
2951 case TEK_FONT_2:
2952 proc = do_tektext2;
2953 break;
2954 case TEK_FONT_3:
2955 proc = do_tektext3;
2956 break;
2957 case TEK_FONT_SMALL:
2958 proc = do_tektextsmall;
2959 break;
2960 }
2961 break;
2962 }
2963 if (proc)
2964 (*proc) (w, (XtPointer) 0, (XtPointer) 0);
2965 else
2966 Bell(xw, XkbBI_MinorError, 0);
2967 }
2968
2969 /* ARGSUSED */
2970 void
HandleTekPage(Widget w,XEvent * event GCC_UNUSED,String * params GCC_UNUSED,Cardinal * param_count GCC_UNUSED)2971 HandleTekPage(Widget w,
2972 XEvent *event GCC_UNUSED,
2973 String *params GCC_UNUSED,
2974 Cardinal *param_count GCC_UNUSED)
2975 {
2976 do_tekpage(w, (XtPointer) 0, (XtPointer) 0);
2977 }
2978
2979 /* ARGSUSED */
2980 void
HandleTekReset(Widget w,XEvent * event GCC_UNUSED,String * params GCC_UNUSED,Cardinal * param_count GCC_UNUSED)2981 HandleTekReset(Widget w,
2982 XEvent *event GCC_UNUSED,
2983 String *params GCC_UNUSED,
2984 Cardinal *param_count GCC_UNUSED)
2985 {
2986 do_tekreset(w, (XtPointer) 0, (XtPointer) 0);
2987 }
2988
2989 /* ARGSUSED */
2990 void
HandleTekCopy(Widget w,XEvent * event GCC_UNUSED,String * params GCC_UNUSED,Cardinal * param_count GCC_UNUSED)2991 HandleTekCopy(Widget w,
2992 XEvent *event GCC_UNUSED,
2993 String *params GCC_UNUSED,
2994 Cardinal *param_count GCC_UNUSED)
2995 {
2996 do_tekcopy(w, (XtPointer) 0, (XtPointer) 0);
2997 }
2998 #endif /* OPT_TEK4014 */
2999
3000 #if OPT_TOOLBAR
3001 /*
3002 * The normal style of xterm popup menu delays initialization until the menu is
3003 * first requested. When using a toolbar, we can use the same initialization,
3004 * though on the first popup there will be a little geometry layout jitter,
3005 * since the menu is already managed when this callback is invoked.
3006 */
3007 static void
InitPopup(Widget gw,XtPointer closure,XtPointer data GCC_UNUSED)3008 InitPopup(Widget gw,
3009 XtPointer closure,
3010 XtPointer data GCC_UNUSED)
3011 {
3012 String params[2];
3013 Cardinal count = 1;
3014
3015 params[0] = (char *) closure;
3016 params[1] = 0;
3017 TRACE(("InitPopup(%s)\n", params[0]));
3018
3019 domenu(gw, (XEvent *) 0, params, &count);
3020
3021 XtRemoveCallback(gw, XtNpopupCallback, InitPopup, closure);
3022 }
3023
3024 static Dimension
SetupShell(Widget * menus,MenuList * shell,int n,int m)3025 SetupShell(Widget *menus, MenuList * shell, int n, int m)
3026 {
3027 char temp[80];
3028 char *external_name = 0;
3029 Dimension button_height;
3030 Dimension button_border;
3031 char *saveLocale = xtermSetLocale(LC_CTYPE, resource.menuLocale);
3032
3033 shell[n].w = XtVaCreatePopupShell(menu_names[n].internal_name,
3034 simpleMenuWidgetClass,
3035 *menus,
3036 XtNgeometry, NULL,
3037 (XtPointer) 0);
3038 TRACE(("created popupShel widget %p, window %#lx\n",
3039 (void *) shell[n].w, XtWindow(shell[n].w)));
3040
3041 XtAddCallback(shell[n].w, XtNpopupCallback, InitPopup, menu_names[n].internal_name);
3042 XtVaGetValues(shell[n].w,
3043 XtNlabel, &external_name,
3044 (XtPointer) 0);
3045
3046 TRACE(("...SetupShell(%s) -> %s -> %#lx\n",
3047 menu_names[n].internal_name,
3048 external_name,
3049 (long) shell[n].w));
3050
3051 sprintf(temp, "%sButton", menu_names[n].internal_name);
3052 shell[n].b = XtVaCreateManagedWidget(temp,
3053 menuButtonWidgetClass,
3054 *menus,
3055 XtNfromHoriz, ((m >= 0)
3056 ? shell[m].b
3057 : 0),
3058 XtNmenuName, menu_names[n].internal_name,
3059 XtNlabel, external_name,
3060 (XtPointer) 0);
3061 TRACE(("created menuButton[%d] widget %p, window %#lx\n",
3062 n, (void *) shell[n].b, XtWindow(shell[n].b)));
3063 XtVaGetValues(shell[n].b,
3064 XtNheight, &button_height,
3065 XtNborderWidth, &button_border,
3066 (XtPointer) 0);
3067
3068 xtermResetLocale(LC_CTYPE, saveLocale);
3069 return (Dimension) (button_height + (button_border * 2));
3070 }
3071 #endif /* OPT_TOOLBAR */
3072
3073 void
SetupMenus(Widget shell,Widget * forms,Widget * menus,Dimension * menu_high)3074 SetupMenus(Widget shell, Widget *forms, Widget *menus, Dimension *menu_high)
3075 {
3076 #if OPT_TOOLBAR
3077 Dimension button_height = 0;
3078 Dimension toolbar_hSpace;
3079 Arg args[10];
3080 #endif
3081
3082 TRACE(("SetupMenus(%s)\n", shell == toplevel ? "vt100" : "tek4014"));
3083
3084 *menu_high = 0;
3085
3086 if (shell == toplevel) {
3087 XawSimpleMenuAddGlobalActions(app_con);
3088 XtRegisterGrabAction(HandlePopupMenu, True,
3089 (unsigned) (ButtonPressMask | ButtonReleaseMask),
3090 GrabModeAsync, GrabModeAsync);
3091 }
3092 #if OPT_TOOLBAR
3093 *forms = XtVaCreateManagedWidget("form",
3094 formWidgetClass, shell,
3095 (XtPointer) 0);
3096 TRACE(("created form widget %p, window %#lx\n",
3097 (void *) *forms, XtWindow(*forms)));
3098 xtermAddInput(*forms);
3099
3100 /*
3101 * Set a nominal value for the preferred pane size, which lets the
3102 * buttons determine the actual height of the menu bar. We don't show
3103 * the grip, because it's too easy to make the toolbar look bad that
3104 * way.
3105 */
3106 XtSetArg(args[0], XtNorientation, XtorientHorizontal);
3107 XtSetArg(args[1], XtNtop, XawChainTop);
3108 XtSetArg(args[2], XtNbottom, XawChainTop);
3109 XtSetArg(args[3], XtNleft, XawChainLeft);
3110 XtSetArg(args[4], XtNright, XawChainLeft);
3111
3112 if (resource.toolBar) {
3113 *menus = XtCreateManagedWidget("menubar", boxWidgetClass, *forms,
3114 args, 5);
3115 } else {
3116 *menus = XtCreateWidget("menubar", boxWidgetClass, *forms, args, 5);
3117 }
3118 TRACE(("created menubar widget %p, window %#lx\n",
3119 (void *) *menus, XtWindow(*menus)));
3120
3121 /*
3122 * The toolbar widget's height is not necessarily known yet. If the
3123 * toolbar is not created as a managed widget, we can still make a good
3124 * guess about its height by collecting the widget's other resource values.
3125 */
3126 XtVaGetValues(*menus,
3127 XtNhSpace, &toolbar_hSpace,
3128 (XtPointer) 0);
3129
3130 if (shell == toplevel) { /* vt100 */
3131 int j;
3132 for (j = mainMenu; j <= fontMenu; j++) {
3133 button_height = SetupShell(menus, vt_shell, j, j - 1);
3134 }
3135 }
3136 #if OPT_TEK4014
3137 else { /* tek4014 */
3138 (void) SetupShell(menus, tek_shell, mainMenu, -1);
3139 button_height = SetupShell(menus, tek_shell, tekMenu, mainMenu);
3140 }
3141 #endif
3142
3143 /*
3144 * Tell the main program how high the toolbar is, to help with the initial
3145 * layout.
3146 */
3147 *menu_high = (Dimension) (button_height + 2 * (toolbar_hSpace));
3148 TRACE(("...menuHeight:%d = (%d + 2 * %d)\n",
3149 *menu_high, button_height, toolbar_hSpace));
3150
3151 #else /* !OPT_TOOLBAR */
3152 *forms = shell;
3153 *menus = shell;
3154 #endif
3155
3156 TRACE(("...shell=%#lx\n", (long) shell));
3157 TRACE(("...forms=%#lx\n", (long) *forms));
3158 TRACE(("...menus=%#lx\n", (long) *menus));
3159 }
3160
3161 void
repairSizeHints(void)3162 repairSizeHints(void)
3163 {
3164 XtermWidget xw = term;
3165 TScreen *screen = TScreenOf(xw);
3166
3167 if (XtIsRealized((Widget) xw)) {
3168 getXtermSizeHints(xw);
3169 xtermSizeHints(xw, ScrollbarWidth(screen));
3170
3171 XSetWMNormalHints(screen->display, VShellWindow(xw), &xw->hints);
3172 }
3173 }
3174
3175 #if OPT_TOOLBAR
3176 #define INIT_POPUP(s, n) InitPopup(s[n].w, menu_names[n].internal_name, 0)
3177
3178 static Bool
InitWidgetMenu(Widget shell)3179 InitWidgetMenu(Widget shell)
3180 {
3181 Bool result = False;
3182
3183 TRACE(("InitWidgetMenu(%p)\n", (void *) shell));
3184 if (term != 0) {
3185 if (shell == toplevel) { /* vt100 */
3186 if (!term->init_menu) {
3187 INIT_POPUP(vt_shell, mainMenu);
3188 INIT_POPUP(vt_shell, vtMenu);
3189 INIT_POPUP(vt_shell, fontMenu);
3190 term->init_menu = True;
3191 TRACE(("...InitWidgetMenu(vt)\n"));
3192 }
3193 result = term->init_menu;
3194 }
3195 #if OPT_TEK4014
3196 else if (tekWidget) { /* tek4014 */
3197 if (!tekWidget->init_menu) {
3198 INIT_POPUP(tek_shell, mainMenu);
3199 INIT_POPUP(tek_shell, tekMenu);
3200 tekWidget->init_menu = True;
3201 TRACE(("...InitWidgetMenu(tek)\n"));
3202 }
3203 result = tekWidget->init_menu;
3204 }
3205 #endif
3206 }
3207 TRACE(("...InitWidgetMenu ->%d\n", result));
3208 return result;
3209 }
3210
3211 static TbInfo *
toolbar_info(Widget w)3212 toolbar_info(Widget w)
3213 {
3214 TRACE(("...getting toolbar_info\n"));
3215 #if OPT_TEK4014
3216 if (w != (Widget) term)
3217 return &(tekWidget->tek.tb_info);
3218 #else
3219 (void) w;
3220 #endif
3221 return &(WhichVWin(TScreenOf(term))->tb_info);
3222 }
3223
3224 static void
hide_toolbar(Widget w)3225 hide_toolbar(Widget w)
3226 {
3227 if (w != 0) {
3228 TbInfo *info = toolbar_info(w);
3229
3230 TRACE(("hiding toolbar\n"));
3231 XtVaSetValues(w,
3232 XtNfromVert, (Widget) 0,
3233 (XtPointer) 0);
3234
3235 if (info->menu_bar != 0) {
3236 repairSizeHints();
3237 XtUnmanageChild(info->menu_bar);
3238 if (XtIsRealized(info->menu_bar)) {
3239 XtUnmapWidget(info->menu_bar);
3240 }
3241 }
3242 TRACE(("...hiding toolbar (done)\n"));
3243 }
3244 }
3245
3246 static void
show_toolbar(Widget w)3247 show_toolbar(Widget w)
3248 {
3249 if (w != 0) {
3250 TbInfo *info = toolbar_info(w);
3251
3252 TRACE(("showing toolbar\n"));
3253 if (info->menu_bar != 0) {
3254 XtVaSetValues(w,
3255 XtNfromVert, info->menu_bar,
3256 (XtPointer) 0);
3257 if (XtIsRealized(info->menu_bar))
3258 repairSizeHints();
3259 XtManageChild(info->menu_bar);
3260 if (XtIsRealized(info->menu_bar)) {
3261 XtMapWidget(info->menu_bar);
3262 }
3263 }
3264 /*
3265 * This is needed to make the terminal widget move down below the
3266 * toolbar.
3267 */
3268 XawFormDoLayout(XtParent(w), True);
3269 TRACE(("...showing toolbar (done)\n"));
3270 }
3271 }
3272
3273 /*
3274 * Make the toolbar visible or invisible in the current window(s).
3275 */
3276 void
ShowToolbar(Bool enable)3277 ShowToolbar(Bool enable)
3278 {
3279 XtermWidget xw = term;
3280
3281 TRACE(("ShowToolbar(%d)\n", enable));
3282
3283 if (IsIcon(TScreenOf(xw))) {
3284 Bell(xw, XkbBI_MinorError, 0);
3285 } else {
3286 if (enable) {
3287 if (InitWidgetMenu(toplevel))
3288 show_toolbar((Widget) xw);
3289 #if OPT_TEK4014
3290 if (InitWidgetMenu(tekshellwidget))
3291 show_toolbar((Widget) tekWidget);
3292 #endif
3293 } else {
3294 hide_toolbar((Widget) xw);
3295 #if OPT_TEK4014
3296 hide_toolbar((Widget) tekWidget);
3297 #endif
3298 }
3299 resource.toolBar = (Boolean) enable;
3300 update_toolbar();
3301 }
3302 #if OPT_TOOLBAR
3303 /*
3304 * Layout for the toolbar confuses the Shell widget. Remind it that we
3305 * would like to be iconified if the corresponding resource was set.
3306 */
3307 {
3308 static Bool first = True;
3309 if (first && XtIsRealized(toplevel)) {
3310 Boolean iconic = 0;
3311
3312 XtVaGetValues(toplevel,
3313 XtNiconic, &iconic,
3314 (XtPointer) 0);
3315
3316 if (iconic) {
3317 TRACE(("...please iconify window %#lx\n", XtWindow(toplevel)));
3318 xtermIconify(xw);
3319 }
3320 first = False;
3321 }
3322 }
3323 #endif
3324 }
3325
3326 void
HandleToolbar(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)3327 HandleToolbar(Widget w,
3328 XEvent *event GCC_UNUSED,
3329 String *params,
3330 Cardinal *param_count)
3331 {
3332 XtermWidget xw = term;
3333
3334 if (IsIcon(TScreenOf(xw))) {
3335 Bell(xw, XkbBI_MinorError, 0);
3336 } else {
3337 handle_vt_toggle(do_toolbar, resource.toolBar,
3338 params, *param_count, w);
3339 }
3340 }
3341
3342 /* ARGSUSED */
3343 static void
do_toolbar(Widget gw GCC_UNUSED,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)3344 do_toolbar(Widget gw GCC_UNUSED,
3345 XtPointer closure GCC_UNUSED,
3346 XtPointer data GCC_UNUSED)
3347 {
3348 XtermWidget xw = term;
3349
3350 /*
3351 * Toggle toolbars for both vt100 and tek windows, since they share the
3352 * menu which contains the checkbox indicating whether the toolbar is
3353 * active.
3354 */
3355 if (IsIcon(TScreenOf(xw))) {
3356 Bell(xw, XkbBI_MinorError, 0);
3357 } else {
3358 ShowToolbar(ToggleFlag(resource.toolBar));
3359 }
3360 }
3361
3362 void
update_toolbar(void)3363 update_toolbar(void)
3364 {
3365 UpdateCheckbox("update_toolbar",
3366 mainMenuEntries,
3367 mainMenu_toolbar,
3368 resource.toolBar);
3369 }
3370 #endif /* OPT_TOOLBAR */
3371
3372 void
update_securekbd(void)3373 update_securekbd(void)
3374 {
3375 UpdateCheckbox("update_securekbd",
3376 mainMenuEntries,
3377 mainMenu_securekbd,
3378 TScreenOf(term)->grabbedKbd);
3379 }
3380
3381 void
update_allowsends(void)3382 update_allowsends(void)
3383 {
3384 UpdateCheckbox("update_allowsends",
3385 mainMenuEntries,
3386 mainMenu_allowsends,
3387 TScreenOf(term)->allowSendEvents);
3388 }
3389
3390 #ifdef ALLOWLOGGING
3391 void
update_logging(void)3392 update_logging(void)
3393 {
3394 UpdateCheckbox("update_logging",
3395 mainMenuEntries,
3396 mainMenu_logging,
3397 TScreenOf(term)->logging);
3398 }
3399 #endif
3400
3401 #if OPT_PRINT_ON_EXIT
3402 void
update_write_error(void)3403 update_write_error(void)
3404 {
3405 UpdateCheckbox("update_write_error",
3406 mainMenuEntries,
3407 mainMenu_write_error,
3408 TScreenOf(term)->write_error);
3409 }
3410 #endif
3411
3412 void
update_print_redir(void)3413 update_print_redir(void)
3414 {
3415 UpdateCheckbox("update_print_redir",
3416 mainMenuEntries,
3417 mainMenu_print_redir,
3418 PrinterOf(TScreenOf(term)).printer_controlmode);
3419 }
3420
3421 void
update_8bit_control(void)3422 update_8bit_control(void)
3423 {
3424 UpdateCheckbox("update_8bit_control",
3425 mainMenuEntries,
3426 mainMenu_8bit_ctrl,
3427 TScreenOf(term)->control_eight_bits);
3428 }
3429
3430 void
update_decbkm(void)3431 update_decbkm(void)
3432 {
3433 UpdateCheckbox("update_decbkm",
3434 mainMenuEntries,
3435 mainMenu_backarrow,
3436 (term->keyboard.flags & MODE_DECBKM) != 0);
3437 }
3438
3439 #if OPT_NUM_LOCK
3440 void
update_num_lock(void)3441 update_num_lock(void)
3442 {
3443 UpdateCheckbox("update_num_lock",
3444 mainMenuEntries,
3445 mainMenu_num_lock,
3446 term->misc.real_NumLock);
3447 }
3448
3449 void
update_alt_esc(void)3450 update_alt_esc(void)
3451 {
3452 UpdateCheckbox("update_alt_esc",
3453 mainMenuEntries,
3454 mainMenu_alt_esc,
3455 TScreenOf(term)->alt_sends_esc);
3456 }
3457
3458 void
update_meta_esc(void)3459 update_meta_esc(void)
3460 {
3461 UpdateCheckbox("update_meta_esc",
3462 mainMenuEntries,
3463 mainMenu_meta_esc,
3464 TScreenOf(term)->meta_sends_esc);
3465 }
3466 #endif
3467
3468 #if OPT_SUN_FUNC_KEYS
3469 void
update_sun_fkeys(void)3470 update_sun_fkeys(void)
3471 {
3472 UpdateCheckbox("update_sun_fkeys",
3473 mainMenuEntries,
3474 mainMenu_sun_fkeys,
3475 term->keyboard.type == keyboardIsSun);
3476 }
3477 #endif
3478
3479 #if OPT_TCAP_FKEYS
3480 void
update_tcap_fkeys(void)3481 update_tcap_fkeys(void)
3482 {
3483 UpdateCheckbox("update_tcap_fkeys",
3484 mainMenuEntries,
3485 mainMenu_tcap_fkeys,
3486 term->keyboard.type == keyboardIsTermcap);
3487 }
3488 #endif
3489
3490 void
update_old_fkeys(void)3491 update_old_fkeys(void)
3492 {
3493 UpdateCheckbox("update_old_fkeys",
3494 mainMenuEntries,
3495 mainMenu_old_fkeys,
3496 term->keyboard.type == keyboardIsLegacy);
3497 }
3498
3499 void
update_delete_del(void)3500 update_delete_del(void)
3501 {
3502 UpdateCheckbox("update_delete_del",
3503 mainMenuEntries,
3504 mainMenu_delete_del,
3505 xtermDeleteIsDEL(term));
3506 }
3507
3508 #if OPT_SUNPC_KBD
3509 void
update_sun_kbd(void)3510 update_sun_kbd(void)
3511 {
3512 UpdateCheckbox("update_sun_kbd",
3513 mainMenuEntries,
3514 mainMenu_sun_kbd,
3515 term->keyboard.type == keyboardIsVT220);
3516 }
3517 #endif
3518
3519 #if OPT_HP_FUNC_KEYS
3520 void
update_hp_fkeys(void)3521 update_hp_fkeys(void)
3522 {
3523 UpdateCheckbox("update_hp_fkeys",
3524 mainMenuEntries,
3525 mainMenu_hp_fkeys,
3526 term->keyboard.type == keyboardIsHP);
3527 }
3528 #endif
3529
3530 #if OPT_SCO_FUNC_KEYS
3531 void
update_sco_fkeys(void)3532 update_sco_fkeys(void)
3533 {
3534 UpdateCheckbox("update_sco_fkeys",
3535 mainMenuEntries,
3536 mainMenu_sco_fkeys,
3537 term->keyboard.type == keyboardIsSCO);
3538 }
3539 #endif
3540
3541 void
update_scrollbar(void)3542 update_scrollbar(void)
3543 {
3544 UpdateCheckbox("update_scrollbar",
3545 vtMenuEntries,
3546 vtMenu_scrollbar,
3547 ScrollbarWidth(TScreenOf(term)));
3548 }
3549
3550 void
update_jumpscroll(void)3551 update_jumpscroll(void)
3552 {
3553 UpdateCheckbox("update_jumpscroll",
3554 vtMenuEntries,
3555 vtMenu_jumpscroll,
3556 TScreenOf(term)->jumpscroll);
3557 }
3558
3559 void
update_reversevideo(void)3560 update_reversevideo(void)
3561 {
3562 UpdateCheckbox("update_reversevideo",
3563 vtMenuEntries,
3564 vtMenu_reversevideo,
3565 (term->misc.re_verse));
3566 }
3567
3568 void
update_autowrap(void)3569 update_autowrap(void)
3570 {
3571 DisableIfVT52(vtMenuEntries,
3572 vtMenu_autowrap);
3573 UpdateCheckbox("update_autowrap",
3574 vtMenuEntries,
3575 vtMenu_autowrap,
3576 (term->flags & WRAPAROUND) != 0);
3577 }
3578
3579 void
update_reversewrap(void)3580 update_reversewrap(void)
3581 {
3582 DisableIfVT52(vtMenuEntries,
3583 vtMenu_reversewrap);
3584 UpdateCheckbox("update_reversewrap",
3585 vtMenuEntries,
3586 vtMenu_reversewrap,
3587 (term->flags & REVERSEWRAP) != 0);
3588 }
3589
3590 void
update_autolinefeed(void)3591 update_autolinefeed(void)
3592 {
3593 DisableIfVT52(vtMenuEntries,
3594 vtMenu_autolinefeed);
3595 UpdateCheckbox("update_autolinefeed",
3596 vtMenuEntries,
3597 vtMenu_autolinefeed,
3598 (term->flags & LINEFEED) != 0);
3599 }
3600
3601 void
update_appcursor(void)3602 update_appcursor(void)
3603 {
3604 DisableIfVT52(vtMenuEntries,
3605 vtMenu_appcursor);
3606 UpdateCheckbox("update_appcursor",
3607 vtMenuEntries,
3608 vtMenu_appcursor,
3609 (term->keyboard.flags & MODE_DECCKM) != 0);
3610 }
3611
3612 void
update_appkeypad(void)3613 update_appkeypad(void)
3614 {
3615 UpdateCheckbox("update_appkeypad",
3616 vtMenuEntries,
3617 vtMenu_appkeypad,
3618 (term->keyboard.flags & MODE_DECKPAM) != 0);
3619 }
3620
3621 void
update_scrollkey(void)3622 update_scrollkey(void)
3623 {
3624 UpdateCheckbox("update_scrollkey",
3625 vtMenuEntries,
3626 vtMenu_scrollkey,
3627 TScreenOf(term)->scrollkey);
3628 }
3629
3630 void
update_scrollttyoutput(void)3631 update_scrollttyoutput(void)
3632 {
3633 UpdateCheckbox("update_scrollttyoutput",
3634 vtMenuEntries,
3635 vtMenu_scrollttyoutput,
3636 TScreenOf(term)->scrollttyoutput);
3637 }
3638
3639 void
update_keepSelection(void)3640 update_keepSelection(void)
3641 {
3642 UpdateCheckbox("update_keepSelection",
3643 vtMenuEntries,
3644 vtMenu_keepSelection,
3645 TScreenOf(term)->keepSelection);
3646 }
3647
3648 void
update_selectToClipboard(void)3649 update_selectToClipboard(void)
3650 {
3651 UpdateCheckbox("update_selectToClipboard",
3652 vtMenuEntries,
3653 vtMenu_selectToClipboard,
3654 TScreenOf(term)->selectToClipboard);
3655 }
3656
3657 void
update_allow132(void)3658 update_allow132(void)
3659 {
3660 DisableIfVT52(vtMenuEntries,
3661 vtMenu_allow132);
3662 UpdateCheckbox("update_allow132",
3663 vtMenuEntries,
3664 vtMenu_allow132,
3665 TScreenOf(term)->c132);
3666 }
3667
3668 void
update_cursesemul(void)3669 update_cursesemul(void)
3670 {
3671 #if 0 /* 2006-2-12: no longer menu entry */
3672 UpdateMenuItem("update_cursesemul", vtMenuEntries, vtMenu_cursesemul,
3673 TScreenOf(term)->curses);
3674 #endif
3675 }
3676
3677 void
update_visualbell(void)3678 update_visualbell(void)
3679 {
3680 UpdateCheckbox("update_visualbell",
3681 vtMenuEntries,
3682 vtMenu_visualbell,
3683 TScreenOf(term)->visualbell);
3684 }
3685
3686 void
update_bellIsUrgent(void)3687 update_bellIsUrgent(void)
3688 {
3689 UpdateCheckbox("update_bellIsUrgent",
3690 vtMenuEntries,
3691 vtMenu_bellIsUrgent,
3692 TScreenOf(term)->bellIsUrgent);
3693 }
3694
3695 void
update_poponbell(void)3696 update_poponbell(void)
3697 {
3698 UpdateCheckbox("update_poponbell",
3699 vtMenuEntries,
3700 vtMenu_poponbell,
3701 TScreenOf(term)->poponbell);
3702 }
3703
3704 #ifndef update_marginbell /* 2007-3-7: no longer menu entry */
3705 void
update_marginbell(void)3706 update_marginbell(void)
3707 {
3708 UpdateCheckbox("update_marginbell",
3709 vtMenuEntries,
3710 vtMenu_marginbell,
3711 TScreenOf(term)->marginbell);
3712 }
3713 #endif
3714
3715 #if OPT_BLINK_CURS
3716 void
update_cursorblink(void)3717 update_cursorblink(void)
3718 {
3719 BlinkOps check = TScreenOf(term)->cursor_blink;
3720
3721 if (check == cbAlways ||
3722 check == cbNever) {
3723 SetItemSensitivity(vtMenuEntries[vtMenu_cursorblink].widget, False);
3724 }
3725 UpdateCheckbox("update_cursorblink",
3726 vtMenuEntries,
3727 vtMenu_cursorblink,
3728 (check == cbTrue ||
3729 check == cbAlways));
3730 }
3731 #endif
3732
3733 void
update_altscreen(void)3734 update_altscreen(void)
3735 {
3736 UpdateCheckbox("update_altscreen",
3737 vtMenuEntries,
3738 vtMenu_altscreen,
3739 TScreenOf(term)->whichBuf);
3740 }
3741
3742 void
update_titeInhibit(void)3743 update_titeInhibit(void)
3744 {
3745 UpdateCheckbox("update_titeInhibit",
3746 vtMenuEntries,
3747 vtMenu_titeInhibit,
3748 !(term->misc.titeInhibit));
3749 }
3750
3751 #ifndef NO_ACTIVE_ICON
3752 void
update_activeicon(void)3753 update_activeicon(void)
3754 {
3755 UpdateCheckbox("update_activeicon",
3756 vtMenuEntries,
3757 vtMenu_activeicon,
3758 term->work.active_icon);
3759 }
3760 #endif /* NO_ACTIVE_ICON */
3761
3762 static void
do_allowBoldFonts(Widget w,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)3763 do_allowBoldFonts(Widget w,
3764 XtPointer closure GCC_UNUSED,
3765 XtPointer data GCC_UNUSED)
3766 {
3767 XtermWidget xw = getXtermWidget(w);
3768 if (xw != 0) {
3769 ToggleFlag(TScreenOf(xw)->allowBoldFonts);
3770 update_menu_allowBoldFonts();
3771 Redraw();
3772 }
3773 }
3774
3775 #if OPT_DEC_CHRSET
3776 void
update_font_doublesize(void)3777 update_font_doublesize(void)
3778 {
3779 UpdateCheckbox("update_font_doublesize",
3780 fontMenuEntries,
3781 fontMenu_font_doublesize,
3782 TScreenOf(term)->font_doublesize);
3783 }
3784 #endif
3785
3786 #if OPT_BOX_CHARS
3787 void
update_font_boxchars(void)3788 update_font_boxchars(void)
3789 {
3790 SetItemSensitivity(fontMenuEntries[fontMenu_font_boxchars].widget,
3791 !TScreenOf(term)->broken_box_chars);
3792 UpdateCheckbox("update_font_boxchars",
3793 fontMenuEntries,
3794 fontMenu_font_boxchars,
3795 TScreenOf(term)->force_box_chars ||
3796 TScreenOf(term)->broken_box_chars);
3797 }
3798
3799 void
update_font_packed(void)3800 update_font_packed(void)
3801 {
3802 UpdateCheckbox("update_font_packed",
3803 fontMenuEntries,
3804 fontMenu_font_packedfont,
3805 TScreenOf(term)->force_packed);
3806 }
3807 #endif
3808
3809 #if OPT_DEC_SOFTFONT
3810 void
update_font_loadable(void)3811 update_font_loadable(void)
3812 {
3813 UpdateCheckbox("update_font_loadable",
3814 fontMenuEntries,
3815 fontMenu_font_loadable,
3816 term->misc.font_loadable);
3817 }
3818 #endif
3819
3820 #if OPT_RENDERFONT
3821 void
update_font_renderfont(void)3822 update_font_renderfont(void)
3823 {
3824 UpdateCheckbox("update_font_renderfont",
3825 fontMenuEntries,
3826 fontMenu_render_font,
3827 (term->work.render_font == True));
3828 SetItemSensitivity(fontMenuEntries[fontMenu_render_font].widget,
3829 !IsEmpty(CurrentXftFont(term)));
3830
3831 #if OPT_BOX_CHARS
3832 if (term->work.render_font) {
3833 TScreenOf(term)->broken_box_chars = term->work.broken_box_chars;
3834 } else {
3835 TScreenOf(term)->broken_box_chars = False;
3836 }
3837 #endif
3838 update_font_boxchars();
3839
3840 update_fontmenu(term);
3841 }
3842 #endif
3843
3844 #if OPT_WIDE_CHARS
3845 void
update_font_utf8_mode(void)3846 update_font_utf8_mode(void)
3847 {
3848 Bool active = (TScreenOf(term)->utf8_mode != uAlways);
3849 Bool enable = (TScreenOf(term)->utf8_mode != uFalse);
3850
3851 TRACE(("update_font_utf8_mode active %d, enable %d\n", active, enable));
3852 SetItemSensitivity(fontMenuEntries[fontMenu_utf8_mode].widget, active);
3853 UpdateCheckbox("update_font_utf8_mode",
3854 fontMenuEntries,
3855 fontMenu_utf8_mode,
3856 enable);
3857 }
3858
3859 void
update_font_utf8_fonts(void)3860 update_font_utf8_fonts(void)
3861 {
3862 Bool active = (TScreenOf(term)->utf8_fonts != uAlways);
3863 Bool enable = (TScreenOf(term)->utf8_fonts != uFalse);
3864
3865 TRACE(("update_font_utf8_fonts active %d, enable %d\n", active, enable));
3866 SetItemSensitivity(fontMenuEntries[fontMenu_utf8_fonts].widget, active);
3867 UpdateCheckbox("update_font_utf8_fonts",
3868 fontMenuEntries,
3869 fontMenu_utf8_fonts,
3870 enable);
3871 }
3872
3873 void
update_font_utf8_title(void)3874 update_font_utf8_title(void)
3875 {
3876 Bool active = (TScreenOf(term)->utf8_mode != uAlways);
3877 Bool enable = (TScreenOf(term)->utf8_mode != uFalse);
3878
3879 TRACE(("update_font_utf8_title active %d, enable %d\n", active, enable));
3880 SetItemSensitivity(fontMenuEntries[fontMenu_utf8_title].widget, active);
3881 UpdateCheckbox("update_font_utf8_title",
3882 fontMenuEntries,
3883 fontMenu_utf8_title,
3884 enable);
3885 }
3886 #endif
3887
3888 #if OPT_DEC_CHRSET || OPT_BOX_CHARS || OPT_DEC_SOFTFONT
3889 void
update_menu_allowBoldFonts(void)3890 update_menu_allowBoldFonts(void)
3891 {
3892 UpdateCheckbox("update_menu_allowBoldFonts",
3893 fontMenuEntries,
3894 fontMenu_allowBoldFonts,
3895 TScreenOf(term)->allowBoldFonts);
3896 }
3897 #endif
3898
3899 #if OPT_ALLOW_XXX_OPS
3900 static void
enable_allow_xxx_ops(Bool enable)3901 enable_allow_xxx_ops(Bool enable)
3902 {
3903 SetItemSensitivity(fontMenuEntries[fontMenu_allowFontOps].widget, enable);
3904 SetItemSensitivity(fontMenuEntries[fontMenu_allowMouseOps].widget, enable);
3905 SetItemSensitivity(fontMenuEntries[fontMenu_allowTcapOps].widget, enable);
3906 SetItemSensitivity(fontMenuEntries[fontMenu_allowTitleOps].widget, enable);
3907 SetItemSensitivity(fontMenuEntries[fontMenu_allowWindowOps].widget, enable);
3908 }
3909
3910 static void
do_allowColorOps(Widget w,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)3911 do_allowColorOps(Widget w,
3912 XtPointer closure GCC_UNUSED,
3913 XtPointer data GCC_UNUSED)
3914 {
3915 XtermWidget xw = getXtermWidget(w);
3916 if (xw != 0) {
3917 ToggleFlag(TScreenOf(xw)->allowColorOps);
3918 update_menu_allowColorOps();
3919 }
3920 }
3921
3922 static void
do_allowFontOps(Widget w,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)3923 do_allowFontOps(Widget w,
3924 XtPointer closure GCC_UNUSED,
3925 XtPointer data GCC_UNUSED)
3926 {
3927 XtermWidget xw = getXtermWidget(w);
3928 if (xw != 0) {
3929 ToggleFlag(TScreenOf(xw)->allowFontOps);
3930 update_menu_allowFontOps();
3931 }
3932 }
3933
3934 static void
do_allowMouseOps(Widget w,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)3935 do_allowMouseOps(Widget w,
3936 XtPointer closure GCC_UNUSED,
3937 XtPointer data GCC_UNUSED)
3938 {
3939 XtermWidget xw = getXtermWidget(w);
3940 if (xw != 0) {
3941 ToggleFlag(TScreenOf(xw)->allowMouseOps);
3942 update_menu_allowMouseOps();
3943 }
3944 }
3945
3946 static void
do_allowTcapOps(Widget w,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)3947 do_allowTcapOps(Widget w,
3948 XtPointer closure GCC_UNUSED,
3949 XtPointer data GCC_UNUSED)
3950 {
3951 XtermWidget xw = getXtermWidget(w);
3952 if (xw != 0) {
3953 ToggleFlag(TScreenOf(xw)->allowTcapOps);
3954 update_menu_allowTcapOps();
3955 }
3956 }
3957
3958 static void
do_allowTitleOps(Widget w,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)3959 do_allowTitleOps(Widget w,
3960 XtPointer closure GCC_UNUSED,
3961 XtPointer data GCC_UNUSED)
3962 {
3963 XtermWidget xw = getXtermWidget(w);
3964 if (xw != 0) {
3965 ToggleFlag(TScreenOf(xw)->allowTitleOps);
3966 update_menu_allowTitleOps();
3967 }
3968 }
3969
3970 static void
do_allowWindowOps(Widget w,XtPointer closure GCC_UNUSED,XtPointer data GCC_UNUSED)3971 do_allowWindowOps(Widget w,
3972 XtPointer closure GCC_UNUSED,
3973 XtPointer data GCC_UNUSED)
3974 {
3975 XtermWidget xw = getXtermWidget(w);
3976 if (xw != 0) {
3977 ToggleFlag(TScreenOf(xw)->allowWindowOps);
3978 update_menu_allowWindowOps();
3979 }
3980 }
3981
3982 void
HandleAllowColorOps(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)3983 HandleAllowColorOps(Widget w,
3984 XEvent *event GCC_UNUSED,
3985 String *params,
3986 Cardinal *param_count)
3987 {
3988 HANDLE_VT_TOGGLE(allowColorOps);
3989 }
3990
3991 void
HandleAllowFontOps(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)3992 HandleAllowFontOps(Widget w,
3993 XEvent *event GCC_UNUSED,
3994 String *params,
3995 Cardinal *param_count)
3996 {
3997 HANDLE_VT_TOGGLE(allowFontOps);
3998 }
3999
4000 void
HandleAllowMouseOps(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)4001 HandleAllowMouseOps(Widget w,
4002 XEvent *event GCC_UNUSED,
4003 String *params,
4004 Cardinal *param_count)
4005 {
4006 HANDLE_VT_TOGGLE(allowMouseOps);
4007 }
4008
4009 void
HandleAllowTcapOps(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)4010 HandleAllowTcapOps(Widget w,
4011 XEvent *event GCC_UNUSED,
4012 String *params,
4013 Cardinal *param_count)
4014 {
4015 HANDLE_VT_TOGGLE(allowTcapOps);
4016 }
4017
4018 void
HandleAllowTitleOps(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)4019 HandleAllowTitleOps(Widget w,
4020 XEvent *event GCC_UNUSED,
4021 String *params,
4022 Cardinal *param_count)
4023 {
4024 HANDLE_VT_TOGGLE(allowTitleOps);
4025 }
4026
4027 void
HandleAllowWindowOps(Widget w,XEvent * event GCC_UNUSED,String * params,Cardinal * param_count)4028 HandleAllowWindowOps(Widget w,
4029 XEvent *event GCC_UNUSED,
4030 String *params,
4031 Cardinal *param_count)
4032 {
4033 HANDLE_VT_TOGGLE(allowWindowOps);
4034 }
4035
4036 void
update_menu_allowColorOps(void)4037 update_menu_allowColorOps(void)
4038 {
4039 UpdateCheckbox("update_menu_allowColorOps",
4040 fontMenuEntries,
4041 fontMenu_allowColorOps,
4042 TScreenOf(term)->allowColorOps);
4043 }
4044
4045 void
update_menu_allowFontOps(void)4046 update_menu_allowFontOps(void)
4047 {
4048 UpdateCheckbox("update_menu_allowFontOps",
4049 fontMenuEntries,
4050 fontMenu_allowFontOps,
4051 TScreenOf(term)->allowFontOps);
4052 }
4053
4054 void
update_menu_allowMouseOps(void)4055 update_menu_allowMouseOps(void)
4056 {
4057 UpdateCheckbox("update_menu_allowMouseOps",
4058 fontMenuEntries,
4059 fontMenu_allowMouseOps,
4060 TScreenOf(term)->allowMouseOps);
4061 }
4062
4063 void
update_menu_allowTcapOps(void)4064 update_menu_allowTcapOps(void)
4065 {
4066 UpdateCheckbox("update_menu_allowTcapOps",
4067 fontMenuEntries,
4068 fontMenu_allowTcapOps,
4069 TScreenOf(term)->allowTcapOps);
4070 }
4071
4072 void
update_menu_allowTitleOps(void)4073 update_menu_allowTitleOps(void)
4074 {
4075 UpdateCheckbox("update_menu_allowTitleOps",
4076 fontMenuEntries,
4077 fontMenu_allowTitleOps,
4078 TScreenOf(term)->allowTitleOps);
4079 }
4080
4081 void
update_menu_allowWindowOps(void)4082 update_menu_allowWindowOps(void)
4083 {
4084 UpdateCheckbox("update_menu_allowWindowOps",
4085 fontMenuEntries,
4086 fontMenu_allowWindowOps,
4087 TScreenOf(term)->allowWindowOps);
4088 }
4089 #endif
4090
4091 #if OPT_TEK4014
4092 void
update_tekshow(void)4093 update_tekshow(void)
4094 {
4095 if (!(TScreenOf(term)->inhibit & I_TEK)) {
4096 UpdateCheckbox("update_tekshow",
4097 vtMenuEntries,
4098 vtMenu_tekshow,
4099 TEK4014_SHOWN(term));
4100 }
4101 }
4102
4103 void
update_vttekmode(void)4104 update_vttekmode(void)
4105 {
4106 XtermWidget xw = term;
4107
4108 if (!(TScreenOf(xw)->inhibit & I_TEK)) {
4109 UpdateCheckbox("update_vtmode",
4110 vtMenuEntries,
4111 vtMenu_tekmode,
4112 TEK4014_ACTIVE(xw));
4113 UpdateCheckbox("update_tekmode",
4114 tekMenuEntries,
4115 tekMenu_vtmode,
4116 !TEK4014_ACTIVE(xw));
4117 update_fullscreen();
4118 }
4119 }
4120
4121 void
update_vtshow(void)4122 update_vtshow(void)
4123 {
4124 if (!(TScreenOf(term)->inhibit & I_TEK)) {
4125 UpdateCheckbox("update_vtshow",
4126 tekMenuEntries,
4127 tekMenu_vtshow,
4128 TScreenOf(term)->Vshow);
4129 }
4130 }
4131
4132 void
set_vthide_sensitivity(void)4133 set_vthide_sensitivity(void)
4134 {
4135 if (!(TScreenOf(term)->inhibit & I_TEK)) {
4136 SetItemSensitivity(
4137 vtMenuEntries[vtMenu_vthide].widget,
4138 TEK4014_SHOWN(term));
4139 }
4140 }
4141
4142 void
set_tekhide_sensitivity(void)4143 set_tekhide_sensitivity(void)
4144 {
4145 if (!(TScreenOf(term)->inhibit & I_TEK)) {
4146 SetItemSensitivity(
4147 tekMenuEntries[tekMenu_tekhide].widget,
4148 TScreenOf(term)->Vshow);
4149 }
4150 }
4151
4152 void
set_tekfont_menu_item(int n,int val)4153 set_tekfont_menu_item(int n, int val)
4154 {
4155 if (!(TScreenOf(term)->inhibit & I_TEK)) {
4156 UpdateCheckbox("set_tekfont_menu_item", tekMenuEntries, FS2MI(n),
4157 (val));
4158 }
4159 }
4160 #endif /* OPT_TEK4014 */
4161
4162 void
set_menu_font(int val)4163 set_menu_font(int val)
4164 {
4165 UpdateCheckbox("set_menu_font",
4166 fontMenuEntries,
4167 TScreenOf(term)->menu_font_number,
4168 (val));
4169 }
4170