Mercurial > emacs
annotate src/xmenu.c @ 4022:a3d3d7eef5ce
(mail-rfc822-time-zone, mail-rfc822-date): New fns.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 07 Jul 1993 17:55:55 +0000 |
parents | 6506b2fd475a |
children | 340c18d50337 |
rev | line source |
---|---|
118 | 1 /* X Communication module for terminals which understand the X protocol. |
2961 | 2 Copyright (C) 1986, 1988, 1993 Free Software Foundation, Inc. |
118 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
1437
36ef55ecb265
* frame.c (make_frame_without_minibuffer, Fwindow_frame): Use
Jim Blandy <jimb@redhat.com>
parents:
1304
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option) |
118 | 9 any later version. |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | |
20 /* X pop-up deck-of-cards menu facility for gnuemacs. | |
21 * | |
22 * Written by Jon Arnold and Roman Budzianowski | |
23 * Mods and rewrite by Robert Krawitz | |
24 * | |
25 */ | |
26 | |
27 #ifdef XDEBUG | |
28 #include <stdio.h> | |
29 #endif | |
30 | |
31 /* On 4.3 this loses if it comes after xterm.h. */ | |
32 #include <signal.h> | |
33 #include "config.h" | |
34 #include "lisp.h" | |
770 | 35 #include "frame.h" |
118 | 36 #include "window.h" |
1304
93d55019750e
* xmenu.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1213
diff
changeset
|
37 #include "keyboard.h" |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2209
diff
changeset
|
38 #include "blockinput.h" |
118 | 39 |
40 /* This may include sys/types.h, and that somehow loses | |
41 if this is not done before the other system files. */ | |
42 #include "xterm.h" | |
43 | |
44 /* Load sys/types.h if not already loaded. | |
45 In some systems loading it twice is suicidal. */ | |
46 #ifndef makedev | |
47 #include <sys/types.h> | |
48 #endif | |
49 | |
50 #include "dispextern.h" | |
51 | |
52 #ifdef HAVE_X11 | |
53 #include "../oldXMenu/XMenu.h" | |
54 #else | |
55 #include <X/XMenu.h> | |
56 #endif | |
57 | |
58 #define min(x,y) (((x) < (y)) ? (x) : (y)) | |
59 #define max(x,y) (((x) > (y)) ? (x) : (y)) | |
60 | |
61 #define NUL 0 | |
62 | |
63 #ifndef TRUE | |
64 #define TRUE 1 | |
65 #define FALSE 0 | |
3270
0c9a88fe24c9
* sysdep.c (sys_siglist): Comment out #endif trailer.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
66 #endif /* TRUE */ |
118 | 67 |
68 #ifdef HAVE_X11 | |
69 extern Display *x_current_display; | |
70 #else | |
71 #define ButtonReleaseMask ButtonReleased | |
72 #endif /* not HAVE_X11 */ | |
73 | |
2514
6700e25af205
Since Qmenu_enable is used by non-X-specific code, it shouldn't be
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
74 extern Lisp_Object Qmenu_enable; |
118 | 75 Lisp_Object xmenu_show (); |
76 extern int x_error_handler (); | |
77 | |
78 /*************************************************************/ | |
79 | |
80 #if 0 | |
81 /* Ignoring the args is easiest. */ | |
82 xmenu_quit () | |
83 { | |
84 error ("Unknown XMenu error"); | |
85 } | |
86 #endif | |
87 | |
88 DEFUN ("x-popup-menu",Fx_popup_menu, Sx_popup_menu, 1, 2, 0, | |
89 "Pop up a deck-of-cards menu and return user's selection.\n\ | |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
90 POSITION is a position specification. This is either a mouse button event\n\ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
91 or a list ((XOFFSET YOFFSET) WINDOW)\n\ |
118 | 92 where XOFFSET and YOFFSET are positions in characters from the top left\n\ |
2147
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
93 corner of WINDOW's frame. (WINDOW may be a frame object instead of a window.)\n\ |
118 | 94 This controls the position of the center of the first line\n\ |
95 in the first pane of the menu, not the top left of the menu as a whole.\n\ | |
96 \n\ | |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
97 MENU is a specifier for a menu. For the simplest case, MENU is a keymap.\n\ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
98 The menu items come from key bindings that have a menu string as well as\n\ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
99 a definition; actually, the \"definition\" in such a key binding looks like\n\ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
100 \(STRING . REAL-DEFINITION). To give the menu a title, put a string into\n\ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
101 the keymap as a top-level element.\n\n\ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
102 You can also use a list of keymaps as MENU.\n\ |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
103 Then each keymap makes a separate pane.\n\ |
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
104 When MENU is a keymap or a list of keymaps, the return value\n\ |
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
105 is a list of events.\n\n\ |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
106 Alternatively, you can specify a menu of multiple panes\n\ |
2191
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
107 with a list of the form (TITLE PANE1 PANE2...),\n\ |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
108 where each pane is a list of form (TITLE ITEM1 ITEM2...).\n\ |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
109 Each ITEM is normally a cons cell (STRING . VALUE);\n\ |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
110 but a string can appear as an item--that makes a nonselectable line\n\ |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
111 in the menu.\n\ |
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
112 With this form of menu, the return value is VALUE from the chosen item.") |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
113 (position, menu) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
114 Lisp_Object position, menu; |
118 | 115 { |
116 int number_of_panes; | |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
117 Lisp_Object XMenu_return, keymap, tem; |
118 | 118 int XMenu_xpos, XMenu_ypos; |
119 char **menus; | |
120 char ***names; | |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
121 int **enables; |
118 | 122 Lisp_Object **obj_list; |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
123 Lisp_Object *prefixes; |
118 | 124 int *items; |
125 char *title; | |
126 char *error_name; | |
127 Lisp_Object ltitle, selection; | |
128 int i, j; | |
770 | 129 FRAME_PTR f; |
118 | 130 Lisp_Object x, y, window; |
131 | |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
132 /* Decode the first argument: find the window and the coordinates. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
133 tem = Fcar (position); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
134 if (XTYPE (tem) == Lisp_Cons) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
135 { |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
136 window = Fcar (Fcdr (position)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
137 x = Fcar (tem); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
138 y = Fcar (Fcdr (tem)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
139 } |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
140 else |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
141 { |
2153
42ceb87b43a1
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2147
diff
changeset
|
142 tem = Fcar (Fcdr (position)); /* EVENT_START (position) */ |
42ceb87b43a1
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2147
diff
changeset
|
143 window = Fcar (tem); /* POSN_WINDOW (tem) */ |
42ceb87b43a1
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2147
diff
changeset
|
144 tem = Fcar (Fcdr (Fcdr (tem))); /* POSN_WINDOW_POSN (tem) */ |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
145 x = Fcar (tem); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
146 y = Fcdr (tem); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
147 } |
118 | 148 CHECK_NUMBER (x, 0); |
149 CHECK_NUMBER (y, 0); | |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
150 |
2147
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
151 if (XTYPE (window) == Lisp_Frame) |
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
152 { |
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
153 f = XFRAME (window); |
118 | 154 |
2147
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
155 XMenu_xpos = 0; |
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
156 XMenu_ypos = 0; |
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
157 } |
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
158 else if (XTYPE (window) == Lisp_Window) |
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
159 { |
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
160 CHECK_LIVE_WINDOW (window, 0); |
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
161 f = XFRAME (WINDOW_FRAME (XWINDOW (window))); |
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
162 |
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
163 XMenu_xpos = FONT_WIDTH (f->display.x->font) * XWINDOW (window)->left; |
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
164 XMenu_ypos = FONT_HEIGHT (f->display.x->font) * XWINDOW (window)->top; |
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
165 } |
3501
33a309357161
(Fx_popup_menu): Error if we don't get a window or a frame somehow.
Richard M. Stallman <rms@gnu.org>
parents:
3270
diff
changeset
|
166 else |
33a309357161
(Fx_popup_menu): Error if we don't get a window or a frame somehow.
Richard M. Stallman <rms@gnu.org>
parents:
3270
diff
changeset
|
167 /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME, |
33a309357161
(Fx_popup_menu): Error if we don't get a window or a frame somehow.
Richard M. Stallman <rms@gnu.org>
parents:
3270
diff
changeset
|
168 but I don't want to make one now. */ |
33a309357161
(Fx_popup_menu): Error if we don't get a window or a frame somehow.
Richard M. Stallman <rms@gnu.org>
parents:
3270
diff
changeset
|
169 CHECK_WINDOW (window, 0); |
2147
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
170 |
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
171 XMenu_xpos += FONT_WIDTH (f->display.x->font) * XINT (x); |
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
172 XMenu_ypos += FONT_HEIGHT (f->display.x->font) * XINT (y); |
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
173 |
770 | 174 XMenu_xpos += f->display.x->left_pos; |
175 XMenu_ypos += f->display.x->top_pos; | |
118 | 176 |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
177 keymap = Fkeymapp (menu); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
178 tem = Qnil; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
179 if (XTYPE (menu) == Lisp_Cons) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
180 tem = Fkeymapp (Fcar (menu)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
181 if (!NILP (keymap)) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
182 { |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
183 /* We were given a keymap. Extract menu info from the keymap. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
184 Lisp_Object prompt; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
185 keymap = get_keymap (menu); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
186 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
187 /* Search for a string appearing directly as an element of the keymap. |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
188 That string is the title of the menu. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
189 prompt = map_prompt (keymap); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
190 if (!NILP (prompt)) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
191 title = (char *) XSTRING (prompt)->data; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
192 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
193 /* Extract the detailed info to make one pane. */ |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
194 number_of_panes = keymap_panes (&obj_list, &menus, &names, &enables, |
3747
6506b2fd475a
(xmenu_show): Store 0 in *ERROR at the beginning.
Richard M. Stallman <rms@gnu.org>
parents:
3501
diff
changeset
|
195 &items, &prefixes, &menu, 1); |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
196 /* The menu title seems to be ignored, |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
197 so put it in the pane title. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
198 if (menus[0] == 0) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
199 menus[0] = title; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
200 } |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
201 else if (!NILP (tem)) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
202 { |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
203 /* We were given a list of keymaps. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
204 Lisp_Object prompt; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
205 int nmaps = XFASTINT (Flength (menu)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
206 Lisp_Object *maps |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
207 = (Lisp_Object *) alloca (nmaps * sizeof (Lisp_Object)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
208 int i; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
209 title = 0; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
210 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
211 /* The first keymap that has a prompt string |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
212 supplies the menu title. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
213 for (tem = menu, i = 0; XTYPE (tem) == Lisp_Cons; tem = Fcdr (tem)) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
214 { |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
215 maps[i++] = keymap = get_keymap (Fcar (tem)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
216 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
217 prompt = map_prompt (keymap); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
218 if (title == 0 && !NILP (prompt)) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
219 title = (char *) XSTRING (prompt)->data; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
220 } |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
221 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
222 /* Extract the detailed info to make one pane. */ |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
223 number_of_panes = keymap_panes (&obj_list, &menus, &names, &enables, |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
224 &items, &prefixes, maps, nmaps); |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
225 /* The menu title seems to be ignored, |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
226 so put it in the pane title. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
227 if (menus[0] == 0) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
228 menus[0] = title; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
229 } |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
230 else |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
231 { |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
232 /* We were given an old-fashioned menu. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
233 ltitle = Fcar (menu); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
234 CHECK_STRING (ltitle, 1); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
235 title = (char *) XSTRING (ltitle)->data; |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
236 prefixes = 0; |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
237 number_of_panes = list_of_panes (&obj_list, &menus, &names, &enables, |
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
238 &items, Fcdr (menu)); |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
239 } |
118 | 240 #ifdef XDEBUG |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
241 fprintf (stderr, "Panes = %d\n", number_of_panes); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
242 for (i = 0; i < number_of_panes; i++) |
118 | 243 { |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
244 fprintf (stderr, "Pane %d has lines %d title %s\n", |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
245 i, items[i], menus[i]); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
246 for (j = 0; j < items[i]; j++) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
247 fprintf (stderr, " Item %d %s\n", j, names[i][j]); |
118 | 248 } |
249 #endif | |
250 BLOCK_INPUT; | |
1828
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
251 { |
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
252 Window root; |
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
253 int root_x, root_y; |
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
254 int dummy_int; |
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
255 unsigned int dummy_uint; |
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
256 Window dummy_window; |
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
257 |
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
258 /* Figure out which root window F is on. */ |
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
259 XGetGeometry (x_current_display, FRAME_X_WINDOW (f), &root, |
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
260 &dummy_int, &dummy_int, &dummy_uint, &dummy_uint, |
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
261 &dummy_uint, &dummy_uint); |
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
262 |
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
263 /* Translate the menu co-ordinates within f to menu co-ordinates |
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
264 on that root window. */ |
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
265 if (! XTranslateCoordinates (x_current_display, |
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
266 FRAME_X_WINDOW (f), root, |
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
267 XMenu_xpos, XMenu_ypos, &root_x, &root_y, |
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
268 &dummy_window)) |
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
269 /* But XGetGeometry said root was the root window of f's screen! */ |
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
270 abort (); |
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
271 |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
272 selection = xmenu_show (root, XMenu_xpos, XMenu_ypos, names, enables, |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
273 menus, prefixes, items, number_of_panes, obj_list, |
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
274 title, &error_name); |
1828
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
275 } |
118 | 276 UNBLOCK_INPUT; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
277 /* fprintf (stderr, "selection = %x\n", selection); */ |
118 | 278 if (selection != NUL) |
279 { /* selected something */ | |
280 XMenu_return = selection; | |
281 } | |
282 else | |
283 { /* nothing selected */ | |
284 XMenu_return = Qnil; | |
285 } | |
286 /* now free up the strings */ | |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
287 for (i = 0; i < number_of_panes; i++) |
118 | 288 { |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2209
diff
changeset
|
289 xfree (names[i]); |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2209
diff
changeset
|
290 xfree (enables[i]); |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2209
diff
changeset
|
291 xfree (obj_list[i]); |
118 | 292 } |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2209
diff
changeset
|
293 xfree (menus); |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2209
diff
changeset
|
294 xfree (obj_list); |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2209
diff
changeset
|
295 xfree (names); |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2209
diff
changeset
|
296 xfree (enables); |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2209
diff
changeset
|
297 xfree (items); |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
298 /* free (title); */ |
118 | 299 if (error_name) error (error_name); |
300 return XMenu_return; | |
301 } | |
302 | |
303 struct indices { | |
304 int pane; | |
305 int line; | |
306 }; | |
307 | |
308 Lisp_Object | |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
309 xmenu_show (parent, startx, starty, line_list, enable_list, pane_list, |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
310 prefixes, line_cnt, pane_cnt, item_list, title, error) |
118 | 311 Window parent; |
312 int startx, starty; /* upper left corner position BROKEN */ | |
313 char **line_list[]; /* list of strings for items */ | |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
314 int *enable_list[]; /* list of strings for items */ |
118 | 315 char *pane_list[]; /* list of pane titles */ |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
316 Lisp_Object *prefixes; /* Prefix key for each pane */ |
118 | 317 char *title; |
318 int pane_cnt; /* total number of panes */ | |
319 Lisp_Object *item_list[]; /* All items */ | |
320 int line_cnt[]; /* Lines in each pane */ | |
321 char **error; /* Error returned */ | |
322 { | |
323 XMenu *GXMenu; | |
324 int last, panes, selidx, lpane, status; | |
325 int lines, sofar; | |
326 Lisp_Object entry; | |
327 /* struct indices *datap, *datap_save; */ | |
328 char *datap; | |
329 int ulx, uly, width, height; | |
330 int dispwidth, dispheight; | |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
331 |
3747
6506b2fd475a
(xmenu_show): Store 0 in *ERROR at the beginning.
Richard M. Stallman <rms@gnu.org>
parents:
3501
diff
changeset
|
332 *error = 0; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
333 if (pane_cnt == 0) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
334 return 0; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
335 |
2209
7b95f29936cb
(xmenu_show): Do BLOCK_INPUT; unblock just before returning.
Richard M. Stallman <rms@gnu.org>
parents:
2191
diff
changeset
|
336 BLOCK_INPUT; |
118 | 337 *error = (char *) 0; /* Initialize error pointer to null */ |
338 GXMenu = XMenuCreate (XDISPLAY parent, "emacs"); | |
339 if (GXMenu == NUL) | |
340 { | |
341 *error = "Can't create menu"; | |
2209
7b95f29936cb
(xmenu_show): Do BLOCK_INPUT; unblock just before returning.
Richard M. Stallman <rms@gnu.org>
parents:
2191
diff
changeset
|
342 UNBLOCK_INPUT; |
118 | 343 return (0); |
344 } | |
345 | |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
346 for (panes = 0, lines = 0; panes < pane_cnt; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
347 lines += line_cnt[panes], panes++) |
118 | 348 ; |
349 /* datap = (struct indices *) xmalloc (lines * sizeof (struct indices)); */ | |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
350 /* datap = (char *) xmalloc (lines * sizeof (char)); |
118 | 351 datap_save = datap;*/ |
352 | |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
353 for (panes = 0, sofar = 0; panes < pane_cnt; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
354 sofar += line_cnt[panes], panes++) |
118 | 355 { |
356 /* create all the necessary panes */ | |
357 lpane = XMenuAddPane (XDISPLAY GXMenu, pane_list[panes], TRUE); | |
358 if (lpane == XM_FAILURE) | |
359 { | |
360 XMenuDestroy (XDISPLAY GXMenu); | |
361 *error = "Can't create pane"; | |
2209
7b95f29936cb
(xmenu_show): Do BLOCK_INPUT; unblock just before returning.
Richard M. Stallman <rms@gnu.org>
parents:
2191
diff
changeset
|
362 UNBLOCK_INPUT; |
118 | 363 return (0); |
364 } | |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
365 for (selidx = 0; selidx < line_cnt[panes]; selidx++) |
118 | 366 { |
367 /* add the selection stuff to the menus */ | |
368 /* datap[selidx+sofar].pane = panes; | |
369 datap[selidx+sofar].line = selidx; */ | |
370 if (XMenuAddSelection (XDISPLAY GXMenu, lpane, 0, | |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
371 line_list[panes][selidx], |
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
372 enable_list[panes][selidx]) |
118 | 373 == XM_FAILURE) |
374 { | |
375 XMenuDestroy (XDISPLAY GXMenu); | |
376 /* free (datap); */ | |
377 *error = "Can't add selection to menu"; | |
378 /* error ("Can't add selection to menu"); */ | |
2209
7b95f29936cb
(xmenu_show): Do BLOCK_INPUT; unblock just before returning.
Richard M. Stallman <rms@gnu.org>
parents:
2191
diff
changeset
|
379 UNBLOCK_INPUT; |
118 | 380 return (0); |
381 } | |
382 } | |
383 } | |
384 /* all set and ready to fly */ | |
385 XMenuRecompute (XDISPLAY GXMenu); | |
386 dispwidth = DisplayWidth (x_current_display, XDefaultScreen (x_current_display)); | |
387 dispheight = DisplayHeight (x_current_display, XDefaultScreen (x_current_display)); | |
388 startx = min (startx, dispwidth); | |
389 starty = min (starty, dispheight); | |
390 startx = max (startx, 1); | |
391 starty = max (starty, 1); | |
392 XMenuLocate (XDISPLAY GXMenu, 0, 0, startx, starty, | |
393 &ulx, &uly, &width, &height); | |
394 if (ulx+width > dispwidth) | |
395 { | |
396 startx -= (ulx + width) - dispwidth; | |
397 ulx = dispwidth - width; | |
398 } | |
399 if (uly+height > dispheight) | |
400 { | |
401 starty -= (uly + height) - dispheight; | |
402 uly = dispheight - height; | |
403 } | |
404 if (ulx < 0) startx -= ulx; | |
405 if (uly < 0) starty -= uly; | |
406 | |
407 XMenuSetFreeze (GXMenu, TRUE); | |
408 panes = selidx = 0; | |
409 | |
410 status = XMenuActivate (XDISPLAY GXMenu, &panes, &selidx, | |
411 startx, starty, ButtonReleaseMask, &datap); | |
412 switch (status) | |
413 { | |
414 case XM_SUCCESS: | |
415 #ifdef XDEBUG | |
416 fprintf (stderr, "pane= %d line = %d\n", panes, selidx); | |
417 #endif | |
418 entry = item_list[panes][selidx]; | |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
419 if (prefixes != 0) |
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
420 { |
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
421 entry = Fcons (entry, Qnil); |
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
422 if (!NILP (prefixes[panes])) |
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
423 entry = Fcons (prefixes[panes], entry); |
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
424 } |
118 | 425 break; |
426 case XM_FAILURE: | |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
427 /* free (datap_save); */ |
118 | 428 XMenuDestroy (XDISPLAY GXMenu); |
429 *error = "Can't activate menu"; | |
430 /* error ("Can't activate menu"); */ | |
431 case XM_IA_SELECT: | |
432 case XM_NO_SELECT: | |
433 entry = Qnil; | |
434 break; | |
435 } | |
436 XMenuDestroy (XDISPLAY GXMenu); | |
2209
7b95f29936cb
(xmenu_show): Do BLOCK_INPUT; unblock just before returning.
Richard M. Stallman <rms@gnu.org>
parents:
2191
diff
changeset
|
437 UNBLOCK_INPUT; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
438 /* free (datap_save);*/ |
118 | 439 return (entry); |
440 } | |
441 | |
442 syms_of_xmenu () | |
443 { | |
444 defsubr (&Sx_popup_menu); | |
445 } | |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
446 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
447 /* Construct the vectors that describe a menu |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
448 and store them in *VECTOR, *PANES, *NAMES, *ENABLES and *ITEMS. |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
449 Each of those four values is a vector indexed by pane number. |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
450 Return the number of panes. |
118 | 451 |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
452 KEYMAPS is a vector of keymaps. NMAPS gives the length of KEYMAPS. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
453 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
454 int |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
455 keymap_panes (vector, panes, names, enables, items, prefixes, keymaps, nmaps) |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
456 Lisp_Object ***vector; /* RETURN all menu objects */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
457 char ***panes; /* RETURN pane names */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
458 char ****names; /* RETURN all line names */ |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
459 int ***enables; /* RETURN enable-flags of lines */ |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
460 int **items; /* RETURN number of items per pane */ |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
461 Lisp_Object **prefixes; /* RETURN vector of prefix keys, per pane */ |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
462 Lisp_Object *keymaps; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
463 int nmaps; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
464 { |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
465 /* Number of panes we have made. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
466 int p = 0; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
467 /* Number of panes we have space for. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
468 int npanes_allocated = nmaps; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
469 int mapno; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
470 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
471 if (npanes_allocated < 4) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
472 npanes_allocated = 4; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
473 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
474 /* Make space for an estimated number of panes. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
475 *vector = (Lisp_Object **) xmalloc (npanes_allocated * sizeof (Lisp_Object *)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
476 *panes = (char **) xmalloc (npanes_allocated * sizeof (char *)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
477 *items = (int *) xmalloc (npanes_allocated * sizeof (int)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
478 *names = (char ***) xmalloc (npanes_allocated * sizeof (char **)); |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
479 *enables = (int **) xmalloc (npanes_allocated * sizeof (int *)); |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
480 *prefixes = (Lisp_Object *) xmalloc (npanes_allocated * sizeof (Lisp_Object)); |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
481 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
482 /* Loop over the given keymaps, making a pane for each map. |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
483 But don't make a pane that is empty--ignore that map instead. |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
484 P is the number of panes we have made so far. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
485 for (mapno = 0; mapno < nmaps; mapno++) |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
486 single_keymap_panes (keymaps[mapno], panes, vector, names, enables, items, |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
487 prefixes, &p, &npanes_allocated, ""); |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
488 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
489 /* Return the number of panes. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
490 return p; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
491 } |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
492 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
493 /* This is a recursive subroutine of the previous function. |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
494 It handles one keymap, KEYMAP. |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
495 The other arguments are passed along |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
496 or point to local variables of the previous function. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
497 |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
498 single_keymap_panes (keymap, panes, vector, names, enables, items, prefixes, |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
499 p_ptr, npanes_allocated_ptr, pane_name) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
500 Lisp_Object keymap; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
501 Lisp_Object ***vector; /* RETURN all menu objects */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
502 char ***panes; /* RETURN pane names */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
503 char ****names; /* RETURN all line names */ |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
504 int ***enables; /* RETURN enable flags of lines */ |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
505 int **items; /* RETURN number of items per pane */ |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
506 Lisp_Object **prefixes; /* RETURN vector of prefix keys, per pane */ |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
507 int *p_ptr; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
508 int *npanes_allocated_ptr; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
509 char *pane_name; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
510 { |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
511 int i; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
512 Lisp_Object pending_maps; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
513 Lisp_Object tail, item, item1, item2, table; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
514 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
515 pending_maps = Qnil; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
516 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
517 /* Make sure we have room for another pane. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
518 if (*p_ptr == *npanes_allocated_ptr) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
519 { |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
520 *npanes_allocated_ptr *= 2; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
521 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
522 *vector |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
523 = (Lisp_Object **) xrealloc (*vector, |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
524 *npanes_allocated_ptr * sizeof (Lisp_Object *)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
525 *panes |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
526 = (char **) xrealloc (*panes, |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
527 *npanes_allocated_ptr * sizeof (char *)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
528 *items |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
529 = (int *) xrealloc (*items, |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
530 *npanes_allocated_ptr * sizeof (int)); |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
531 *prefixes |
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
532 = (Lisp_Object *) xrealloc (*prefixes, |
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
533 (*npanes_allocated_ptr |
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
534 * sizeof (Lisp_Object))); |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
535 *names |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
536 = (char ***) xrealloc (*names, |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
537 *npanes_allocated_ptr * sizeof (char **)); |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
538 *enables |
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
539 = (int **) xrealloc (*enables, |
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
540 *npanes_allocated_ptr * sizeof (int *)); |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
541 } |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
542 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
543 /* When a menu comes from keymaps, don't give names to the panes. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
544 (*panes)[*p_ptr] = pane_name; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
545 |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
546 /* Normally put nil as pane's prefix key. |
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
547 Caller will override this if appropriate. */ |
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
548 (*prefixes)[*p_ptr] = Qnil; |
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
549 |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
550 /* Get the length of the list level of the keymap. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
551 i = XFASTINT (Flength (keymap)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
552 |
1213
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
553 /* Add in lengths of any arrays. */ |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
554 for (tail = keymap; XTYPE (tail) == Lisp_Cons; tail = XCONS (tail)->cdr) |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
555 if (XTYPE (XCONS (tail)->car) == Lisp_Vector) |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
556 i += XVECTOR (XCONS (tail)->car)->size; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
557 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
558 /* Create vectors for the names and values of the items in the pane. |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
559 I is an upper bound for the number of items. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
560 (*vector)[*p_ptr] = (Lisp_Object *) xmalloc (i * sizeof (Lisp_Object)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
561 (*names)[*p_ptr] = (char **) xmalloc (i * sizeof (char *)); |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
562 (*enables)[*p_ptr] = (int *) xmalloc (i * sizeof (int)); |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
563 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
564 /* I is now the index of the next unused slots. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
565 i = 0; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
566 for (tail = keymap; XTYPE (tail) == Lisp_Cons; tail = XCONS (tail)->cdr) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
567 { |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
568 /* Look at each key binding, and if it has a menu string, |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
569 make a menu item from it. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
570 item = XCONS (tail)->car; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
571 if (XTYPE (item) == Lisp_Cons) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
572 { |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
573 item1 = XCONS (item)->cdr; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
574 if (XTYPE (item1) == Lisp_Cons) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
575 { |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
576 item2 = XCONS (item1)->car; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
577 if (XTYPE (item2) == Lisp_String) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
578 { |
2135
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
579 Lisp_Object def, tem; |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
580 Lisp_Object enabled; |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
581 |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
582 def = Fcdr (item1); |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
583 enabled = Qt; |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
584 if (XTYPE (def) == Lisp_Symbol) |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
585 { |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
586 /* No property, or nil, means enable. |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
587 Otherwise, enable if value is not nil. */ |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
588 tem = Fget (def, Qmenu_enable); |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
589 if (!NILP (tem)) |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
590 enabled = Feval (tem); |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
591 } |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
592 tem = Fkeymapp (def); |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
593 if (XSTRING (item2)->data[0] == '@' && !NILP (tem)) |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
594 pending_maps = Fcons (Fcons (def, Fcons (item2, XCONS (item)->car)), |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
595 pending_maps); |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
596 else |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
597 { |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
598 (*names)[*p_ptr][i] = (char *) XSTRING (item2)->data; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
599 /* The menu item "value" is the key bound here. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
600 (*vector)[*p_ptr][i] = XCONS (item)->car; |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
601 (*enables)[*p_ptr][i] |
2191
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
602 = (NILP (def) ? -1 : !NILP (enabled) ? 1 : 0); |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
603 i++; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
604 } |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
605 } |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
606 } |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
607 } |
1213
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
608 else if (XTYPE (item) == Lisp_Vector) |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
609 { |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
610 /* Loop over the char values represented in the vector. */ |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
611 int len = XVECTOR (item)->size; |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
612 int c; |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
613 for (c = 0; c < len; c++) |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
614 { |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
615 Lisp_Object character; |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
616 XFASTINT (character) = c; |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
617 item1 = XVECTOR (item)->contents[c]; |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
618 if (XTYPE (item1) == Lisp_Cons) |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
619 { |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
620 item2 = XCONS (item1)->car; |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
621 if (XTYPE (item2) == Lisp_String) |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
622 { |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
623 Lisp_Object tem; |
2135
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
624 Lisp_Object def; |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
625 Lisp_Object enabled; |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
626 |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
627 def = Fcdr (item1); |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
628 enabled = Qt; |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
629 if (XTYPE (def) == Lisp_Symbol) |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
630 { |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
631 tem = Fget (def, Qmenu_enable); |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
632 /* No property, or nil, means enable. |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
633 Otherwise, enable if value is not nil. */ |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
634 if (!NILP (tem)) |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
635 enabled = Feval (tem); |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
636 } |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
637 |
0634d08c28d1
(syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents:
1933
diff
changeset
|
638 tem = Fkeymapp (def); |
1213
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
639 if (XSTRING (item2)->data[0] == '@' && !NILP (tem)) |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
640 pending_maps = Fcons (Fcons (def, Fcons (item2, character)), |
1213
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
641 pending_maps); |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
642 else |
1213
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
643 { |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
644 (*names)[*p_ptr][i] = (char *) XSTRING (item2)->data; |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
645 /* The menu item "value" is the key bound here. */ |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
646 (*vector)[*p_ptr][i] = character; |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
647 (*enables)[*p_ptr][i] |
2191
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
648 = (NILP (def) ? -1 : !NILP (enabled) ? 1 : 0); |
1213
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
649 i++; |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
650 } |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
651 } |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
652 } |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
653 } |
0901fe62d97b
(single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents:
1210
diff
changeset
|
654 } |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
655 } |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
656 /* Record the number of items in the pane. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
657 (*items)[*p_ptr] = i; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
658 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
659 /* If we just made an empty pane, get rid of it. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
660 if (i == 0) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
661 { |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2209
diff
changeset
|
662 xfree ((*vector)[*p_ptr]); |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2209
diff
changeset
|
663 xfree ((*names)[*p_ptr]); |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2209
diff
changeset
|
664 xfree ((*enables)[*p_ptr]); |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
665 } |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
666 /* Otherwise, advance past it. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
667 else |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
668 (*p_ptr)++; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
669 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
670 /* Process now any submenus which want to be panes at this level. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
671 while (!NILP (pending_maps)) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
672 { |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
673 Lisp_Object elt, eltcdr; |
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
674 int panenum = *p_ptr; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
675 elt = Fcar (pending_maps); |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
676 eltcdr = XCONS (elt)->cdr; |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
677 single_keymap_panes (Fcar (elt), panes, vector, names, enables, items, |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
678 prefixes, p_ptr, npanes_allocated_ptr, |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
679 /* Add 1 to discard the @. */ |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
680 (char *) XSTRING (XCONS (eltcdr)->car)->data + 1); |
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
681 (*prefixes)[panenum] = XCONS (eltcdr)->cdr; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
682 pending_maps = Fcdr (pending_maps); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
683 } |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
684 } |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
685 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
686 /* Construct the vectors that describe a menu |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
687 and store them in *VECTOR, *PANES, *NAMES, *ENABLES and *ITEMS. |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
688 Each of those four values is a vector indexed by pane number. |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
689 Return the number of panes. |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
690 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
691 MENU is the argument that was given to Fx_popup_menu. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
692 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
693 int |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
694 list_of_panes (vector, panes, names, enables, items, menu) |
118 | 695 Lisp_Object ***vector; /* RETURN all menu objects */ |
696 char ***panes; /* RETURN pane names */ | |
697 char ****names; /* RETURN all line names */ | |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
698 int ***enables; /* RETURN enable flags of lines */ |
118 | 699 int **items; /* RETURN number of items per pane */ |
700 Lisp_Object menu; | |
701 { | |
702 Lisp_Object tail, item, item1; | |
703 int i; | |
704 | |
705 if (XTYPE (menu) != Lisp_Cons) menu = wrong_type_argument (Qlistp, menu); | |
706 | |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
707 i = XFASTINT (Flength (menu)); |
118 | 708 |
709 *vector = (Lisp_Object **) xmalloc (i * sizeof (Lisp_Object *)); | |
710 *panes = (char **) xmalloc (i * sizeof (char *)); | |
711 *items = (int *) xmalloc (i * sizeof (int)); | |
712 *names = (char ***) xmalloc (i * sizeof (char **)); | |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
713 *enables = (int **) xmalloc (i * sizeof (int *)); |
118 | 714 |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
715 for (i = 0, tail = menu; !NILP (tail); tail = Fcdr (tail), i++) |
118 | 716 { |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
717 item = Fcdr (Fcar (tail)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
718 if (XTYPE (item) != Lisp_Cons) (void) wrong_type_argument (Qlistp, item); |
118 | 719 #ifdef XDEBUG |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
720 fprintf (stderr, "list_of_panes check tail, i=%d\n", i); |
118 | 721 #endif |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
722 item1 = Fcar (Fcar (tail)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
723 CHECK_STRING (item1, 1); |
118 | 724 #ifdef XDEBUG |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
725 fprintf (stderr, "list_of_panes check pane, i=%d%s\n", i, |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
726 XSTRING (item1)->data); |
118 | 727 #endif |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
728 (*panes)[i] = (char *) XSTRING (item1)->data; |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
729 (*items)[i] = list_of_items ((*vector)+i, (*names)+i, (*enables)+i, item); |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
730 /* (*panes)[i] = (char *) xmalloc ((XSTRING (item1)->size)+1); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
731 bcopy (XSTRING (item1)->data, (*panes)[i], XSTRING (item1)->size + 1) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
732 ; */ |
118 | 733 } |
734 return i; | |
735 } | |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
736 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
737 /* Construct the lists of values and names for a single pane, from the |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
738 alist PANE. Put them in *VECTOR and *NAMES. Put the enable flags |
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
739 int *ENABLES. Return the number of items. */ |
118 | 740 |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
741 int |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
742 list_of_items (vector, names, enables, pane) |
118 | 743 Lisp_Object **vector; /* RETURN menu "objects" */ |
744 char ***names; /* RETURN line names */ | |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
745 int **enables; /* RETURN enable flags of lines */ |
118 | 746 Lisp_Object pane; |
747 { | |
748 Lisp_Object tail, item, item1; | |
749 int i; | |
750 | |
751 if (XTYPE (pane) != Lisp_Cons) pane = wrong_type_argument (Qlistp, pane); | |
752 | |
1933
63ba4f555b90
* minibuf.c (Fdisplay_completion_list): Pass the proper number of
Jim Blandy <jimb@redhat.com>
parents:
1828
diff
changeset
|
753 i = XFASTINT (Flength (pane)); |
118 | 754 |
755 *vector = (Lisp_Object *) xmalloc (i * sizeof (Lisp_Object)); | |
756 *names = (char **) xmalloc (i * sizeof (char *)); | |
2160
0639c52f017c
(xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents:
2153
diff
changeset
|
757 *enables = (int *) xmalloc (i * sizeof (int)); |
118 | 758 |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
759 for (i = 0, tail = pane; !NILP (tail); tail = Fcdr (tail), i++) |
118 | 760 { |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
761 item = Fcar (tail); |
2191
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
762 if (STRINGP (item)) |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
763 { |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
764 (*vector)[i] = Qnil; |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
765 (*names)[i] = (char *) XSTRING (item)->data; |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
766 (*enables)[i] = -1; |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
767 } |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
768 else |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
769 { |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
770 CHECK_CONS (item, 0); |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
771 (*vector)[i] = Fcdr (item); |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
772 item1 = Fcar (item); |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
773 CHECK_STRING (item1, 1); |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
774 (*names)[i] = (char *) XSTRING (item1)->data; |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
775 (*enables)[i] = 1; |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
776 } |
118 | 777 } |
778 return i; | |
779 } |