annotate src/xmenu.c @ 2439:b6c62e4abf59

Put interrupt input blocking in a separate file from xterm.h. This isn't specific to X, and it allows us to avoid #including xterm.h in files that don't really have anything to do with X. * blockinput.h: New file. * xterm.h (BLOCK_INPUT, UNBLOCK_INPUT, TOTALLY_UNBLOCK_INPUT, UNBLOCK_INPUT_RESIGNAL): These are now in blockinput.h. (x_input_blocked, x_pending_input): Deleted; there are analogs in blockinput.h called interrupt_input_blocked and interrupt_input_pending. * keyboard.c (interrupt_input_blocked, interrupt_input_pending): New variables, used by the macros in blockinput.h. * xterm.c: #include blockinput.h. (x_input_blocked, x_pending_input): Deleted. (XTread_socket): Test and set interrupt_input_blocked and interrupt_input_pending instead of the old variables. * alloc.c, xfaces.c, xfns.c, xmenu.c, xselect.c, keymap.c: #include blockinput.h. * eval.c: #include blockinput.h instead of xterm.h. * keyboard.c: #include blockinput.h. (input_poll_signal): Just test interrupt_input_blocked, instead of testing HAVE_X_WINDOWS and x_input_blocked. Block the processing of interrupt input while we're manipulating the malloc heap. * alloc.c: (xfree): New function, to make it easy to free things safely. (xmalloc, xrealloc): Block X input while doing the deed. (VALIDATE_LISP_STORAGE, gc_sweep, compact_strings): Use xfree instead of free. (uninterrupt_malloc): New function, to install input-blocking hooks into the GNU malloc routines. * emacs.c [not SYSTEM_MALLOC] (main): Call uninterrupt_malloc on startup. * alloc.c: (make_interval, make_float, Fcons, Fmake_vector, Fmake_symbol, Fmake_marker, make_uninit_string, Fgarbage_collect): Use xmalloc instead of malloc; don't bother to check if out of memory here. (Fgarbage_collect): Call xrealloc instead of realloc. * buffer.c: Use xmalloc and xfree instead of malloc and free; don't bother to check if out of memory here. (Fget_buffer_create): Put BLOCK_INPUT/UNBLOCK_INPUT pair around calls to ralloc routines. * insdel.c: Same. * lisp.h (xfree): New extern declaration. * xfaces.c (xfree): Don't #define this to be free; use the definition in alloc.c. * dispnew.c, doc.c, doprnt.c, fileio.c, lread.c, term.c, xfns.c, xmenu.c, xterm.c: Use xfree instead of free. * hftctl.c: Use xfree and xmalloc instead of free and malloc. * keymap.c (current_minor_maps): BLOCK_INPUT while calling realloc and malloc. * search.c: Since the regexp routines can malloc, BLOCK_INPUT while runing them. #include blockinput.h. * sysdep.c: #include blockinput.h. Call xfree and xmalloc instead of free and malloc. BLOCK_INPUT around routines which we know will call malloc. ymakefile (keyboard.o, keymap.o, search.o, sysdep.o, xfaces.o, xfns.o, xmenu.o, xterm.o, xselect.o, alloc.o, eval.o): Note that these depend on blockinput.h.
author Jim Blandy <jimb@redhat.com>
date Wed, 31 Mar 1993 10:55:33 +0000
parents 7b95f29936cb
children 6700e25af205
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 /* X Communication module for terminals which understand the X protocol.
1437
36ef55ecb265 * frame.c (make_frame_without_minibuffer, Fwindow_frame): Use
Jim Blandy <jimb@redhat.com>
parents: 1304
diff changeset
2 Copyright (C) 1986, 1988, 1992 Free Software Foundation, Inc.
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4 This file is part of GNU Emacs.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 any later version.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 GNU General Public License for more details.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 /* X pop-up deck-of-cards menu facility for gnuemacs.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 *
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 * Written by Jon Arnold and Roman Budzianowski
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 * Mods and rewrite by Robert Krawitz
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 *
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 #ifdef XDEBUG
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 #include <stdio.h>
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 #endif
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 /* On 4.3 this loses if it comes after xterm.h. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 #include <signal.h>
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 #include "config.h"
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 #include "lisp.h"
770
4de9c9a62bda entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
35 #include "frame.h"
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 /* This may include sys/types.h, and that somehow loses
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 if this is not done before the other system files. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 #include "xterm.h"
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 /* Load sys/types.h if not already loaded.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 In some systems loading it twice is suicidal. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 #ifndef makedev
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 #include <sys/types.h>
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 #endif
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 #include "dispextern.h"
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 #ifdef HAVE_X11
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 #include "../oldXMenu/XMenu.h"
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 #else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 #include <X/XMenu.h>
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 #endif
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 #define min(x,y) (((x) < (y)) ? (x) : (y))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 #define max(x,y) (((x) > (y)) ? (x) : (y))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 #define NUL 0
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 #ifndef TRUE
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 #define TRUE 1
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 #define FALSE 0
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 #endif TRUE
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 #ifdef HAVE_X11
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 extern Display *x_current_display;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 #else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 #define ButtonReleaseMask ButtonReleased
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 #endif /* not HAVE_X11 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73
2135
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
74 Lisp_Object Qmenu_enable;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 Lisp_Object xmenu_show ();
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 extern int x_error_handler ();
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 /*************************************************************/
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 #if 0
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 /* Ignoring the args is easiest. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 xmenu_quit ()
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 error ("Unknown XMenu error");
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 #endif
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 DEFUN ("x-popup-menu",Fx_popup_menu, Sx_popup_menu, 1, 2, 0,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 This controls the position of the center of the first line\n\
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 in the first pane of the menu, not the top left of the menu as a whole.\n\
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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\
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
103 Then each keymap makes a separate pane.\n\n\
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
104 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
105 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
106 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
107 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
108 but a string can appear as an item--that makes a nonselectable line\n\
12480fa04422 (list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents: 2160
diff changeset
109 in the menu.")
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
110 (position, menu)
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
111 Lisp_Object position, menu;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 int number_of_panes;
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
114 Lisp_Object XMenu_return, keymap, tem;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 int XMenu_xpos, XMenu_ypos;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 char **menus;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 char ***names;
2160
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
118 int **enables;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 Lisp_Object **obj_list;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 int *items;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 char *title;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 char *error_name;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 Lisp_Object ltitle, selection;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 int i, j;
770
4de9c9a62bda entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
125 FRAME_PTR f;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 Lisp_Object x, y, window;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
128 /* 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
129 tem = Fcar (position);
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
130 if (XTYPE (tem) == Lisp_Cons)
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
131 {
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
132 window = Fcar (Fcdr (position));
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
133 x = Fcar (tem);
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
134 y = Fcar (Fcdr (tem));
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 else
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
137 {
2153
42ceb87b43a1 (Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents: 2147
diff changeset
138 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
139 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
140 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
141 x = Fcar (tem);
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
142 y = Fcdr (tem);
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
143 }
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 CHECK_NUMBER (x, 0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 CHECK_NUMBER (y, 0);
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
146
2147
1b6e54507323 (Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents: 2135
diff changeset
147 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
148 {
1b6e54507323 (Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents: 2135
diff changeset
149 f = XFRAME (window);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
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 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
152 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
153 }
1b6e54507323 (Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents: 2135
diff changeset
154 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
155 {
1b6e54507323 (Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents: 2135
diff changeset
156 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
157 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
158
1b6e54507323 (Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents: 2135
diff changeset
159 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
160 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
161 }
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) * 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
164 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
165
770
4de9c9a62bda entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
166 XMenu_xpos += f->display.x->left_pos;
4de9c9a62bda entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
167 XMenu_ypos += f->display.x->top_pos;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
169 keymap = Fkeymapp (menu);
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
170 tem = Qnil;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
171 if (XTYPE (menu) == Lisp_Cons)
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
172 tem = Fkeymapp (Fcar (menu));
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
173 if (!NILP (keymap))
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
174 {
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
175 /* 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
176 Lisp_Object prompt;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
177 keymap = get_keymap (menu);
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
178
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
179 /* 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
180 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
181 prompt = map_prompt (keymap);
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
182 if (!NILP (prompt))
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
183 title = (char *) XSTRING (prompt)->data;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
184
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
185 /* 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
186 number_of_panes = keymap_panes (&obj_list, &menus, &names, &enables,
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
187 &items, &menu, 1);
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
188 /* 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
189 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
190 if (menus[0] == 0)
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
191 menus[0] = title;
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 else if (!NILP (tem))
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
194 {
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
195 /* 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
196 Lisp_Object prompt;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
197 int nmaps = XFASTINT (Flength (menu));
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
198 Lisp_Object *maps
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
199 = (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
200 int i;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
201 title = 0;
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 /* 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
204 supplies the menu title. */
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
205 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
206 {
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
207 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
208
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
209 prompt = map_prompt (keymap);
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
210 if (title == 0 && !NILP (prompt))
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
211 title = (char *) XSTRING (prompt)->data;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
212 }
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
213
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
214 /* 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
215 number_of_panes = keymap_panes (&obj_list, &menus, &names, &enables,
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
216 &items, maps, nmaps);
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
217 /* 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
218 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
219 if (menus[0] == 0)
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
220 menus[0] = title;
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 else
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
223 {
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
224 /* 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
225 ltitle = Fcar (menu);
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
226 CHECK_STRING (ltitle, 1);
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
227 title = (char *) XSTRING (ltitle)->data;
2160
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
228 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
229 &items, Fcdr (menu));
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
230 }
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 #ifdef XDEBUG
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
232 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
233 for (i = 0; i < number_of_panes; i++)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 {
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
235 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
236 i, items[i], menus[i]);
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
237 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
238 fprintf (stderr, " Item %d %s\n", j, names[i][j]);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 #endif
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 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
242 {
1463592a6463 * xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
243 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
244 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
245 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
246 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
247 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
248
1463592a6463 * xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
249 /* 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
250 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
251 &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
252 &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
253
1463592a6463 * xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
254 /* 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
255 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
256 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
257 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
258 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
259 &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
260 /* 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
261 abort ();
1463592a6463 * xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
262
2160
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
263 selection = xmenu_show (root, XMenu_xpos, XMenu_ypos, names, enables,
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
264 menus, items, number_of_panes, obj_list, title,
1828
1463592a6463 * xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
265 &error_name);
1463592a6463 * xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
266 }
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 UNBLOCK_INPUT;
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
268 /* fprintf (stderr, "selection = %x\n", selection); */
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 if (selection != NUL)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 { /* selected something */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 XMenu_return = selection;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 { /* nothing selected */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 XMenu_return = Qnil;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 /* now free up the strings */
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
278 for (i = 0; i < number_of_panes; i++)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 {
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2209
diff changeset
280 xfree (names[i]);
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2209
diff changeset
281 xfree (enables[i]);
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2209
diff changeset
282 xfree (obj_list[i]);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 }
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2209
diff changeset
284 xfree (menus);
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2209
diff changeset
285 xfree (obj_list);
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2209
diff changeset
286 xfree (names);
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2209
diff changeset
287 xfree (enables);
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2209
diff changeset
288 xfree (items);
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
289 /* free (title); */
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 if (error_name) error (error_name);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 return XMenu_return;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 struct indices {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 int pane;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 int line;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297 };
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299 Lisp_Object
2160
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
300 xmenu_show (parent, startx, starty, line_list, enable_list, pane_list,
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
301 line_cnt, pane_cnt, item_list, title, error)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302 Window parent;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303 int startx, starty; /* upper left corner position BROKEN */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304 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
305 int *enable_list[]; /* list of strings for items */
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 char *pane_list[]; /* list of pane titles */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307 char *title;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308 int pane_cnt; /* total number of panes */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309 Lisp_Object *item_list[]; /* All items */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 int line_cnt[]; /* Lines in each pane */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 char **error; /* Error returned */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 XMenu *GXMenu;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 int last, panes, selidx, lpane, status;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315 int lines, sofar;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316 Lisp_Object entry;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317 /* struct indices *datap, *datap_save; */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318 char *datap;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319 int ulx, uly, width, height;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320 int dispwidth, dispheight;
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
321
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
322 if (pane_cnt == 0)
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
323 return 0;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
324
2209
7b95f29936cb (xmenu_show): Do BLOCK_INPUT; unblock just before returning.
Richard M. Stallman <rms@gnu.org>
parents: 2191
diff changeset
325 BLOCK_INPUT;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 *error = (char *) 0; /* Initialize error pointer to null */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 GXMenu = XMenuCreate (XDISPLAY parent, "emacs");
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 if (GXMenu == NUL)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 *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
331 UNBLOCK_INPUT;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 return (0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
335 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
336 lines += line_cnt[panes], panes++)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337 ;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338 /* 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
339 /* datap = (char *) xmalloc (lines * sizeof (char));
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 datap_save = datap;*/
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
342 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
343 sofar += line_cnt[panes], panes++)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 /* create all the necessary panes */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346 lpane = XMenuAddPane (XDISPLAY GXMenu, pane_list[panes], TRUE);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 if (lpane == XM_FAILURE)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 XMenuDestroy (XDISPLAY GXMenu);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 *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
351 UNBLOCK_INPUT;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352 return (0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 }
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
354 for (selidx = 0; selidx < line_cnt[panes]; selidx++)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 /* add the selection stuff to the menus */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 /* datap[selidx+sofar].pane = panes;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 datap[selidx+sofar].line = selidx; */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359 if (XMenuAddSelection (XDISPLAY GXMenu, lpane, 0,
2160
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
360 line_list[panes][selidx],
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
361 enable_list[panes][selidx])
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 == XM_FAILURE)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364 XMenuDestroy (XDISPLAY GXMenu);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 /* free (datap); */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366 *error = "Can't add selection to menu";
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367 /* 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
368 UNBLOCK_INPUT;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 return (0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
370 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 /* all set and ready to fly */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 XMenuRecompute (XDISPLAY GXMenu);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 dispwidth = DisplayWidth (x_current_display, XDefaultScreen (x_current_display));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376 dispheight = DisplayHeight (x_current_display, XDefaultScreen (x_current_display));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377 startx = min (startx, dispwidth);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378 starty = min (starty, dispheight);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379 startx = max (startx, 1);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380 starty = max (starty, 1);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381 XMenuLocate (XDISPLAY GXMenu, 0, 0, startx, starty,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
382 &ulx, &uly, &width, &height);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
383 if (ulx+width > dispwidth)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
384 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
385 startx -= (ulx + width) - dispwidth;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
386 ulx = dispwidth - width;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388 if (uly+height > dispheight)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
389 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
390 starty -= (uly + height) - dispheight;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
391 uly = dispheight - height;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
392 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
393 if (ulx < 0) startx -= ulx;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
394 if (uly < 0) starty -= uly;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
395
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 XMenuSetFreeze (GXMenu, TRUE);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
397 panes = selidx = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
398
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399 status = XMenuActivate (XDISPLAY GXMenu, &panes, &selidx,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400 startx, starty, ButtonReleaseMask, &datap);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 switch (status)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
403 case XM_SUCCESS:
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
404 #ifdef XDEBUG
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
405 fprintf (stderr, "pane= %d line = %d\n", panes, selidx);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
406 #endif
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
407 entry = item_list[panes][selidx];
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
408 break;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
409 case XM_FAILURE:
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
410 /* free (datap_save); */
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
411 XMenuDestroy (XDISPLAY GXMenu);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
412 *error = "Can't activate menu";
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
413 /* error ("Can't activate menu"); */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
414 case XM_IA_SELECT:
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415 case XM_NO_SELECT:
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416 entry = Qnil;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 break;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419 XMenuDestroy (XDISPLAY GXMenu);
2209
7b95f29936cb (xmenu_show): Do BLOCK_INPUT; unblock just before returning.
Richard M. Stallman <rms@gnu.org>
parents: 2191
diff changeset
420 UNBLOCK_INPUT;
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
421 /* free (datap_save);*/
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422 return (entry);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 syms_of_xmenu ()
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
426 {
2135
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
427 Qmenu_enable = intern ("menu-enable");
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
428
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
429 staticpro (&Qmenu_enable);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 defsubr (&Sx_popup_menu);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431 }
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
432
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
433 /* 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
434 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
435 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
436 Return the number of panes.
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
438 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
439
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
440 int
2160
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
441 keymap_panes (vector, panes, names, enables, items, keymaps, nmaps)
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
442 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
443 char ***panes; /* RETURN pane names */
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
444 char ****names; /* RETURN all line names */
2160
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
445 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
446 int **items; /* RETURN number of items per pane */
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
447 Lisp_Object *keymaps;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
448 int nmaps;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
449 {
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
450 /* Number of panes we have made. */
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
451 int p = 0;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
452 /* 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
453 int npanes_allocated = nmaps;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
454 int mapno;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
455
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
456 if (npanes_allocated < 4)
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
457 npanes_allocated = 4;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
458
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
459 /* 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
460 *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
461 *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
462 *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
463 *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
464 *enables = (int **) xmalloc (npanes_allocated * sizeof (int *));
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
465
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
466 /* 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
467 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
468 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
469 for (mapno = 0; mapno < nmaps; mapno++)
2160
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
470 single_keymap_panes (keymaps[mapno], panes, vector, names, enables, items,
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
471 &p, &npanes_allocated, "");
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
472
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
473 /* Return the number of panes. */
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
474 return p;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
475 }
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
476
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
477 /* 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
478 It handles one keymap, KEYMAP.
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
479 The other arguments are passed along
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
480 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
481
2160
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
482 single_keymap_panes (keymap, panes, vector, names, enables, items,
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
483 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
484 Lisp_Object keymap;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
485 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
486 char ***panes; /* RETURN pane names */
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
487 char ****names; /* RETURN all line names */
2160
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
488 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
489 int **items; /* RETURN number of items per pane */
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
490 int *p_ptr;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
491 int *npanes_allocated_ptr;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
492 char *pane_name;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
493 {
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
494 int i;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
495 Lisp_Object pending_maps;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
496 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
497
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
498 pending_maps = Qnil;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
499
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
500 /* 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
501 if (*p_ptr == *npanes_allocated_ptr)
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
502 {
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
503 *npanes_allocated_ptr *= 2;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
504
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
505 *vector
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
506 = (Lisp_Object **) xrealloc (*vector,
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
507 *npanes_allocated_ptr * sizeof (Lisp_Object *));
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
508 *panes
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
509 = (char **) xrealloc (*panes,
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
510 *npanes_allocated_ptr * sizeof (char *));
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
511 *items
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
512 = (int *) xrealloc (*items,
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
513 *npanes_allocated_ptr * sizeof (int));
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
514 *names
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
515 = (char ***) xrealloc (*names,
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
516 *npanes_allocated_ptr * sizeof (char **));
2160
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
517 *enables
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
518 = (int **) xrealloc (*enables,
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
519 *npanes_allocated_ptr * sizeof (int *));
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
520 }
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 /* 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
523 (*panes)[*p_ptr] = pane_name;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
524
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
525 /* 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
526 i = XFASTINT (Flength (keymap));
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
527
1213
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
528 /* Add in lengths of any arrays. */
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
529 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
530 if (XTYPE (XCONS (tail)->car) == Lisp_Vector)
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
531 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
532
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
533 /* 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
534 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
535 (*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
536 (*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
537 (*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
538
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
539 /* 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
540 i = 0;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
541 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
542 {
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
543 /* 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
544 make a menu item from it. */
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
545 item = XCONS (tail)->car;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
546 if (XTYPE (item) == Lisp_Cons)
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
547 {
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
548 item1 = XCONS (item)->cdr;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
549 if (XTYPE (item1) == Lisp_Cons)
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
550 {
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
551 item2 = XCONS (item1)->car;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
552 if (XTYPE (item2) == Lisp_String)
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
553 {
2135
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
554 Lisp_Object def, tem;
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
555 Lisp_Object enabled;
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
556
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
557 def = Fcdr (item1);
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
558 enabled = Qt;
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
559 if (XTYPE (def) == Lisp_Symbol)
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
560 {
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
561 /* No property, or nil, means enable.
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
562 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
563 tem = Fget (def, Qmenu_enable);
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
564 if (!NILP (tem))
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
565 enabled = Feval (tem);
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
566 }
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
567 tem = Fkeymapp (def);
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
568 if (XSTRING (item2)->data[0] == '@' && !NILP (tem))
2135
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
569 pending_maps = Fcons (Fcons (def, item2),
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
570 pending_maps);
2160
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
571 else
1082
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 (*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
574 /* 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
575 (*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
576 (*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
577 = (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
578 i++;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
579 }
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
580 }
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
581 }
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
582 }
1213
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
583 else if (XTYPE (item) == Lisp_Vector)
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
584 {
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
585 /* 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
586 int len = XVECTOR (item)->size;
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
587 int c;
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
588 for (c = 0; c < len; c++)
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
589 {
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
590 Lisp_Object character;
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
591 XFASTINT (character) = c;
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
592 item1 = XVECTOR (item)->contents[c];
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
593 if (XTYPE (item1) == Lisp_Cons)
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
594 {
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
595 item2 = XCONS (item1)->car;
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
596 if (XTYPE (item2) == Lisp_String)
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
597 {
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
598 Lisp_Object tem;
2135
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
599 Lisp_Object def;
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
600 Lisp_Object enabled;
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
601
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
602 def = Fcdr (item1);
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
603 enabled = Qt;
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
604 if (XTYPE (def) == Lisp_Symbol)
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
605 {
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
606 tem = Fget (def, Qmenu_enable);
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
607 /* No property, or nil, means enable.
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
608 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
609 if (!NILP (tem))
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
610 enabled = Feval (tem);
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
611 }
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
612
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
613 tem = Fkeymapp (def);
1213
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
614 if (XSTRING (item2)->data[0] == '@' && !NILP (tem))
2135
0634d08c28d1 (syms_of_xmenu): Set up Qmenu_enable.
Richard M. Stallman <rms@gnu.org>
parents: 1933
diff changeset
615 pending_maps = Fcons (Fcons (def, item2),
1213
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
616 pending_maps);
2160
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
617 else
1213
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
618 {
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
619 (*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
620 /* 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
621 (*vector)[*p_ptr][i] = character;
2160
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
622 (*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
623 = (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
624 i++;
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
625 }
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
626 }
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
627 }
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
628 }
0901fe62d97b (single_keymap_panes): Handle vectors properly.
Richard M. Stallman <rms@gnu.org>
parents: 1210
diff changeset
629 }
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
630 }
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
631 /* 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
632 (*items)[*p_ptr] = i;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
633
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
634 /* 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
635 if (i == 0)
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
636 {
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2209
diff changeset
637 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
638 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
639 xfree ((*enables)[*p_ptr]);
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
640 }
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
641 /* Otherwise, advance past it. */
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
642 else
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
643 (*p_ptr)++;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
644
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
645 /* 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
646 while (!NILP (pending_maps))
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
647 {
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
648 Lisp_Object elt;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
649 elt = Fcar (pending_maps);
2160
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
650 single_keymap_panes (Fcar (elt), panes, vector, names, enables, items,
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
651 p_ptr, npanes_allocated_ptr,
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
652 /* Add 1 to discard the @. */
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
653 (char *) XSTRING (XCONS (elt)->cdr)->data + 1);
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
654 pending_maps = Fcdr (pending_maps);
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 }
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
657
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
658 /* 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
659 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
660 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
661 Return the number of panes.
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
662
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
663 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
664
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
665 int
2160
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
666 list_of_panes (vector, panes, names, enables, items, menu)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
667 Lisp_Object ***vector; /* RETURN all menu objects */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
668 char ***panes; /* RETURN pane names */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
669 char ****names; /* RETURN all line names */
2160
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
670 int ***enables; /* RETURN enable flags of lines */
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
671 int **items; /* RETURN number of items per pane */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
672 Lisp_Object menu;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
673 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
674 Lisp_Object tail, item, item1;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
675 int i;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
676
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
677 if (XTYPE (menu) != Lisp_Cons) menu = wrong_type_argument (Qlistp, menu);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
678
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
679 i = XFASTINT (Flength (menu));
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
680
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
681 *vector = (Lisp_Object **) xmalloc (i * sizeof (Lisp_Object *));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
682 *panes = (char **) xmalloc (i * sizeof (char *));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
683 *items = (int *) xmalloc (i * sizeof (int));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
684 *names = (char ***) xmalloc (i * sizeof (char **));
2160
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
685 *enables = (int **) xmalloc (i * sizeof (int *));
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
686
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
687 for (i = 0, tail = menu; !NILP (tail); tail = Fcdr (tail), i++)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
688 {
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
689 item = Fcdr (Fcar (tail));
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
690 if (XTYPE (item) != Lisp_Cons) (void) wrong_type_argument (Qlistp, item);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
691 #ifdef XDEBUG
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
692 fprintf (stderr, "list_of_panes check tail, i=%d\n", i);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
693 #endif
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
694 item1 = Fcar (Fcar (tail));
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
695 CHECK_STRING (item1, 1);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
696 #ifdef XDEBUG
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
697 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
698 XSTRING (item1)->data);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
699 #endif
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
700 (*panes)[i] = (char *) XSTRING (item1)->data;
2160
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
701 (*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
702 /* (*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
703 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
704 ; */
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
705 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
706 return i;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
707 }
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
708
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
709 /* 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
710 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
711 int *ENABLES. Return the number of items. */
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
712
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
713 int
2160
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
714 list_of_items (vector, names, enables, pane)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
715 Lisp_Object **vector; /* RETURN menu "objects" */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
716 char ***names; /* RETURN line names */
2160
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
717 int **enables; /* RETURN enable flags of lines */
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
718 Lisp_Object pane;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
719 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
720 Lisp_Object tail, item, item1;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
721 int i;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
722
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
723 if (XTYPE (pane) != Lisp_Cons) pane = wrong_type_argument (Qlistp, pane);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
724
1933
63ba4f555b90 * minibuf.c (Fdisplay_completion_list): Pass the proper number of
Jim Blandy <jimb@redhat.com>
parents: 1828
diff changeset
725 i = XFASTINT (Flength (pane));
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
726
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
727 *vector = (Lisp_Object *) xmalloc (i * sizeof (Lisp_Object));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
728 *names = (char **) xmalloc (i * sizeof (char *));
2160
0639c52f017c (xmenu_show): New arg enable_list.
Richard M. Stallman <rms@gnu.org>
parents: 2153
diff changeset
729 *enables = (int *) xmalloc (i * sizeof (int));
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
730
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
731 for (i = 0, tail = pane; !NILP (tail); tail = Fcdr (tail), i++)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
732 {
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
733 item = Fcar (tail);
2191
12480fa04422 (list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents: 2160
diff changeset
734 if (STRINGP (item))
12480fa04422 (list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents: 2160
diff changeset
735 {
12480fa04422 (list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents: 2160
diff changeset
736 (*vector)[i] = Qnil;
12480fa04422 (list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents: 2160
diff changeset
737 (*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
738 (*enables)[i] = -1;
12480fa04422 (list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents: 2160
diff changeset
739 }
12480fa04422 (list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents: 2160
diff changeset
740 else
12480fa04422 (list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents: 2160
diff changeset
741 {
12480fa04422 (list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents: 2160
diff changeset
742 CHECK_CONS (item, 0);
12480fa04422 (list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents: 2160
diff changeset
743 (*vector)[i] = Fcdr (item);
12480fa04422 (list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents: 2160
diff changeset
744 item1 = Fcar (item);
12480fa04422 (list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents: 2160
diff changeset
745 CHECK_STRING (item1, 1);
12480fa04422 (list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents: 2160
diff changeset
746 (*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
747 (*enables)[i] = 1;
12480fa04422 (list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents: 2160
diff changeset
748 }
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
749 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
750 return i;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
751 }