1/* $XTermId: menu.h,v 1.147 2024/12/01 23:38:29 tom Exp $ */
2
3/*
4 * Copyright 1999-2021,2024 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
42 * in all copies or substantial portions of the Software.
43 *
44 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
45 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
46 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
47 * IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
48 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
49 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
50 * OTHER DEALINGS IN THE SOFTWARE.
51 *
52 * Except as contained in this notice, the name of the X Consortium shall
53 * not be used in advertising or otherwise to promote the sale, use or
54 * other dealings in this Software without prior written authorization
55 * from the X Consortium.
56 */
57
58#ifndef included_menu_h
59#define included_menu_h
60/* *INDENT-OFF* */
61
62#include <xterm.h>
63
64#ifndef OPT_MENU_KEEPCLIPBOARD
65#define OPT_MENU_KEEPCLIPBOARD 0	/* useful for debugging */
66#endif
67
68typedef struct _MenuEntry {
69    const char *name;
70    void (*function) PROTO_XT_CALLBACK_ARGS;
71    Widget widget;
72} MenuEntry;
73
74extern MenuEntry mainMenuEntries[], vtMenuEntries[];
75extern MenuEntry fontMenuEntries[];
76#if OPT_TEK4014
77extern MenuEntry tekMenuEntries[];
78#endif
79
80extern void Handle8BitControl      PROTO_XT_ACTIONS_ARGS;
81extern void HandleAllow132         PROTO_XT_ACTIONS_ARGS;
82extern void HandleAllowBoldFonts   PROTO_XT_ACTIONS_ARGS;
83extern void HandleAllowColorOps    PROTO_XT_ACTIONS_ARGS;
84extern void HandleAllowFontOps     PROTO_XT_ACTIONS_ARGS;
85extern void HandleAllowMouseOps    PROTO_XT_ACTIONS_ARGS;
86extern void HandleAllowSends       PROTO_XT_ACTIONS_ARGS;
87extern void HandleAllowTcapOps     PROTO_XT_ACTIONS_ARGS;
88extern void HandleAllowTitleOps    PROTO_XT_ACTIONS_ARGS;
89extern void HandleAllowWindowOps   PROTO_XT_ACTIONS_ARGS;
90extern void HandleAltEsc           PROTO_XT_ACTIONS_ARGS;
91extern void HandleAltScreen        PROTO_XT_ACTIONS_ARGS;
92extern void HandleAppCursor        PROTO_XT_ACTIONS_ARGS;
93extern void HandleAppKeypad        PROTO_XT_ACTIONS_ARGS;
94extern void HandleAutoLineFeed     PROTO_XT_ACTIONS_ARGS;
95extern void HandleAutoWrap         PROTO_XT_ACTIONS_ARGS;
96extern void HandleBackarrow        PROTO_XT_ACTIONS_ARGS;
97extern void HandleBellIsUrgent     PROTO_XT_ACTIONS_ARGS;
98extern void HandleCreateMenu       PROTO_XT_ACTIONS_ARGS;
99extern void HandleCursesEmul       PROTO_XT_ACTIONS_ARGS;
100extern void HandleCursorBlink      PROTO_XT_ACTIONS_ARGS;
101extern void HandleDeleteIsDEL      PROTO_XT_ACTIONS_ARGS;
102extern void HandleDumpHtml         PROTO_XT_ACTIONS_ARGS;
103extern void HandleDumpSvg          PROTO_XT_ACTIONS_ARGS;
104extern void HandleFontBoxChars     PROTO_XT_ACTIONS_ARGS;
105extern void HandleFontDoublesize   PROTO_XT_ACTIONS_ARGS;
106extern void HandleFontLoading      PROTO_XT_ACTIONS_ARGS;
107extern void HandleFontPacked       PROTO_XT_ACTIONS_ARGS;
108extern void HandleFullscreen       PROTO_XT_ACTIONS_ARGS;
109extern void HandleHpFunctionKeys   PROTO_XT_ACTIONS_ARGS;
110extern void HandleJumpscroll       PROTO_XT_ACTIONS_ARGS;
111extern void HandleKeepClipboard    PROTO_XT_ACTIONS_ARGS;
112extern void HandleKeepSelection    PROTO_XT_ACTIONS_ARGS;
113extern void HandleLogging          PROTO_XT_ACTIONS_ARGS;
114extern void HandleMarginBell       PROTO_XT_ACTIONS_ARGS;
115extern void HandleMetaEsc          PROTO_XT_ACTIONS_ARGS;
116extern void HandleNumLock          PROTO_XT_ACTIONS_ARGS;
117extern void HandleOldFunctionKeys  PROTO_XT_ACTIONS_ARGS;
118extern void HandlePopupMenu        PROTO_XT_ACTIONS_ARGS;
119extern void HandlePrintControlMode PROTO_XT_ACTIONS_ARGS;
120extern void HandlePrintEverything  PROTO_XT_ACTIONS_ARGS;
121extern void HandlePrintImmediate   PROTO_XT_ACTIONS_ARGS;
122extern void HandlePrintOnError     PROTO_XT_ACTIONS_ARGS;
123extern void HandlePrintScreen      PROTO_XT_ACTIONS_ARGS;
124extern void HandleRedraw           PROTO_XT_ACTIONS_ARGS;
125extern void HandleRenderFont       PROTO_XT_ACTIONS_ARGS;
126extern void HandleReverseVideo     PROTO_XT_ACTIONS_ARGS;
127extern void HandleReverseWrap      PROTO_XT_ACTIONS_ARGS;
128extern void HandleScoFunctionKeys  PROTO_XT_ACTIONS_ARGS;
129extern void HandleScrollKey        PROTO_XT_ACTIONS_ARGS;
130extern void HandleScrollTtyOutput  PROTO_XT_ACTIONS_ARGS;
131extern void HandleScrollbar        PROTO_XT_ACTIONS_ARGS;
132extern void HandleSecure           PROTO_XT_ACTIONS_ARGS;
133extern void HandleSendSignal       PROTO_XT_ACTIONS_ARGS;
134extern void HandleSetPopOnBell     PROTO_XT_ACTIONS_ARGS;
135extern void HandleSetPrivateColorRegisters PROTO_XT_ACTIONS_ARGS;
136extern void HandleSetSelect        PROTO_XT_ACTIONS_ARGS;
137extern void HandleSetTekText       PROTO_XT_ACTIONS_ARGS;
138extern void HandleSetTerminalType  PROTO_XT_ACTIONS_ARGS;
139extern void HandleSetVisualBell    PROTO_XT_ACTIONS_ARGS;
140extern void HandleSixelScrolling   PROTO_XT_ACTIONS_ARGS;
141extern void HandleSunFunctionKeys  PROTO_XT_ACTIONS_ARGS;
142extern void HandleSunKeyboard      PROTO_XT_ACTIONS_ARGS;
143extern void HandleTekCopy          PROTO_XT_ACTIONS_ARGS;
144extern void HandleTekPage          PROTO_XT_ACTIONS_ARGS;
145extern void HandleTekReset         PROTO_XT_ACTIONS_ARGS;
146extern void HandleTiteInhibit      PROTO_XT_ACTIONS_ARGS;
147extern void HandleToolbar          PROTO_XT_ACTIONS_ARGS;
148extern void HandleUTF8Fonts        PROTO_XT_ACTIONS_ARGS;
149extern void HandleUTF8Mode         PROTO_XT_ACTIONS_ARGS;
150extern void HandleUTF8Title        PROTO_XT_ACTIONS_ARGS;
151extern void HandleVisibility       PROTO_XT_ACTIONS_ARGS;
152extern void HandleWriteError       PROTO_XT_ACTIONS_ARGS;
153extern void HandleWriteNow         PROTO_XT_ACTIONS_ARGS;
154
155extern GCC_NORETURN void HandleClearSavedLines  PROTO_XT_ACTIONS_ARGS;
156extern GCC_NORETURN void HandleHardReset        PROTO_XT_ACTIONS_ARGS;
157extern GCC_NORETURN void HandleQuit             PROTO_XT_ACTIONS_ARGS;
158extern GCC_NORETURN void HandleSoftReset        PROTO_XT_ACTIONS_ARGS;
159
160extern void SetupMenus (Widget /*shell*/, Widget */*forms*/, Widget */*menus*/, Dimension * /*menu_high*/);
161
162#if OPT_TOOLBAR
163extern void ShowToolbar(Bool);
164#endif
165
166/*
167 * The following definitions MUST match the order of entries given in
168 * the mainMenuEntries, vtMenuEntries, and tekMenuEntries arrays in menu.c.
169 */
170
171/*
172 * items in primary menu
173 */
174typedef enum {
175#if OPT_TOOLBAR
176    mainMenu_toolbar,
177#endif
178#if OPT_MAXIMIZE
179    mainMenu_fullscreen,
180#endif
181    mainMenu_securekbd,
182    mainMenu_allowsends,
183    mainMenu_redraw,
184    mainMenu_line1,
185#ifdef ALLOWLOGGING
186    mainMenu_logging,
187#endif
188#if OPT_PRINT_ON_EXIT
189    mainMenu_write_now,
190    mainMenu_write_error,
191#endif
192    mainMenu_print,
193    mainMenu_print_redir,
194#if OPT_SCREEN_DUMPS
195    mainMenu_dump_html,
196    mainMenu_dump_svg,
197#endif
198    mainMenu_line2,
199    mainMenu_8bit_ctrl,
200    mainMenu_backarrow,
201#if OPT_NUM_LOCK
202    mainMenu_num_lock,
203    mainMenu_alt_esc,
204    mainMenu_meta_esc,
205#endif
206    mainMenu_delete_del,
207    mainMenu_old_fkeys,
208#if OPT_TCAP_FKEYS
209    mainMenu_tcap_fkeys,
210#endif
211#if OPT_HP_FUNC_KEYS
212    mainMenu_hp_fkeys,
213#endif
214#if OPT_SCO_FUNC_KEYS
215    mainMenu_sco_fkeys,
216#endif
217#if OPT_SUN_FUNC_KEYS
218    mainMenu_sun_fkeys,
219#endif
220#if OPT_SUNPC_KBD
221    mainMenu_sun_kbd,
222#endif
223    mainMenu_line3,
224    mainMenu_suspend,
225    mainMenu_continue,
226    mainMenu_interrupt,
227    mainMenu_hangup,
228    mainMenu_terminate,
229    mainMenu_kill,
230    mainMenu_line4,
231    mainMenu_quit,
232    mainMenu_LAST
233} mainMenuIndices;
234
235
236/*
237 * items in vt100 mode menu
238 */
239typedef enum {
240    vtMenu_scrollbar,
241    vtMenu_jumpscroll,
242    vtMenu_reversevideo,
243    vtMenu_autowrap,
244    vtMenu_reversewrap,
245    vtMenu_autolinefeed,
246    vtMenu_appcursor,
247    vtMenu_appkeypad,
248    vtMenu_scrollkey,
249    vtMenu_scrollttyoutput,
250    vtMenu_allow132,
251    vtMenu_keepSelection,
252#if OPT_MENU_KEEPCLIPBOARD
253    vtMenu_keepClipboard,
254#endif
255    vtMenu_selectToClipboard,
256    vtMenu_visualbell,
257    vtMenu_bellIsUrgent,
258    vtMenu_poponbell,
259#if OPT_BLINK_CURS
260    vtMenu_cursorblink,
261#endif
262    vtMenu_titeInhibit,
263#ifndef NO_ACTIVE_ICON
264    vtMenu_activeicon,
265#endif /* NO_ACTIVE_ICON */
266    vtMenu_line1,
267    vtMenu_softreset,
268    vtMenu_hardreset,
269    vtMenu_clearsavedlines,
270    vtMenu_line2,
271#if OPT_TEK4014
272    vtMenu_tekshow,
273    vtMenu_tekmode,
274    vtMenu_vthide,
275#endif
276    vtMenu_altscreen,
277#if OPT_SIXEL_GRAPHICS
278    vtMenu_sixelscrolling,
279#endif
280#if OPT_GRAPHICS
281    vtMenu_privatecolorregisters,
282#endif
283    vtMenu_LAST
284} vtMenuIndices;
285
286/*
287 * items in vt100 font menu
288 */
289typedef enum {
290    fontMenu_default,
291    fontMenu_font1,
292    fontMenu_font2,
293    fontMenu_font3,
294    fontMenu_font4,
295    fontMenu_font5,
296    fontMenu_font6,
297    fontMenu_font7,
298#define fontMenu_lastBuiltin fontMenu_font7
299    fontMenu_fontescape,
300    fontMenu_fontsel,
301/* number of non-line items down to here should match NMENUFONTS in ptyx.h */
302
303#if OPT_DEC_CHRSET || OPT_BOX_CHARS || OPT_DEC_SOFTFONT
304    fontMenu_line1,
305    fontMenu_allowBoldFonts,
306#if OPT_BOX_CHARS
307    fontMenu_font_boxchars,
308    fontMenu_font_packedfont,
309#endif
310#if OPT_DEC_CHRSET
311    fontMenu_font_doublesize,
312#endif
313#if OPT_DEC_SOFTFONT
314    fontMenu_font_loadable,
315#endif
316#endif
317
318#if OPT_RENDERFONT || OPT_WIDE_CHARS
319    fontMenu_line2,
320#if OPT_RENDERFONT
321    fontMenu_render_font,
322#endif
323#if OPT_WIDE_CHARS
324    fontMenu_utf8_mode,
325    fontMenu_utf8_fonts,
326    fontMenu_utf8_title,
327#endif
328#endif
329#if OPT_ALLOW_XXX_OPS
330    fontMenu_line3,
331    fontMenu_allowColorOps,
332    fontMenu_allowFontOps,
333    fontMenu_allowMouseOps,
334    fontMenu_allowTcapOps,
335    fontMenu_allowTitleOps,
336    fontMenu_allowWindowOps,
337#endif
338
339    fontMenu_LAST
340} fontMenuIndices;
341
342/*
343 * items in tek4014 mode menu
344 */
345#if OPT_TEK4014
346typedef enum {
347    tekMenu_tektextlarge,
348    tekMenu_tektext2,
349    tekMenu_tektext3,
350    tekMenu_tektextsmall,
351    tekMenu_line1,
352    tekMenu_tekpage,
353    tekMenu_tekreset,
354    tekMenu_tekcopy,
355    tekMenu_line2,
356    tekMenu_vtshow,
357    tekMenu_vtmode,
358    tekMenu_tekhide,
359    tekMenu_LAST
360} tekMenuIndices;
361#endif
362
363
364/*
365 * functions for updating menus
366 */
367
368extern void SetItemSensitivity(Widget mi, Bool val);
369
370typedef enum {
371    toggleErr = -2,
372    toggleAll = -1,
373    toggleOff = 0,
374    toggleOn = 1
375} ToggleEnum;
376
377extern int decodeToggle(XtermWidget /* xw */, String * /* params */, Cardinal /* nparams */);
378
379/*
380 * there should be one of each of the following for each checkable item
381 */
382#if OPT_TOOLBAR
383extern void update_toolbar(void);
384#else
385#define update_toolbar() /* nothing */
386#endif
387
388#if OPT_MAXIMIZE
389extern void update_fullscreen(void);
390#else
391#define update_fullscreen() /* nothing */
392#endif
393
394extern void update_securekbd(void);
395extern void update_allowsends(void);
396
397#ifdef ALLOWLOGGING
398extern void update_logging(void);
399#else
400#define update_logging() /*nothing*/
401#endif
402
403#if OPT_PRINT_ON_EXIT
404extern void update_write_error(void);
405#else
406#define update_write_error() /*nothing*/
407#endif
408
409extern void update_print_redir(void);
410extern void update_8bit_control(void);
411extern void update_decbkm(void);
412
413#if OPT_NUM_LOCK
414extern void update_num_lock(void);
415extern void update_alt_esc(void);
416extern void update_meta_esc(void);
417#else
418#define update_num_lock() /*nothing*/
419#define update_alt_esc()  /*nothing*/
420#define update_meta_esc() /*nothing*/
421#endif
422
423extern void update_old_fkeys(void);
424extern void update_delete_del(void);
425
426#if OPT_SUNPC_KBD
427extern void update_sun_kbd(void);
428#endif
429
430#if OPT_HP_FUNC_KEYS
431extern void update_hp_fkeys(void);
432#else
433#define update_hp_fkeys() /*nothing*/
434#endif
435
436#if OPT_SCO_FUNC_KEYS
437extern void update_sco_fkeys(void);
438#else
439#define update_sco_fkeys() /*nothing*/
440#endif
441
442#if OPT_SUN_FUNC_KEYS
443extern void update_sun_fkeys(void);
444#else
445#define update_sun_fkeys() /*nothing*/
446#endif
447
448#if OPT_TCAP_FKEYS
449extern void update_tcap_fkeys(void);
450#else
451#define update_tcap_fkeys() /*nothing*/
452#endif
453
454extern void update_scrollbar(void);
455extern void update_jumpscroll(void);
456extern void update_reversevideo(void);
457extern void update_autowrap(void);
458extern void update_reversewrap(void);
459extern void update_autolinefeed(void);
460extern void update_appcursor(void);
461extern void update_appkeypad(void);
462extern void update_scrollkey(void);
463extern void update_keepSelection(void);
464extern void update_selectToClipboard(void);
465extern void update_scrollttyoutput(void);
466extern void update_allow132(void);
467extern void update_cursesemul(void);
468extern void update_visualbell(void);
469extern void update_bellIsUrgent(void);
470extern void update_poponbell(void);
471
472#if OPT_MENU_KEEPCLIPBOARD
473extern void update_keepClipboard(void);
474#else
475#define update_keepClipboard() /* nothing */
476#endif
477
478#define update_marginbell() /* nothing */
479
480#if OPT_LOAD_VTFONTS
481extern void update_font_escape(void);
482#else
483#define update_font_escape() /* nothing */
484#endif
485
486#if OPT_ALLOW_XXX_OPS
487extern void update_menu_allowColorOps(void);
488extern void update_menu_allowFontOps(void);
489extern void update_menu_allowMouseOps(void);
490extern void update_menu_allowTcapOps(void);
491extern void update_menu_allowTitleOps(void);
492extern void update_menu_allowWindowOps(void);
493#endif
494
495#if OPT_BLINK_CURS
496extern void update_cursorblink(void);
497#else
498#define update_cursorblink() /* nothing */
499#endif
500
501extern void update_altscreen(void);
502extern void update_titeInhibit(void);
503
504#ifndef NO_ACTIVE_ICON
505extern void update_activeicon(void);
506#endif /* NO_ACTIVE_ICON */
507
508#if OPT_DEC_CHRSET
509extern void update_font_doublesize(void);
510#else
511#define update_font_doublesize() /* nothing */
512#endif
513
514#if OPT_BOX_CHARS
515extern void update_font_boxchars(void);
516extern void update_font_packed(void);
517#else
518#define update_font_boxchars() /* nothing */
519#define update_font_packed() /* nothing */
520#endif
521
522#if OPT_SIXEL_GRAPHICS
523extern void update_decsdm(void);
524#else
525#define update_decsdm() /* nothing */
526#endif
527
528#if OPT_GRAPHICS
529extern void update_privatecolorregisters(void);
530#else
531#define update_privatecolorregisters() /* nothing */
532#endif
533
534#if OPT_DEC_SOFTFONT
535extern void update_font_loadable(void);
536#else
537#define update_font_loadable() /* nothing */
538#endif
539
540#if OPT_RENDERFONT
541extern void update_font_renderfont(void);
542#else
543#define update_font_renderfont() /* nothing */
544#endif
545
546#if OPT_WIDE_CHARS
547extern void update_font_utf8_mode(void);
548extern void update_font_utf8_fonts(void);
549extern void update_font_utf8_title(void);
550#else
551#define update_font_utf8_mode() /* nothing */
552#define update_font_utf8_fonts() /* nothing */
553#define update_font_utf8_title() /* nothing */
554#endif
555
556#if OPT_TEK4014
557extern void update_tekshow(void);
558extern void update_vttekmode(void);
559extern void update_vtshow(void);
560extern void set_vthide_sensitivity(void);
561extern void set_tekhide_sensitivity(void);
562#else
563#define update_tekshow() /*nothing*/
564#define update_vttekmode() /*nothing*/
565#define update_vtshow() /*nothing*/
566#define set_vthide_sensitivity() /*nothing*/
567#define set_tekhide_sensitivity() /*nothing*/
568#endif
569
570#if OPT_DEC_CHRSET || OPT_BOX_CHARS || OPT_DEC_SOFTFONT
571extern void update_menu_allowBoldFonts(void);
572#else
573#define update_menu_allowBoldFonts() /*nothing*/
574#endif
575
576/*
577 * macros for mapping font size to tekMenu placement
578 */
579#define FS2MI(n) (n)			/* font_size_to_menu_item */
580#define MI2FS(n) (n)			/* menu_item_to_font_size */
581
582#if OPT_TEK4014
583extern void set_tekfont_menu_item(int n,int val);
584#else
585#define set_tekfont_menu_item(n,val) /*nothing*/
586#endif
587
588extern void set_menu_font(int val);
589
590/* *INDENT-ON* */
591
592#endif /* included_menu_h */
593