annotate src/menubar.c @ 404:2f8bb876ab1d r21-2-32

Import from CVS: tag r21-2-32
author cvs
date Mon, 13 Aug 2007 11:16:07 +0200
parents 74fd4e045ea6
children 697ef44129c6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Implements an elisp-programmable menubar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 /* Synched up with: Not in FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
24 /* Authorship:
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
25
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
26 Created by Ben Wing as part of device-abstraction work for 19.12.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
27 Menu filters and many other keywords added by Stig for 19.12.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
28 Menu accelerators c. 1997? by ??. Moved here from event-stream.c.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
29 Much other work post-1996 by ??.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
30 */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
35 #include "buffer.h"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 #include "device.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 #include "frame.h"
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
38 #include "gui.h"
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
39 #include "keymap.h"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 #include "menubar.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 #include "redisplay.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 #include "window.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 int menubar_show_keybindings;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 Lisp_Object Vmenubar_configuration;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 Lisp_Object Qcurrent_menubar;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 Lisp_Object Qactivate_menubar_hook, Vactivate_menubar_hook;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 Lisp_Object Vmenubar_visible_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 static Lisp_Object Vcurrent_menubar; /* DO NOT ever reference this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 Always go through Qcurrent_menubar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 See below. */
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 20
diff changeset
56
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 Lisp_Object Vblank_menubar;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 int popup_menu_titles;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 Lisp_Object Vmenubar_pointer_glyph;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
63 /* prefix key(s) that must match in order to activate menu.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
64 This is ugly. fix me.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
65 */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
66 Lisp_Object Vmenu_accelerator_prefix;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
67
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
68 /* list of modifier keys to match accelerator for top level menus */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
69 Lisp_Object Vmenu_accelerator_modifiers;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
70
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
71 /* whether menu accelerators are enabled */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
72 Lisp_Object Vmenu_accelerator_enabled;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
73
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
74 /* keymap for auxiliary menu accelerator functions */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
75 Lisp_Object Vmenu_accelerator_map;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
76
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
77 Lisp_Object Qmenu_force;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
78 Lisp_Object Qmenu_fallback;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
79 Lisp_Object Qmenu_quit;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
80 Lisp_Object Qmenu_up;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
81 Lisp_Object Qmenu_down;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
82 Lisp_Object Qmenu_left;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
83 Lisp_Object Qmenu_right;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
84 Lisp_Object Qmenu_select;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
85 Lisp_Object Qmenu_escape;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
86
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 menubar_variable_changed (Lisp_Object sym, Lisp_Object *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 Lisp_Object in_object, int flags)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 MARK_MENUBAR_CHANGED;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 update_frame_menubars (struct frame *f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 if (f->menubar_changed || f->windows_changed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 MAYBE_FRAMEMETH (f, update_frame_menubars, (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 f->menubar_changed = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 free_frame_menubars (struct frame *f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 /* If we had directly allocated any memory for the menubars instead
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 of using all Lisp_Objects this is where we would now free it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 MAYBE_FRAMEMETH (f, free_frame_menubars, (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 menubar_visible_p_changed (Lisp_Object specifier, struct window *w,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 Lisp_Object oldval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 MARK_MENUBAR_CHANGED;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 menubar_visible_p_changed_in_frame (Lisp_Object specifier, struct frame *f,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 Lisp_Object oldval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 update_frame_menubars (f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
127 Lisp_Object
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
128 current_frame_menubar (const struct frame* f)
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
129 {
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
130 struct window *w = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f));
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
131 return symbol_value_in_buffer (Qcurrent_menubar, w->buffer);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
132 }
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
133
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
134 Lisp_Object
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
135 menu_parse_submenu_keywords (Lisp_Object desc, Lisp_Object gui_item)
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
136 {
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
137 Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
138
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
139 /* Menu descriptor should be a list */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
140 CHECK_CONS (desc);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
141
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
142 /* First element may be menu name, although can be omitted.
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
143 Let's think that if stuff begins with anything than a keyword
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
144 or a list (submenu), this is a menu name, expected to be a string */
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
145 if (!KEYWORDP (XCAR (desc)) && !CONSP (XCAR (desc)))
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
146 {
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
147 CHECK_STRING (XCAR (desc));
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
148 pgui_item->name = XCAR (desc);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
149 desc = XCDR (desc);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
150 if (!NILP (desc))
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
151 CHECK_CONS (desc);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
152 }
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
153
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
154 /* Walk along all key-value pairs */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
155 while (!NILP(desc) && KEYWORDP (XCAR (desc)))
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
156 {
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
157 Lisp_Object key, val;
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
158 key = XCAR (desc);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
159 desc = XCDR (desc);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
160 CHECK_CONS (desc);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
161 val = XCAR (desc);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
162 desc = XCDR (desc);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
163 if (!NILP (desc))
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
164 CHECK_CONS (desc);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
165 gui_item_add_keyval_pair (gui_item, key, val, ERROR_ME);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
166 }
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
167
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
168 /* Return the rest - supposed to be a list of items */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
169 return desc;
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
170 }
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
171
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
172 DEFUN ("menu-find-real-submenu", Fmenu_find_real_submenu, 2, 2, 0, /*
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
173 Find a submenu descriptor within DESC by following PATH.
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
174 This function finds a submenu descriptor, either from the description
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
175 DESC or generated by a filter within DESC. The function regards :config
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
176 and :included keywords in the DESC, and expands submenus along the
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
177 PATH using :filter functions. Return value is a descriptor for the
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
178 submenu, NOT expanded and NOT checked against :config and :included.
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
179 Also, individual menu items are not looked for, only submenus.
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
180
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
181 See also 'find-menu-item'.
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
182 */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
183 (desc, path))
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
184 {
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
185 Lisp_Object path_entry, submenu_desc, submenu;
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
186 struct gcpro gcpro1, gcpro2;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
187 Lisp_Object gui_item = allocate_gui_item ();
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
188 Lisp_Gui_Item* pgui_item = XGUI_ITEM (gui_item);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
189
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
190 GCPRO2 (gui_item, desc);
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
191
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
192 EXTERNAL_LIST_LOOP (path_entry, path)
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
193 {
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
194 /* Verify that DESC describes a menu, not single item */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
195 if (!CONSP (desc))
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
196 RETURN_UNGCPRO (Qnil);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
197
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
198 /* Parse this menu */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
199 desc = menu_parse_submenu_keywords (desc, gui_item);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
200
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
201 /* Check that this (sub)menu is active */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
202 if (!gui_item_active_p (gui_item))
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
203 RETURN_UNGCPRO (Qnil);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
204
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
205 /* Apply :filter */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
206 if (!NILP (pgui_item->filter))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
207 desc = call1 (pgui_item->filter, desc);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
208
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
209 /* Find the next menu on the path inside this one */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
210 EXTERNAL_LIST_LOOP (submenu_desc, desc)
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
211 {
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
212 submenu = XCAR (submenu_desc);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
213 if (CONSP (submenu)
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
214 && STRINGP (XCAR (submenu))
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
215 && !NILP (Fstring_equal (XCAR (submenu), XCAR (path_entry))))
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
216 {
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
217 desc = submenu;
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
218 goto descend;
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
219 }
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
220 }
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
221 /* Submenu not found */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
222 RETURN_UNGCPRO (Qnil);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
223
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
224 descend:
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
225 /* Prepare for the next iteration */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
226 gui_item_init (gui_item);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
227 }
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
228
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
229 /* We have successfully descended down the end of the path */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
230 UNGCPRO;
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
231 return desc;
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
232 }
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
233
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
234 DEFUN ("popup-menu", Fpopup_menu, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 Pop up the given menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 A menu description is a list of menu items, strings, and submenus.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 The first element of a menu must be a string, which is the name of the menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 This is the string that will be displayed in the parent menu, if any. For
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 toplevel menus, it is ignored. This string is not displayed in the menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 itself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 If an element of a menu is a string, then that string will be presented in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 the menu as unselectable text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 If an element of a menu is a string consisting solely of hyphens, then that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 item will be presented as a solid horizontal line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 If an element of a menu is a list, it is treated as a submenu. The name of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 that submenu (the first element in the list) will be used as the name of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 item representing this menu on the parent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 Otherwise, the element must be a vector, which describes a menu item.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 A menu item can have any of the following forms:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
256 [ "name" callback <active-p> ]
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
257 [ "name" callback <active-p> <suffix> ]
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
258 [ "name" callback :<keyword> <value> :<keyword> <value> ... ]
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 The name is the string to display on the menu; it is filtered through the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 resource database, so it is possible for resources to override what string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 is actually displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 If the `callback' of a menu item is a symbol, then it must name a command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 It will be invoked with `call-interactively'. If it is a list, then it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 evaluated with `eval'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 The possible keywords are this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 :active <form> Same as <active-p> in the first two forms: the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 expression is evaluated just before the menu is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 displayed, and the menu will be selectable only if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 the result is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
275 :suffix <form> Same as <suffix> in the second form: the expression
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
276 is evaluated just before the menu is displayed and
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
277 resulting string is appended to the displayed name,
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
278 providing a convenient way of adding the name of a
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
279 command's ``argument'' to the menu, like
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
280 ``Kill Buffer NAME''.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
282 :keys "string" Normally, the keyboard equivalents of commands in
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 menus are displayed when the `callback' is a symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 This can be used to specify keys for more complex menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 items. It is passed through `substitute-command-keys'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 :style <style> Specifies what kind of object this menu item is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 nil A normal menu item.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 toggle A toggle button.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 radio A radio button.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 The only difference between toggle and radio buttons is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 how they are displayed. But for consistency, a toggle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 button should be used when there is one option whose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 value can be turned on or off, and radio buttons should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 be used when there is a set of mutually exclusive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 options. When using a group of radio buttons, you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 should arrange for no more than one to be marked as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 selected at a time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 :selected <form> Meaningful only when STYLE is `toggle' or `radio'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 This specifies whether the button will be in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 selected or unselected state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 For example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
309 [ "Save As..." write-file t ]
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
310 [ "Revert Buffer" revert-buffer (buffer-modified-p) ]
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
311 [ "Read Only" toggle-read-only :style toggle :selected buffer-read-only ]
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 See menubar.el for many more examples.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
314 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
315 (menu_desc, event))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 struct frame *f = decode_frame(Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 MAYBE_FRAMEMETH (f, popup_menu, (menu_desc,event));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
322 DEFUN ("normalize-menu-item-name", Fnormalize_menu_item_name, 1, 2, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
323 Convert a menu item name string into normal form, and return the new string.
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
324 Menu item names should be converted to normal form before being compared.
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
325 This removes %_'s (accelerator indications) and converts %% to %.
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
326 */
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
327 (name, buffer))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
328 {
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
329 struct buffer *buf = decode_buffer (buffer, 0);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
330 Lisp_String *n;
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
331 Charcount end;
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
332 int i;
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
333 Bufbyte *name_data;
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
334 Bufbyte *string_result;
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
335 Bufbyte *string_result_ptr;
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
336 Emchar elt;
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
337 int expecting_underscore = 0;
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
338
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
339 CHECK_STRING (name);
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
340
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
341 n = XSTRING (name);
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
342 end = string_char_length (n);
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
343 name_data = string_data (n);
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
344
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
345 string_result = (Bufbyte *) alloca (end * MAX_EMCHAR_LEN);
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
346 string_result_ptr = string_result;
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 197
diff changeset
347 for (i = 0; i < end; i++)
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
348 {
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 197
diff changeset
349 elt = charptr_emchar (name_data);
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
350 elt = DOWNCASE (buf, elt);
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 197
diff changeset
351 if (expecting_underscore)
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
352 {
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
353 expecting_underscore = 0;
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 197
diff changeset
354 switch (elt)
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
355 {
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 197
diff changeset
356 case '%':
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 197
diff changeset
357 /* Allow `%%' to mean `%'. */
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 197
diff changeset
358 string_result_ptr += set_charptr_emchar (string_result_ptr, '%');
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 197
diff changeset
359 break;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 197
diff changeset
360 case '_':
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 197
diff changeset
361 break;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 197
diff changeset
362 default:
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
363 string_result_ptr += set_charptr_emchar (string_result_ptr, '%');
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
364 string_result_ptr += set_charptr_emchar (string_result_ptr, elt);
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
365 }
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
366 }
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 197
diff changeset
367 else if (elt == '%')
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 197
diff changeset
368 expecting_underscore = 1;
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
369 else
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
370 string_result_ptr += set_charptr_emchar (string_result_ptr, elt);
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 197
diff changeset
371 INC_CHARPTR (name_data);
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
372 }
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
373
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
374 return make_string (string_result, string_result_ptr - string_result);
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
375 }
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
376
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 syms_of_menubar (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 defsymbol (&Qcurrent_menubar, "current-menubar");
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
381
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
382 defsymbol (&Qmenu_force, "menu-force");
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
383 defsymbol (&Qmenu_fallback, "menu-fallback");
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
384
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
385 defsymbol (&Qmenu_quit, "menu-quit");
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
386 defsymbol (&Qmenu_up, "menu-up");
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
387 defsymbol (&Qmenu_down, "menu-down");
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
388 defsymbol (&Qmenu_left, "menu-left");
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
389 defsymbol (&Qmenu_right, "menu-right");
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
390 defsymbol (&Qmenu_select, "menu-select");
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
391 defsymbol (&Qmenu_escape, "menu-escape");
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
392
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
393 DEFSUBR (Fpopup_menu);
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
394 DEFSUBR (Fnormalize_menu_item_name);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 219
diff changeset
395 DEFSUBR (Fmenu_find_real_submenu);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 vars_of_menubar (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
401 /* put in Vblank_menubar a menubar value which has no visible
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
402 * items. This is a bit tricky due to various quirks. We
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
403 * could use '(["" nil nil]), but this is apparently equivalent
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
404 * to '(nil), and a new frame created with this menubar will
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
405 * get a vertically-squished menubar. If we use " " as the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
406 * button title instead of "", we get an etched button border.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
407 * So we use
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
408 * '(("No active menubar" ["" nil nil]))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
409 * which creates a menu whose title is "No active menubar",
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
410 * and this works fine.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
411 */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
413 Vblank_menubar = list1 (list2 (build_string ("No active menubar"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
414 vector3 (build_string (""), Qnil, Qnil)));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
415 staticpro (&Vblank_menubar);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 DEFVAR_BOOL ("popup-menu-titles", &popup_menu_titles /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 If true, popup menus will have title bars at the top.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 popup_menu_titles = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 /* #### Replace current menubar with a specifier. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 /* All C code must access the menubar via Qcurrent_menubar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 because it can be buffer-local. Note that Vcurrent_menubar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 doesn't need to exist at all, except for the magic function. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 DEFVAR_LISP_MAGIC ("current-menubar", &Vcurrent_menubar /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 The current menubar. This may be buffer-local.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 When the menubar is changed, the function `set-menubar-dirty-flag' has to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 be called for the menubar to be updated on the frame. See `set-menubar'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 and `set-buffer-menubar'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 A menubar is a list of menus and menu-items.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 A menu is a list of menu items, keyword-value pairs, strings, and submenus.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 The first element of a menu must be a string, which is the name of the menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 This is the string that will be displayed in the parent menu, if any. For
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 toplevel menus, it is ignored. This string is not displayed in the menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 itself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
443 Menu accelerators can be indicated in the string by putting the
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
444 sequence "%_" before the character corresponding to the key that will
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
445 invoke the menu or menu item. Uppercase and lowercase accelerators
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
446 are equivalent. The sequence "%%" is also special, and is translated
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
447 into a single %.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
448
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
449 If no menu accelerator is present in the string, XEmacs will act as if
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
450 the first character has been tagged as an accelerator.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
451
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
452 Immediately following the name string of the menu, various optional
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
453 keyword-value pairs are permitted: currently, :filter, :active, :included,
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
454 and :config. (See below.)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 If an element of a menu (or menubar) is a string, then that string will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 presented as unselectable text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 If an element of a menu is a string consisting solely of hyphens, then that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 item will be presented as a solid horizontal line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
462 If an element of a menu is a string beginning with "--:", it will be
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
463 presented as a line whose appearance is controlled by the rest of the
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
464 text in the string. The allowed line specs are system-dependent, and
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
465 currently work only under X Windows (with Lucid and Motif menubars);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
466 otherwise, a solid horizontal line is presented, as if the string were
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
467 all hyphens.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
468
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
469 The possibilities are:
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
470
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
471 "--:singleLine"
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
472 "--:doubleLine"
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
473 "--:singleDashedLine"
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
474 "--:doubleDashedLine"
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
475 "--:noLine"
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
476 "--:shadowEtchedIn"
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
477 "--:shadowEtchedOut"
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
478 "--:shadowEtchedInDash"
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
479 "--:shadowEtchedOutDash"
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
480 "--:shadowDoubleEtchedIn" (Lucid menubars only)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
481 "--:shadowDoubleEtchedOut" (Lucid menubars only)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
482 "--:shadowDoubleEtchedInDash" (Lucid menubars only)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
483 "--:shadowDoubleEtchedOutDash" (Lucid menubars only)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
484
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 If an element of a menu is a list, it is treated as a submenu. The name of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 that submenu (the first element in the list) will be used as the name of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 item representing this menu on the parent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 If an element of a menubar is `nil', then it is used to represent the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 division between the set of menubar-items which are flushleft and those
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 which are flushright.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 Otherwise, the element must be a vector, which describes a menu item.
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
494 A menu item is of the following form:
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
495
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
496 [ "name" callback :<keyword> <value> :<keyword> <value> ... ]
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
497
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
498 The following forms are also accepted for compatibility, but deprecated:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
500 [ "name" callback <active-p> ]
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
501 [ "name" callback <active-p> <suffix> ]
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 The name is the string to display on the menu; it is filtered through the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 resource database, so it is possible for resources to override what string
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
505 is actually displayed. Menu accelerator indicators (the sequence `%_') are
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
506 also processed; see above. If the name is not a string, it will be
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
507 evaluated with `eval', and the result should be a string.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 If the `callback' of a menu item is a symbol, then it must name a command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 It will be invoked with `call-interactively'. If it is a list, then it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 evaluated with `eval'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
513 In the deprecated forms, <active-p> is equivalent to using the :active
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
514 keyword, and <suffix> is equivalent to using the :suffix keyword.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
516 The possible keywords are:
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
517
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
518 :active <form> The expression is evaluated just before the menu is
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 displayed, and the menu will be selectable only if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 the result is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
522 :suffix <form> The expression is evaluated just before the menu is
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
523 displayed and the resulting string is appended to
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
524 the displayed name, providing a convenient way of
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
525 adding the name of a command's ``argument'' to the
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
526 menu, like ``Kill Buffer NAME''.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
528 :keys "string" Normally, the keyboard equivalents of commands in
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 menus are displayed when the `callback' is a symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 This can be used to specify keys for more complex menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 items. It is passed through `substitute-command-keys'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 :style <style> Specifies what kind of object this menu item is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 nil A normal menu item.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 toggle A toggle button.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 radio A radio button.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 button A menubar button.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 The only difference between toggle and radio buttons is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 how they are displayed. But for consistency, a toggle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 button should be used when there is one option whose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 value can be turned on or off, and radio buttons should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 be used when there is a set of mutually exclusive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 options. When using a group of radio buttons, you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 should arrange for no more than one to be marked as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 selected at a time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 :selected <form> Meaningful only when STYLE is `toggle', `radio' or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 `button'. This specifies whether the button will be in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 the selected or unselected state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 :included <form> This can be used to control the visibility of a menu or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 menu item. The form is evaluated and the menu or menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 item is only displayed if the result is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 :config <symbol> This is an efficient shorthand for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 :included (memq symbol menubar-configuration)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 See the variable `menubar-configuration'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 :filter <function> A menu filter can only be used in a menu item list.
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
563 (i.e. not in a menu item itself). It is used to
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
564 incrementally create a submenu only when it is selected
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
565 by the user and not every time the menubar is activated.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
566 The filter function is passed the list of menu items in
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
567 the submenu and must return a list of menu items to be
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
568 used for the menu. It must not destructively modify
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
569 the list of menu items passed to it. It is called only
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
570 when the menu is about to be displayed, so other menus
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
571 may already be displayed. Vile and terrible things will
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
572 happen if a menu filter function changes the current
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
573 buffer, window, or frame. It also should not raise,
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
574 lower, or iconify any frames. Basically, the filter
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
575 function should have no side-effects.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576
377
d883f39b8495 Import from CVS: tag r21-2b4
cvs
parents: 371
diff changeset
577 :key-sequence keys Used in FSF Emacs as an hint to an equivalent keybinding.
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
578 Ignored by XEmacs for easymenu.el compatibility.
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
579
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 For example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
582 ("%_File"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 :filter file-menu-filter ; file-menu-filter is a function that takes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 ; one argument (a list of menu items) and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 ; returns a list of menu items
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
586 [ "Save %_As..." write-file t ]
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
587 [ "%_Revert Buffer" revert-buffer (buffer-modified-p) ]
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
588 [ "R%_ead Only" toggle-read-only :style toggle
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 :selected buffer-read-only ]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
592 See menubar-items.el for many more examples.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 After the menubar is clicked upon, but before any menus are popped up,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 the functions on the `activate-menubar-hook' are invoked to make top-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 changes to the menus and menubar. Note, however, that the use of menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 filters (using the :filter keyword) is usually a more efficient way to
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
598 dynamically alter or sensitize menus. */, menubar_variable_changed);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 Vcurrent_menubar = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 DEFVAR_LISP ("activate-menubar-hook", &Vactivate_menubar_hook /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 Function or functions called before a menubar menu is pulled down.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 These functions are called with no arguments, and should interrogate and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 modify the value of `current-menubar' as desired.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 The functions on this hook are invoked after the mouse goes down, but before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 the menu is mapped, and may be used to activate, deactivate, add, or delete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 items from the menus. However, it is probably the case that using a :filter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 keyword in a submenu would be a more efficient way of updating menus. See
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 the documentation of `current-menubar'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 These functions may return the symbol `t' to assert that they have made
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 no changes to the menubar. If any other value is returned, the menubar is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 recomputed. If `t' is returned but the menubar has been changed, then the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 changes may not show up right away. Returning `nil' when the menubar has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 not changed is not so bad; more computation will be done, but redisplay of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 the menubar will still be performed optimally.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 Vactivate_menubar_hook = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 defsymbol (&Qactivate_menubar_hook, "activate-menubar-hook");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 DEFVAR_BOOL ("menubar-show-keybindings", &menubar_show_keybindings /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 If true, the menubar will display keyboard equivalents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 If false, only the command names will be displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 menubar_show_keybindings = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 DEFVAR_LISP_MAGIC ("menubar-configuration", &Vmenubar_configuration /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 A list of symbols, against which the value of the :config tag for each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 menubar item will be compared. If a menubar item has a :config tag, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 it is omitted from the menubar if that tag is not a member of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 `menubar-configuration' list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 */ , menubar_variable_changed);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 Vmenubar_configuration = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 DEFVAR_LISP ("menubar-pointer-glyph", &Vmenubar_pointer_glyph /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 *The shape of the mouse-pointer when over the menubar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 This is a glyph; use `set-glyph-image' to change it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 If unspecified in a particular domain, the window-system-provided
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 default pointer is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
644 DEFVAR_LISP ("menu-accelerator-prefix", &Vmenu_accelerator_prefix /*
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
645 Prefix key(s) that must be typed before menu accelerators will be activated.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
646 Set this to a value acceptable by define-key.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
647
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
648 NOTE: This currently only has any effect under X Windows.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
649 */ );
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
650 Vmenu_accelerator_prefix = Qnil;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
651
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
652 DEFVAR_LISP ("menu-accelerator-modifiers", &Vmenu_accelerator_modifiers /*
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
653 Modifier keys which must be pressed to get to the top level menu accelerators.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
654 This is a list of modifier key symbols. All modifier keys must be held down
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
655 while a valid menu accelerator key is pressed in order for the top level
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
656 menu to become active.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
657
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
658 NOTE: This currently only has any effect under X Windows.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
659
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
660 See also menu-accelerator-enabled and menu-accelerator-prefix.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
661 */ );
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
662 Vmenu_accelerator_modifiers = list1 (Qmeta);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
663
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
664 DEFVAR_LISP ("menu-accelerator-enabled", &Vmenu_accelerator_enabled /*
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
665 Whether menu accelerator keys can cause the menubar to become active.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
666 If 'menu-force or 'menu-fallback, then menu accelerator keys can
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
667 be used to activate the top level menu. Once the menubar becomes active, the
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
668 accelerator keys can be used regardless of the value of this variable.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
669
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
670 menu-force is used to indicate that the menu accelerator key takes
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
671 precedence over bindings in the current keymap(s). menu-fallback means
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
672 that bindings in the current keymap take precedence over menu accelerator keys.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
673 Thus a top level menu with an accelerator of "T" would be activated on a
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
674 keypress of Meta-t if menu-accelerator-enabled is menu-force.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
675 However, if menu-accelerator-enabled is menu-fallback, then
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
676 Meta-t will not activate the menubar and will instead run the function
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
677 transpose-words, to which it is normally bound.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
678
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
679 See also menu-accelerator-modifiers and menu-accelerator-prefix.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
680 */ );
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
681 Vmenu_accelerator_enabled = Qnil;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
682
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
683 DEFVAR_LISP ("menu-accelerator-map", &Vmenu_accelerator_map /*
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
684 Keymap for use when the menubar is active.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
685 The actions menu-quit, menu-up, menu-down, menu-left, menu-right,
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
686 menu-select and menu-escape can be mapped to keys in this map.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
687 NOTE: This currently only has any effect under X Windows.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
688
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
689 menu-quit Immediately deactivate the menubar and any open submenus without
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
690 selecting an item.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
691 menu-up Move the menu cursor up one row in the current menu. If the
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
692 move extends past the top of the menu, wrap around to the bottom.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
693 menu-down Move the menu cursor down one row in the current menu. If the
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
694 move extends past the bottom of the menu, wrap around to the top.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
695 If executed while the cursor is in the top level menu, move down
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
696 into the selected menu.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
697 menu-left Move the cursor from a submenu into the parent menu. If executed
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
698 while the cursor is in the top level menu, move the cursor to the
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
699 left. If the move extends past the left edge of the menu, wrap
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
700 around to the right edge.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
701 menu-right Move the cursor into a submenu. If the cursor is located in the
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
702 top level menu or is not currently on a submenu heading, then move
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
703 the cursor to the next top level menu entry. If the move extends
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
704 past the right edge of the menu, wrap around to the left edge.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
705 menu-select Activate the item under the cursor. If the cursor is located on
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
706 a submenu heading, then move the cursor into the submenu.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
707 menu-escape Pop up to the next level of menus. Moves from a submenu into its
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
708 parent menu. From the top level menu, this deactivates the
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
709 menubar.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
710
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
711 This keymap can also contain normal key-command bindings, in which case the
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
712 menubar is deactivated and the corresponding command is executed.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
713
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
714 The action bindings used by the menu accelerator code are designed to mimic
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
715 the actions of menu traversal keys in a commonly used PC operating system.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
716 */ );
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
717
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 Fprovide (intern ("menubar"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 specifier_vars_of_menubar (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 DEFVAR_SPECIFIER ("menubar-visible-p", &Vmenubar_visible_p /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 *Whether the menubar is visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 This is a specifier; use `set-specifier' to change it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 Vmenubar_visible_p = Fmake_specifier (Qboolean);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 set_specifier_fallback (Vmenubar_visible_p, list1 (Fcons (Qnil, Qt)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 set_specifier_caching (Vmenubar_visible_p,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
732 offsetof (struct window, menubar_visible_p),
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 menubar_visible_p_changed,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
734 offsetof (struct frame, menubar_visible_p),
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 menubar_visible_p_changed_in_frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 complex_vars_of_menubar (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 Vmenubar_pointer_glyph = Fmake_glyph_internal (Qpointer);
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
742
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
743 Vmenu_accelerator_map = Fmake_keymap (Qnil);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 }