annotate src/xmenu.c @ 293:7e7575d7b6d0

*** empty log message ***
author Jim Blandy <jimb@redhat.com>
date Thu, 20 Jun 1991 10:29:36 +0000
parents 49342840ba00
children 8c615e453683
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.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2 Copyright (C) 1986, 1988 Free Software Foundation, Inc.
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
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 the Free Software Foundation; either version 1, or (at your option)
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 /* $Source: /u2/third_party/gnuemacs.chow/src/RCS/xmenu.c,v $
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 * $Author: rlk $
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 * $Locker: $
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 * $Header: xmenu.c,v 1.6 86/08/26 17:23:26 rlk Exp $
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 *
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 #ifndef lint
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 static char *rcsid_GXMenu_c = "$Header: xmenu.c,v 1.6 86/08/26 17:23:26 rlk Exp $";
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 #endif lint
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 #ifdef XDEBUG
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 #include <stdio.h>
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 #endif
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 /* On 4.3 this loses if it comes after xterm.h. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 #include <signal.h>
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 #include "config.h"
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 #include "lisp.h"
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 #include "screen.h"
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 #include "window.h"
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 /* This may include sys/types.h, and that somehow loses
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 if this is not done before the other system files. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 #include "xterm.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 /* Load sys/types.h if not already loaded.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 In some systems loading it twice is suicidal. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 #ifndef makedev
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 #include <sys/types.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 #include "dispextern.h"
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 #ifdef HAVE_X11
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 #include "../oldXMenu/XMenu.h"
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 #else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 #include <X/XMenu.h>
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 #endif
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 #define min(x,y) (((x) < (y)) ? (x) : (y))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 #define max(x,y) (((x) > (y)) ? (x) : (y))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 #define NUL 0
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 #ifndef TRUE
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 #define TRUE 1
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 #define FALSE 0
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 #endif TRUE
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 #ifdef HAVE_X11
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 extern Display *x_current_display;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 #else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 #define ButtonReleaseMask ButtonReleased
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 #endif /* not HAVE_X11 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 Lisp_Object xmenu_show ();
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 extern int x_error_handler ();
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 /*************************************************************/
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 #if 0
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 /* Ignoring the args is easiest. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 xmenu_quit ()
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 error ("Unknown XMenu error");
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 #endif
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 DEFUN ("x-popup-menu",Fx_popup_menu, Sx_popup_menu, 1, 2, 0,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 "Pop up a deck-of-cards menu and return user's selection.\n\
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 ARG is a position specification: a list ((XOFFSET YOFFSET) WINDOW)\n\
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 where XOFFSET and YOFFSET are positions in characters from the top left\n\
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 corner of WINDOW's screen. A mouse-event list will serve for this.\n\
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 This controls the position of the center of the first line\n\
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 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
102 \n\
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 MENU is a specifier for a menu. It is a list of the form\n\
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 \(TITLE PANE1 PANE2...), and each pane is a list of form\n\
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 \(TITLE (LINE ITEM)...). Each line should be a string, and item should\n\
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 be the return value for that line (i.e. if it is selected.")
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 (arg, menu)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 Lisp_Object arg, menu;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 int number_of_panes;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 Lisp_Object XMenu_return;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 int XMenu_xpos, XMenu_ypos;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 char **menus;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 char ***names;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 Lisp_Object **obj_list;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 int *items;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 char *title;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 char *error_name;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 Lisp_Object ltitle, selection;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 int i, j;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 SCREEN_PTR s;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 Lisp_Object x, y, window;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 window = Fcar (Fcdr (arg));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 x = Fcar (Fcar (arg));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 y = Fcar (Fcdr (Fcar (arg)));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 CHECK_WINDOW (window, 0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 CHECK_NUMBER (x, 0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 CHECK_NUMBER (y, 0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 s = XSCREEN (WINDOW_SCREEN (XWINDOW (window)));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 XMenu_xpos = FONT_WIDTH (s->display.x->font) * XINT (x);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 XMenu_ypos = FONT_HEIGHT (s->display.x->font) * XINT (y);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 XMenu_xpos += s->display.x->left_pos;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 XMenu_ypos += s->display.x->top_pos;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 ltitle = Fcar (menu);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 CHECK_STRING (ltitle, 1);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 title = (char *) XSTRING (ltitle)->data;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 number_of_panes=list_of_panes (&obj_list, &menus, &names, &items, Fcdr (menu));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 #ifdef XDEBUG
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 fprintf (stderr, "Panes= %d\n", number_of_panes);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 for (i=0; i < number_of_panes; i++)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 fprintf (stderr, "Pane %d lines %d title %s\n", i, items[i], menus[i]);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 for (j=0; j < items[i]; j++)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 fprintf (stderr, " Item %d %s\n", j, names[i][j]);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 #endif
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 BLOCK_INPUT;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 selection = xmenu_show (ROOT_WINDOW, XMenu_xpos, XMenu_ypos, names, menus,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 items, number_of_panes, obj_list, title, &error_name);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 UNBLOCK_INPUT;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 /** fprintf (stderr, "selection = %x\n", selection); **/
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 if (selection != NUL)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 { /* selected something */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 XMenu_return = selection;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 { /* nothing selected */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 XMenu_return = Qnil;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 /* now free up the strings */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 for (i=0; i < number_of_panes; i++)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 free (names[i]);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 free (obj_list[i]);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 free (menus);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 free (obj_list);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 free (names);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 free (items);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 /* free (title); */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 if (error_name) error (error_name);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 return XMenu_return;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 struct indices {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 int pane;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 int line;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 };
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 Lisp_Object
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 xmenu_show (parent, startx, starty, line_list, pane_list, line_cnt,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 pane_cnt, item_list, title, error)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 Window parent;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 int startx, starty; /* upper left corner position BROKEN */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 char **line_list[]; /* list of strings for items */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 char *pane_list[]; /* list of pane titles */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 char *title;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 int pane_cnt; /* total number of panes */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 Lisp_Object *item_list[]; /* All items */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 int line_cnt[]; /* Lines in each pane */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 char **error; /* Error returned */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 XMenu *GXMenu;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 int last, panes, selidx, lpane, status;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 int lines, sofar;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 Lisp_Object entry;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 /* struct indices *datap, *datap_save; */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 char *datap;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 int ulx, uly, width, height;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 int dispwidth, dispheight;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 *error = (char *) 0; /* Initialize error pointer to null */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 GXMenu = XMenuCreate (XDISPLAY parent, "emacs");
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 if (GXMenu == NUL)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 *error = "Can't create menu";
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 return (0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 for (panes=0, lines=0; panes < pane_cnt; lines += line_cnt[panes], panes++)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 ;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 /* datap = (struct indices *) xmalloc (lines * sizeof (struct indices)); */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 /*datap = (char *) xmalloc (lines * sizeof (char));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 datap_save = datap;*/
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 for (panes = 0, sofar=0;panes < pane_cnt;sofar +=line_cnt[panes], panes++)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 /* create all the necessary panes */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 lpane = XMenuAddPane (XDISPLAY GXMenu, pane_list[panes], TRUE);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 if (lpane == XM_FAILURE)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 XMenuDestroy (XDISPLAY GXMenu);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 *error = "Can't create pane";
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 return (0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 for (selidx = 0; selidx < line_cnt[panes] ; selidx++)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 /* add the selection stuff to the menus */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 /* datap[selidx+sofar].pane = panes;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 datap[selidx+sofar].line = selidx; */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 if (XMenuAddSelection (XDISPLAY GXMenu, lpane, 0,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 line_list[panes][selidx], TRUE)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 == XM_FAILURE)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 XMenuDestroy (XDISPLAY GXMenu);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 /* free (datap); */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242 *error = "Can't add selection to menu";
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243 /* error ("Can't add selection to menu"); */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 return (0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 /* all set and ready to fly */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 XMenuRecompute (XDISPLAY GXMenu);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 dispwidth = DisplayWidth (x_current_display, XDefaultScreen (x_current_display));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 dispheight = DisplayHeight (x_current_display, XDefaultScreen (x_current_display));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 startx = min (startx, dispwidth);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 starty = min (starty, dispheight);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 startx = max (startx, 1);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 starty = max (starty, 1);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 XMenuLocate (XDISPLAY GXMenu, 0, 0, startx, starty,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 &ulx, &uly, &width, &height);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 if (ulx+width > dispwidth)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260 startx -= (ulx + width) - dispwidth;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 ulx = dispwidth - width;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 if (uly+height > dispheight)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 starty -= (uly + height) - dispheight;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 uly = dispheight - height;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 if (ulx < 0) startx -= ulx;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 if (uly < 0) starty -= uly;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 XMenuSetFreeze (GXMenu, TRUE);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 panes = selidx = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 status = XMenuActivate (XDISPLAY GXMenu, &panes, &selidx,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 startx, starty, ButtonReleaseMask, &datap);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 switch (status)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 case XM_SUCCESS:
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 #ifdef XDEBUG
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 fprintf (stderr, "pane= %d line = %d\n", panes, selidx);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 #endif
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 entry = item_list[panes][selidx];
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 break;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 case XM_FAILURE:
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 /*free (datap_save); */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 XMenuDestroy (XDISPLAY GXMenu);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 *error = "Can't activate menu";
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 /* error ("Can't activate menu"); */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 case XM_IA_SELECT:
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 case XM_NO_SELECT:
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 entry = Qnil;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 break;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 XMenuDestroy (XDISPLAY GXMenu);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 /*free (datap_save);*/
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 return (entry);
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 syms_of_xmenu ()
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
301 defsubr (&Sx_popup_menu);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304 list_of_panes (vector, panes, names, items, menu)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305 Lisp_Object ***vector; /* RETURN all menu objects */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 char ***panes; /* RETURN pane names */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307 char ****names; /* RETURN all line names */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308 int **items; /* RETURN number of items per pane */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309 Lisp_Object menu;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 Lisp_Object tail, item, item1;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 int i;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 if (XTYPE (menu) != Lisp_Cons) menu = wrong_type_argument (Qlistp, menu);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316 i= XFASTINT (Flength (menu, 1));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318 *vector = (Lisp_Object **) xmalloc (i * sizeof (Lisp_Object *));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319 *panes = (char **) xmalloc (i * sizeof (char *));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320 *items = (int *) xmalloc (i * sizeof (int));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 *names = (char ***) xmalloc (i * sizeof (char **));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 for (i=0, tail = menu; !NULL (tail); tail = Fcdr (tail), i++)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 item = Fcdr (Fcar (tail));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 if (XTYPE (item) != Lisp_Cons) (void) wrong_type_argument (Qlistp, item);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 #ifdef XDEBUG
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 fprintf (stderr, "list_of_panes check tail, i=%d\n", i);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 #endif
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 item1 = Fcar (Fcar (tail));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 CHECK_STRING (item1, 1);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 #ifdef XDEBUG
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333 fprintf (stderr, "list_of_panes check pane, i=%d%s\n", i,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 XSTRING (item1)->data);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 #endif
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 (*panes)[i] = (char *) XSTRING (item1)->data;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337 (*items)[i] = list_of_items ((*vector)+i, (*names)+i, item);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338 /* (*panes)[i] = (char *) xmalloc ((XSTRING (item1)->size)+1);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 bcopy (XSTRING (item1)->data, (*panes)[i], XSTRING (item1)->size + 1)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 ; */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 return i;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346 list_of_items (vector, names, pane) /* get list from emacs and put to vector */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 Lisp_Object **vector; /* RETURN menu "objects" */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 char ***names; /* RETURN line names */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 Lisp_Object pane;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 Lisp_Object tail, item, item1;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352 int i;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354 if (XTYPE (pane) != Lisp_Cons) pane = wrong_type_argument (Qlistp, pane);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 i= XFASTINT (Flength (pane, 1));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 *vector = (Lisp_Object *) xmalloc (i * sizeof (Lisp_Object));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359 *names = (char **) xmalloc (i * sizeof (char *));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361 for (i=0, tail = pane; !NULL (tail); tail = Fcdr (tail), i++)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 item = Fcar (tail);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364 if (XTYPE (item) != Lisp_Cons) (void) wrong_type_argument (Qlistp, item);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 #ifdef XDEBUG
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366 fprintf (stderr, "list_of_items check tail, i=%d\n", i);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367 #endif
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368 (*vector)[i] = Fcdr (item);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 item1 = Fcar (item);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
370 CHECK_STRING (item1, 1);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 #ifdef XDEBUG
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 fprintf (stderr, "list_of_items check item, i=%d%s\n", i,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 XSTRING (item1)->data);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 #endif
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 (*names)[i] = (char *) XSTRING (item1)->data;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377 return i;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378 }