annotate src/energize.c @ 18:d95e72db5c07 r19-15b92

Import from CVS: tag r19-15b92
author cvs
date Mon, 13 Aug 2007 08:49:43 +0200
parents 9ee227acff29
children 859a2309aef8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /****************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ***
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 *** Copyright (c) 1990 by Sun/Lucid, All Rights Reserved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 *** Copyright (c) 1991-1993 by Lucid, Inc. All Rights Reserved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ***
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 *****************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 /* Synched up with: Not in FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 #ifdef ENERGIZE /* whole file */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 /* Display Context for the icons */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 #include "console-x.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 #include <Xm/DialogS.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 #include "lwlib.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 #include "objects-x.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 #include "events.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 #include "opaque.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 #include "buffer.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 #include "extents.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 #include "process.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 #include "insdel.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 #include "window.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 #include "faces.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 /* Energize editor requests and I/O operations */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #include "energize.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #include "systime.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 #include "sysfile.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 #include "syssignal.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 #ifndef CBFileYourself
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 /* This means that emacs is being compiled against the connection library
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 and headers that go with an Energize protocol less than 0.10. We need
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 to do some slightly different things in this file because of that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 Note that if Emacs is compiled against the 3.0 version of the connection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 library and associated headers, it can still talk to 2.1- or 2.5-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 servers. But the opposite is not true.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 # define ENERGIZE_V2_HEADERS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 /* The Connection library
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 extern void CWriteQueryChoicesRequest ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 extern void CWriteExecuteChoicesRequest ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 extern void CWriteSheetRequest ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 extern void CWriteSetControlRequest ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 extern void CWriteChoice ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 extern void CWriteProtocol ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 extern int CGetPortNumber ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 /************** Typedefs and Structs ***********************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 /* structure argument used by the next mapping function */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 typedef struct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 int n_extents;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 } binfo_and_n_extents;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 typedef struct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 BufferInfo* binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 int state;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 int tell_energize;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 } binfo_and_state;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 struct reply_wait
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 int serial;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 EId objectId;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 EId genericId;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 EId itemId;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 char answered_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 char status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 char* message;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 Lisp_Object menu_result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 Lisp_Object only_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 struct reply_wait* next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 static struct reply_wait *global_reply_wait;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 Lisp_Object Venergize_kernel_busy;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 Lisp_Object Qenergize_kernel_busy;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 Lisp_Object Venergize_attributes_mapping;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 int energize_extent_gc_threshold;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 Lisp_Object Venergize_kernel_busy_hook;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 Lisp_Object Qenergize_kernel_busy_hook;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 Lisp_Object Venergize_menu_update_hook;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 Lisp_Object Qenergize_menu_update_hook;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 Lisp_Object Qenergize;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 Lisp_Object Qenergize_auto_revert_buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 static void set_energize_extent_data (EXTENT extent, void *data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 static char *kernel_buffer_type_to_elisp_type (char *kernel_type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 static CONST void *get_object (EId id, BufferInfo *binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 static void put_object (EId id, BufferInfo *binfo, void *object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 static void remove_object (EId id, BufferInfo *binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 static void free_GDataclass (GDataClass *cl, BufferInfo *binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 static void free_GenericData (GenericData *gen, BufferInfo *binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 static void free_Energize_Extent_Data (Energize_Extent_Data *, BufferInfo *,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 enum Energize_Object_Free_Type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 static BufferInfo *get_buffer_info_for_emacs_buffer (Lisp_Object emacs_buf,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 Editor *editor);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 static void put_buffer_info (EId id, Lisp_Object emacs_buf,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 BufferInfo *binfo, Editor *editor);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 static void handle_sheet_control_change (Widget, EId sheet_id, void* arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 static Connection *make_energize_connection (Editor *editor,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 int fdin, int fdout);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 static void close_energize_connection (void);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 Lisp_Object Fclose_connection_to_energize (void);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 static void mark_all_extents_as_unmodified (BufferInfo *binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 Lisp_Object Fenergize_barf_if_buffer_locked (void);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 Lisp_Object Fconnected_to_energize_p (void);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 static int get_energize_connection_and_buffer_id (Lisp_Object buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 void **conn_ptr,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 long *buffer_id_ptr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 void restore_energize_extent_state (EXTENT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 /**************************** Variables *****************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 /* debugging variable */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 int ignore_kernel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 Lisp_Object Venergize_kernel_modification_hook;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 Lisp_Object Venergize_create_buffer_hook;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 Lisp_Object Qenergize_create_buffer_hook;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 Lisp_Object Qenergize_buffer_modified_hook;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 Lisp_Object Qbuffer_locked_by_energize;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 Lisp_Object Qenergize_user_input_buffer_mark;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 Lisp_Object Qenergize_make_many_buffers_visible;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 int inside_parse_buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 /* List of all buffers currently managed by Energize. This is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 Staticpro'ed so that they don't get GC'ed from under us. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 static Lisp_Object Venergize_buffers_list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 static Editor *energize_connection;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 static protocol_edit_options *peo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 static int request_serial_number;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 extern int current_debuggerpanel_exposed_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 extern int desired_debuggerpanel_exposed_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 extern int debuggerpanel_sheet;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 /**************************** Macros *****************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 #define xnew(type) ((type*)xmalloc (sizeof (type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 #define BUFFER_NOTIFY_BACKGROUND_BIT_SET_P(buffer) 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 #define get_extent_data(id,binfo) (Energize_Extent_Data*)get_object(id, binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 #define get_class(id,binfo) (GDataClass*)get_object(id, binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 #define get_generic(id,binfo) (GenericData*)get_object(id, binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 #define put_extent_data(id,binfo,obj) put_object(id, binfo, obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 #define put_class(id,binfo,obj) put_object(id, binfo, obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 #define put_generic(id,binfo,obj) put_object(id, binfo, obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 #define remove_extent_data(id,binfo) remove_object(id, binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 #define remove_class(id,binfo) remove_object(id, binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 #define remove_generic(id,binfo) remove_object(id, binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 #define DEBUGGER_PSHEET_NAME "DEBUGGER_P_SHEET"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 /* special graphics attribute meaning "use what anyone else's attributes" */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 #define GA_NO_CHANGE 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 /* this number should be bigger than any of the "real" GA's */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 #define GA_MAX 0x1000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 /**************************** Utilities *****************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 emacs_CWriteRequestBuffer (Connection* conn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 int result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 /* don't kill emacs with SIGPIPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 SIGTYPE (*old_sigpipe)() =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (SIGTYPE (*) ()) signal (SIGPIPE, SIG_IGN);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 result = CWriteRequestBuffer (conn); /* the real one; macroized later */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 signal (SIGPIPE, old_sigpipe);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 #define CWriteRequestBuffer emacs_CWriteRequestBuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 static Energize_Extent_Data *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 extent_to_data (Lisp_Object extent_obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 Energize_Extent_Data *ext = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 if (!EXTENTP (extent_obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ext = energize_extent_data (XEXTENT (extent_obj));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 if (ext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 if (EQ (ext->extent, extent_obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 return ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 data_to_extent (Energize_Extent_Data *ext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 Lisp_Object extent = ext->extent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 assert (EXTENTP (extent));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 return extent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 /* duplicate a string */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 static char*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 copy_string (char *s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 if (!s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 int len = strlen (s);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 char *res = (char *) xmalloc (len + 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 return strcpy (res, s);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 /* Get objects from the hashtables */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 static CONST void *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 get_object_internal (EId id, c_hashtable table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 void *res;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 CONST void *found = gethash ((void*)id, table, &res);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 if (found) CHECK_OBJECT (res);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 return found ? res : 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 static CONST void *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 get_object (EId id, BufferInfo *binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 return get_object_internal (id, binfo->id_to_object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 put_object_internal (EId id, c_hashtable table, void *object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 if (!PUT_ABLE_OBJECT (object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 error ("Can't put 0x%x in table", object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 CHECK_OBJECT (object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 puthash ((void*)id, object, table);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 put_object (EId id, BufferInfo *binfo, void *object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 put_object_internal (id, binfo->id_to_object, object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 remove_object_internal (EId id, c_hashtable table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 void *res;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 if (gethash ((void*)id, table, &res))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 if (OBJECT_FREE (res))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 error ("Free'd object 0x%x still in table!", res);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 remhash ((void*)id, table);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 else if (id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 /* #### If this happens for Energize_Extent_Data as a result of extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 finalization, this aborts (because gc_in_progress). These errors are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 awfully bad, so probably they should just be abort()s anyway... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 error ("EId %d not in table!", id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 remove_object (EId id, BufferInfo *binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 remove_object_internal (id, binfo->id_to_object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 /* maphash_function called by free_buffer_info */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 free_object (void *key, void *contents, void *arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 BufferInfo *binfo = arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 if (contents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 switch (OBJECT_SEAL (contents))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 case BUF_INFO_SEAL:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 case EXTENT_SEAL:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 free_Energize_Extent_Data ((Energize_Extent_Data *) contents,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 binfo, OFT_MAPHASH);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 case GDATA_CLASS_SEAL:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 free_GDataclass ((GDataClass *) contents, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 case GDATA_SEAL:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 free_GenericData ((GenericData *) contents, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 error ("Bad argument 0x%x to free_object()", contents);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 static GDataClass *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 alloc_GDataclass (EId id, BufferInfo *binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 GDataClass *cl = xnew (GDataClass);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 memset (cl, 0, sizeof (GDataClass));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 cl->seal = GDATA_CLASS_SEAL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 cl->id = id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 put_class (cl->id, binfo, cl);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 return cl;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 free_GDataclass (GDataClass *cl, BufferInfo *binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 if (cl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 remove_class (cl->id, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 SET_OBJECT_FREE (cl);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 static GenericData *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 alloc_GenericData (EId id, GDataClass *cl, BufferInfo *binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 GenericData *gen = xnew (GenericData);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 gen->seal = GDATA_SEAL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 gen->id = id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 gen->cl = cl;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 /* gen->image = 0;*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 gen->flags = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 gen->modified_state = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 put_generic (gen->id, binfo, gen);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 return gen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 free_GenericData (GenericData *gen, BufferInfo *binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 if (gen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 remove_generic (gen->id, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 gen->cl = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 SET_OBJECT_FREE (gen);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 /* Called to flush the extent from the hash table when Energize tells us to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 lose the extent. This is NOT called from the extent GC finalization method,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 because there would be a period before the next GC when we still had an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 Energize ID that the server thought was dead, and could concievably reuse.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 Since we protect extents from GC until Energize says they're done, if an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 extent still has Energize data by the time it gets collected, something is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 fucked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 free_Energize_Extent_Data (Energize_Extent_Data *ext, BufferInfo *binfo,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 enum Energize_Object_Free_Type free_type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 if (ext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 Lisp_Object extent_obj = data_to_extent (ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 /* Remove the extent, remove the extent's pointer to the data,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 and the data's pointer to the extent. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 Fdetach_extent (extent_obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 set_energize_extent_data (XEXTENT (extent_obj), 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 ext->extent = Qnil; /* at this point, refs will abort */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 /* Remove the data from the hash table, and mark it as dead. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 remove_extent_data (ext->id, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 ext->id = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 /* don't free this "sub-guy" via maphash, as it will get taken care
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 of during the course of the maphash without our doing anything */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 if (free_type != OFT_MAPHASH)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 if (ext->extentType == CEGeneric)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 free_GenericData (ext->u.generic.gData, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 SET_OBJECT_FREE (ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 static BufferInfo *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 alloc_BufferInfo (EId id, Lisp_Object name, Lisp_Object filename,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 char *class_str, Editor *editor, Window win, int nobjects)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 BufferInfo *binfo = xnew (BufferInfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 Widget nw = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 Lisp_Object buffer = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 if (win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 char win_as_string [16];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 nw = XtWindowToWidget (get_x_display (Qnil), win);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 if (nw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 nw = XtParent (nw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 if (nw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 sprintf (win_as_string, "w%x", nw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 sprintf (win_as_string, "0x%x", win);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 binfo->frame =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 Fx_create_frame (Qnil, Qnil, build_string (win_as_string));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 binfo->frame = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 /* try to re-use a buffer with the same file name if one already exists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 * If a buffer already exists but is modified we should do a dialog and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 * ask the user what to do. For now I'll just use a new buffer in that case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 * ParseBuffer will erase the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 if (!NILP (filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 int offct = find_file_compare_truenames;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 find_file_compare_truenames = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 buffer = Fget_file_buffer (filename);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 find_file_compare_truenames = offct;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 if (!NILP (buffer) && !NILP (Fbuffer_modified_p (buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 buffer = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 if (NILP (buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 buffer = Fget_buffer_create (Fgenerate_new_buffer_name (name, Qnil));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 binfo->seal = BUF_INFO_SEAL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 binfo->id = id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 binfo->flags = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 binfo->editor = editor;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 binfo->id_to_object = make_hashtable (nobjects);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 binfo->emacs_buffer = buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 binfo->modified_state = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 binfo->editable = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 binfo->output_mark = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 binfo->buffer_type = kernel_buffer_type_to_elisp_type (class_str);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 binfo->p_sheet_ids = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 binfo->n_p_sheets = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 binfo->note_ids = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 binfo->n_notes = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 #ifdef I18N4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 binfo->wcmap.valid = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 binfo->wcmap.modiff_stamp = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 binfo->wcmap.map = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 put_buffer_info (id, binfo->emacs_buffer, binfo, editor);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 Venergize_buffers_list = Fcons (buffer, Venergize_buffers_list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 * if (nw){
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 * Lisp_Object window = Fframe_selected_window (binfo->frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 * Fset_window_buffer (window, binfo->emacs_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 * set_text_widget ((NoteWidget)nw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 * FRAME_X_SHELL_WIDGET (XFRAME (binfo->frame)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 * }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 return binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 /* free a buffer_info */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 free_buffer_info (BufferInfo *binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 maphash (free_object, binfo->id_to_object, (void *)binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 free_hashtable (binfo->id_to_object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 if (energize_connection && energize_connection->binfo_hash)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 if (binfo->id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 remhash ((void *)binfo->id, energize_connection->binfo_hash);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 if (!NILP (binfo->emacs_buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 remhash (LISP_TO_VOID (binfo->emacs_buffer),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 energize_connection->binfo_hash);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 binfo->id = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 binfo->emacs_buffer = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 #ifdef I18N4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 if (binfo->wcmap.valid) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 binfo->wcmap.valid= 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 xfree(binfo->wcmap.map);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 SET_OBJECT_FREE (binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 /* hash for BufferInfo structures */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 static BufferInfo*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 get_buffer_info_for_emacs_buffer (Lisp_Object emacs_buf, Editor *editor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 BufferInfo *res;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 if (!editor || !editor->binfo_hash)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 void *vbuf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 /* #### Probably should use a Lisp hash table for this; what if the last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 pointer to the buffer was in the editor struct? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 return (gethash (LISP_TO_VOID (emacs_buf),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 editor->binfo_hash,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (void *) &res)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 ? res : 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 /* Called by mark_buffer. It is possible for the last remaining pointer to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 an extent object to be in an Energize_Extent_Data structure that is pointed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 at by the binfo->id_to_object table. Since Energize may still reference
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 this object by its id (in fact, I think it may even "ressurect" a detached
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 extent) we must prevent the extent from being garbage collected. Aside
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 from the obvious lossage (that the extent itself would be trashed) this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 would also cause us to free the Energize_Extent_Data which the server still
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 believes we have. The buffers all get marked because they're on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 `Venergize_buffers_list'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 So, an Energize extent or buffer only ever gets collected when the server
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 has claimed that it is done with it (or when the connection is closed).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 Of course, by keeping pointers to lisp objects in C structs under non-lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 hash tables, we again build in the assumption that GC never relocates.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 /* FUCK!! It's not standard-conforming to cast pointers to functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 to or from void*. Give me a fucking break! */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 struct markobj_kludge_fmh
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 void (*markobj) (Lisp_Object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 mark_energize_buffer_data_extent_mapper (void *key, void *val, void *arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 if (OBJECT_SEAL (val) == EXTENT_SEAL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 struct markobj_kludge_fmh *fmh = arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 struct Energize_Extent_Data *ext = (Energize_Extent_Data *) val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 /* Lisp_Object extent = data_to_extent (ext); (will abort if marked) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 Lisp_Object extent = ext->extent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 assert (GC_EXTENTP (extent));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 ((*fmh->markobj) (extent));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 mark_energize_buffer_data (struct buffer *b,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 void (*markobj) (Lisp_Object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 struct markobj_kludge_fmh fmh;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 Lisp_Object buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 if (!energize_connection || !energize_connection->binfo_hash)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 XSETBUFFER (buffer, b);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 binfo = get_buffer_info_for_emacs_buffer (buffer, energize_connection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 if (! binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 fmh.markobj = markobj;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 maphash (mark_energize_buffer_data_extent_mapper, binfo->id_to_object, &fmh);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 struct buffer_and_sheet_ids
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 EId buffer_id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 EId sheet_id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 find_sheet_id (void* key, void* contents, void* arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 BufferInfo* binfo = (BufferInfo*)contents;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 EId buffer_id = (EId)key;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 struct buffer_and_sheet_ids* result = (struct buffer_and_sheet_ids*)arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 if (!result->buffer_id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 for (i = 0; i < binfo->n_p_sheets; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 if (binfo->p_sheet_ids [i] == result->sheet_id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 result->buffer_id = buffer_id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 static EId
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 buffer_id_of_sheet (EId id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 Editor *editor = energize_connection;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 struct buffer_and_sheet_ids basi;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 if (!energize_connection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 basi.buffer_id = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 basi.sheet_id = id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 maphash (find_sheet_id, editor->binfo_hash, (void*)&basi);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 return basi.buffer_id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 static long
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 get_energize_buffer_id (Lisp_Object emacs_buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 Editor *editor = energize_connection;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 BufferInfo *res;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 if (!editor || !editor->binfo_hash)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 return -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 else if (!gethash (LISP_TO_VOID (emacs_buf), editor->binfo_hash, (void *)&res))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 return -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 return (long) res->id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 kernel_buffer_type_to_elisp_type (char *kernel_type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 struct buffer_type_struct *bts =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 kernel_buffer_types_to_elisp_buffer_types_vector;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 char *elisp_type = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 if (!kernel_type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 return UNINITIALIZED_BUFFER_TYPE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 while (bts->kernel_name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 if (!strcmp (bts->kernel_name, kernel_type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 elisp_type = bts->elisp_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 bts++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 if (!elisp_type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 return kernel_type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 return elisp_type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 get_buffer_type_for_emacs_buffer (Lisp_Object emacs_buf, Editor *editor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 if (!(binfo = get_buffer_info_for_emacs_buffer (emacs_buf, editor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 if (!binfo->buffer_type) binfo->buffer_type =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 UNINITIALIZED_BUFFER_TYPE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 return intern (binfo->buffer_type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 set_buffer_type_for_emacs_buffer (Lisp_Object emacs_buf, Editor *editor,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 Lisp_Object type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 if (!(binfo = get_buffer_info_for_emacs_buffer (emacs_buf, editor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 char *type_string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 if (NILP (type)) return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 if (SYMBOLP (type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 XSETSTRING (type, XSYMBOL (type)->name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 if (STRINGP (type))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
725 type_string = (char *) XSTRING_DATA (type);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 type_string = copy_string (type_string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 if (!type_string) return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 binfo->buffer_type = type_string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 return intern (binfo->buffer_type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 static BufferInfo*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 get_buffer_info_for_id (EId id, Editor *editor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 BufferInfo *res;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 return (gethash ((void *)id, editor->binfo_hash, (void *)&res))?res:0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 put_buffer_info (EId id, Lisp_Object emacs_buf, BufferInfo *binfo,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 Editor *editor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 puthash ((void *)id, binfo, editor->binfo_hash);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 puthash (LISP_TO_VOID (emacs_buf), binfo, editor->binfo_hash);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 remove_buffer_info (EId id, Lisp_Object emacs_buf, Editor *editor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 void *vbuf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 remhash ((void *)id, editor->binfo_hash);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 remhash (LISP_TO_VOID (emacs_buf), editor->binfo_hash);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 /* Conversion between Energize and Emacs buffer positions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 #if defined(I18N4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 /* An emacs position is an index into the buffer... In I18N, foreign
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 characters take up the same amount of space as ASCII characters. Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 is using wide characters. The first position is 1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 An energize position is a straight byte offset into the file when it's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 saved onto disk. Foreign characters take up more than one byte. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 first position is 0. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 #define WCMAP_SETSIZE(wcmap,n) { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (wcmap).mapsize = (n); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (wcmap).map = (WCharMapRec *) xrealloc((wcmap).map, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (n) * sizeof(WCharMapRec)); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 #define WCMAP_ENLARGE(wcmap) WCMAP_SETSIZE(wcmap, 2*(wcmap.mapsize))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 #ifndef MB_LEN_MAX
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 #define MB_LEN_MAX 10 /* arbitrarily large enough */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 static char wcsize_buf[MB_LEN_MAX];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 #define WCSIZE(wc) (isascii(wc) ? 1 : wctomb(wcsize_buf,wc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 #define SANITY_CHECK_NOT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 #ifdef SANITY_CHECK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 static int sanity=0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 sync_buffer_widechar_map (BufferInfo *binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 /* #### - check this: */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 assert (XBUFFER (binfo->emacs_buffer) == current_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 if (!binfo->wcmap.valid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 binfo->wcmap.valid= 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 binfo->wcmap.modiff_stamp= -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 binfo->wcmap.map= NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 WCMAP_SETSIZE (binfo->wcmap, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 if (binfo->wcmap.modiff_stamp == BUF_MODIFF (current_buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 int nbytes, maxpos,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 pos = 0, /* start at zero instead of 1 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 adjustment = 0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 mapindex= 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 wchar_t *buf, t;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 #ifdef SANITY_CHECK
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
819 stderr_out ("rebuilding widechar map for %s\n", XSTRING_DATA (current_buffer->name));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 /* #### this is not gonna compile. move_gap() is now a private function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 inside of insdel.c and it should stay that way. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 if (BUF_BEGV (current_buffer) < GPT && BUF_ZV (current_buffer) > GPT)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 move_gap (current_buffer, BUF_BEGV (current_buffer));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 binfo->wcmap.modiff_stamp = BUF_MODIFF (current_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 buf = BUF_BEG_ADDR (current_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 maxpos= (BUF_Z (current_buffer) - 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 wctomb (NULL, 0); /* reset shift state of wctomb() */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 binfo->wcmap.map[mapindex].pos= pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 binfo->wcmap.map[mapindex].eucsize=
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 ((pos<maxpos) ? (nbytes= WCSIZE(buf[pos])) : 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 do {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 while ((pos < maxpos) && (nbytes == WCSIZE(t = buf[pos])))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 ++pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 binfo->wcmap.map[mapindex++].endpos= pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 if (mapindex == binfo->wcmap.mapsize)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 WCMAP_ENLARGE(binfo->wcmap);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 if (pos < maxpos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 binfo->wcmap.map[mapindex].pos= pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 binfo->wcmap.map[mapindex].eucsize= nbytes= WCSIZE(t);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 } while (pos < maxpos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 WCMAP_SETSIZE(binfo->wcmap, mapindex);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 static EnergizePos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 EnergizePosForBufpos (Bufpos char_pos, BufferInfo *binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 int mapindex;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 WCharMapRec map;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 EnergizePos byte_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 sync_buffer_widechar_map (binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 --char_pos; /* preadjust emacs position */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 mapindex=0, byte_pos=0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 while ((mapindex < binfo->wcmap.mapsize) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (char_pos > (map= binfo->wcmap.map[mapindex++]).pos)) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 if (char_pos > map.endpos) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 byte_pos += ((map.endpos - map.pos) * map.eucsize);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 } else {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 byte_pos += ((char_pos - map.pos) * map.eucsize);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 /* there should be a sanity check here */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 #ifdef CHECK_SANITY
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 if (!sanity) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 Bufpos check_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 sanity=1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 check_pos= BufposForEnergizePos(byte_pos, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 sanity=0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 if (check_pos != char_pos) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 stderr_out ("ezpos(%d) = %d, Bufpos(%d) = %d\n",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 char_pos, byte_pos, byte_pos, check_pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 return byte_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 static Bufpos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 BufposForEnergizePos (EnergizePos ez_pos, BufferInfo *binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 int mapindex, x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 WCharMapRec map;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 Bufpos char_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 EnergizePos byte_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 sync_buffer_widechar_map(binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 mapindex=0, byte_pos=0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 while ((mapindex < binfo->wcmap.mapsize) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (byte_pos <= ez_pos)) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 map= binfo->wcmap.map[mapindex++];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 x= (map.eucsize*(map.endpos-map.pos));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 if (ez_pos > (byte_pos + x)) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 byte_pos += x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 char_pos = map.endpos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 } else {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 char_pos = (map.pos + ((ez_pos - byte_pos)/map.eucsize));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 char_pos= (char_pos >= (1 << VALBITS)) ? BUF_Z (current_buffer) :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (char_pos + 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 #ifdef CHECK_SANITY
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 if (!sanity) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 EnergizePos check_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 sanity=1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 check_pos= EnergizePosForBufpos(char_pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 sanity=0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 if (check_pos != ez_pos) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 stderr_out ("Bufpos(%d) = %d, EnergizePosForBufpos(%d) = %d\n",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 ez_pos, char_pos, char_pos, check_pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 return (char_pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 #else /* !I18N4 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 static Bufpos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 BufposForEnergizePos (EnergizePos energizePos, BufferInfo *binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 return ((energizePos >= (1 << VALBITS)) ? BUF_Z (current_buffer) :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (energizePos + 1));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 static EnergizePos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 EnergizePosForBufpos (Bufpos emacs_pos, BufferInfo *binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 return (emacs_pos - 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 #endif /* !I18N4 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 DEFUN ("energize-update-menubar", Fenergize_update_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 Senergize_update_menubar, 0, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 obsolete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 Lisp_Object frame;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 DEFUN ("energize-extent-menu-p", Fenergize_extent_menu_p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 Senergize_extent_menu_p, 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 Whether the extent has a set of commands defined by Energize.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (extent_obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 Lisp_Object extent_obj;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 CHECK_EXTENT (extent_obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 if (NILP (Fconnected_to_energize_p ()))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 Energize_Extent_Data *ext = extent_to_data (extent_obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 return (ext && ext->extentType == CEGeneric) ? Qt : Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 /* Do what is needed so that the delayed requests will be notified by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 ** the event loop */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 extern void mark_process_as_being_ready (struct Lisp_Process* process);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 notify_delayed_requests (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 if (energize_connection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 && !NILP (energize_connection->proc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 && energize_connection->conn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 && CRequestDelayedP (energize_connection->conn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 this function no longer exists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (Replaced by mark_what_as_being_ready, with different arguments.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 Rewrite this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 mark_process_as_being_ready (XPROCESS (energize_connection->proc));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 /******************* IMAGE storage maintenance *******************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 extern GLYPH image_instance_to_glyph (Lisp_Object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 static c_hashtable image_cache;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 extern char *strdup ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 extern Lisp_Object Fbuffer_file_name (Lisp_Object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 extern Lisp_Object Fmake_face (Lisp_Object name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 extern Lisp_Object Fface_foreground (Lisp_Object face, Lisp_Object frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 extern Lisp_Object Fface_background (Lisp_Object face, Lisp_Object frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 /* Don't let any of these get GCed, since we hold their GLYPH ids in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 a non-lisp hash table (image_cache) . */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 static Lisp_Object Vall_energize_pixmaps;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 /* Parses an image from the image language */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 static GLYPH
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 read_energize_image_data (Connection *conn, BufferInfo *binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 ReqLen l;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 char *s = CGetVstring (conn, &l);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 char pix_name [255];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 char buf [255];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 int attr_number, pix_len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 char *file;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 GLYPH result = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 /* It is bad news to pass the address of a short to gethash. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 int hashed = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 if (s[0] != 'f')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 if (gethash ((void *) s, image_cache, (void *) &hashed))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 /* If we have already parsed this image spec (string=) then just return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 the old glyph, instead of calling the lisp code, x_get_pixmap, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 XtGetSubResources again. The result may be 0 if there is no pixmap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 file name in the resource database.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 return (GLYPH) hashed;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 if (3 != sscanf (s, "f %d p %d %s", &attr_number, &pix_len, pix_name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 sprintf (buf, "unparsable image: \"%s\"", s);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 error (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 assert (pix_len == strlen (pix_name));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 /* Read the pixmap file name for this image from the resource db */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 XtResource resource [1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 resource[0].resource_name = pix_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 resource[0].resource_class = XtCBitmap;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 resource[0].resource_type = XtRString;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 resource[0].resource_size = sizeof (char *);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 resource[0].resource_offset = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 resource[0].default_type = XtRImmediate;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 resource[0].default_addr = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 file = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 XtGetSubresources (FRAME_X_SHELL_WIDGET (XFRAME (Fselected_frame (Qnil))),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (XtPointer) &file, "image", "Image", resource, 1, NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 if (! file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 result = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 Lisp_Object lfile = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 Lisp_Object p = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 struct gcpro gcpro1, gcpro2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 sprintf (buf, "attribute%d", attr_number);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 GCPRO2 (lfile, p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 lfile = build_string (file);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 p = Fmake_image_instance (lfile, Qnil); /* may gc */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 result = image_instance_to_glyph (p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 Vall_energize_pixmaps = Fcons (Fcons (make_int (result), p),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 Vall_energize_pixmaps);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 if (!EQ (p, glyph_to_image_instance (result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 if (XIMAGE_INSTANCE (p)->depth == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 /* if depth is >0 then this is an XPM, and its colors are not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 controlled by the fg/bg of a face. So don't bother making a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 face for it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 Lisp_Object face, fg, bg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 struct face *c_face;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 /* #### review this */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 face = Fmake_face (intern (buf));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 fg = FACE_FOREGROUND (face, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 bg = FACE_BACKGROUND (face, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 Fcolorize_image_instance (p, fg, bg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 /* CGetVstring returns a pointer into the connection buffer; we need to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 copy it to use it as a hash key. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 s = strdup (s);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 hashed = result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 puthash ((void *) s, (void *) hashed, image_cache);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 /* Parses Classes from the connection buffer. Defines them for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 * the buffer given as argument */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 read_energize_class_data (Connection *conn, unsigned int number,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 BufferInfo *binfo, unsigned int modify_ok)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 CClass *ptr; /* pointer to class data in buffer */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 GDataClass *cl; /* unmodified class data */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 GLYPH g;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 for (i = 0; i < number; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 ptr = CGet (conn, CClass);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 g = read_energize_image_data (conn, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 cl = get_class (ptr->classId, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 if (!cl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 cl = alloc_GDataclass (ptr->classId, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 else if (!modify_ok)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 message("Attempt to create class with existing Id %8x", ptr->classId);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 if (ignore_kernel) continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 /* if it did exist, we just clobber it */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 if (cl->flags != ptr->flags)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 cl->flags = ptr->flags;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 BUF_FACECHANGE (XBUFFER (binfo->emacs_buffer))++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 if (cl->glyph != g)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 cl->glyph = g;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 BUF_FACECHANGE (XBUFFER (binfo->emacs_buffer))++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 /* Parse GenericData form the connection buffer. Defines them for the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 * given as argument */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 read_energize_generic_data (Connection *conn, unsigned int number,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 BufferInfo *binfo, unsigned int modify_ok)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 CGeneric *ptr;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 GenericData *gen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 GDataClass *cl;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 GLYPH g;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 for (i = 0; i < number; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 ptr = CGet (conn, CGeneric);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 g = read_energize_image_data (conn, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 gen = get_generic (ptr->genericId, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 cl = get_class (ptr->classId, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 if (!gen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 /* create generic if it didn't already exist */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 if (!cl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 message ("Attempt to create generic %8x with undefined class %8x",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 ptr->genericId, ptr->classId);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 gen = alloc_GenericData (ptr->genericId, cl, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 gen->glyph = g;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 if (ptr->flags != 0xff) gen->flags = ptr->flags;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 gen->attribute = ptr->attribute;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 else if (!modify_ok)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 message("Attempt to create generic with existing id %8x",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 ptr->genericId);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 else{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 /* modify the generic */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 int modified = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 if (cl != gen->cl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 modified = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 gen->cl = cl;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 if (gen->glyph != g)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 modified = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 gen->glyph = g;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 if (ptr->flags != 0xff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 modified = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 gen->flags = ptr->flags;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 if (gen->attribute != ptr->attribute)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 modified = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 gen->attribute = ptr->attribute;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 if (modified)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 BUF_FACECHANGE (XBUFFER (binfo->emacs_buffer))++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 insert_one_extent (CExtent* ptr, BufferInfo* binfo, int modify_ok)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 Energize_Extent_Data *ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 GenericData *gen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 Bufpos extent_start;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 Bufpos extent_end;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 int set_endpoints_p = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 int created_ext_data = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 Lisp_Object buffer = binfo->emacs_buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 ext = get_extent_data (ptr->extentId, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 if (!ext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 ext = (Energize_Extent_Data *) xmalloc (sizeof (Energize_Extent_Data));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 created_ext_data = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 ext->seal = EXTENT_SEAL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 ext->id = ptr->extentId;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 ext->extentType = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 ext->extent = Qnil; /* not a normal value: set before we return */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 ext->start_pixmap = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 ext->end_pixmap = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 ext->warn_modify = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 put_extent_data (ext->id, binfo, ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 else if (!modify_ok)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 message ("Creating extent with existing id %8x", ptr->extentId);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 ext->extentType = ptr->extentType;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 switch (ptr->extentType)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 case CEAttribute:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 ext->u.attr.attrValue = ptr->data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 case CEAbbreviation:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 ext->u.abbrev.isOpened = ptr->data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 case CEWriteProtect:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 case CEGeneric:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 gen = get_generic (ptr->data, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 if (!gen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 message ("NewExtents: Nonexistent generic data %8x", ptr->data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 ext->u.generic.gData = gen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 message ("Unknown extent type %d", ptr->extentType);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 /* instruct redisplay to recompute the frame */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 BUF_FACECHANGE (XBUFFER (binfo->emacs_buffer))++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 /* ptr->startPosition == ptr->endPosition == ~0 means to not change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 * the extent endpoints */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 if (ptr->startPosition == ~0 && ptr->endPosition == ~0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 set_endpoints_p = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 extent_start = ~0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 extent_end = ~0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 struct buffer *b = XBUFFER (buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 extent_start = BufposForEnergizePos (ptr->startPosition, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 extent_end = BufposForEnergizePos (ptr->endPosition, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 /* We have to be careful to create the extents with endpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 which are in the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 Under certain obscure conditions involving changes made outside
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 of Emacs (bug 19983), the server and the editor can have different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 ideas about where the extents are, so these numbers can be off
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 temporarily (during the window between read_energize_extent_data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 and Qenergize_auto_revert_buffer in read_energize_buffer_data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 from ModifyBufferRType).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 /* Don't allow 0-length extents, as they tend to disappear. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 if (extent_start >= extent_end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 extent_end = extent_start + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 /* Don't let them outside the buffer (even if we grew them). */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 if (extent_start >= BUF_Z (b)) extent_start = BUF_Z (b) - 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 if (extent_end >= BUF_Z (b)) extent_end = BUF_Z (b) - 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 if (extent_start < BUF_BEG (b)) extent_start = BUF_BEG (b);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 if (extent_end < BUF_BEG (b)) extent_end = BUF_BEG (b);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 /* If they're 0-length again, then the extent must be at point-max.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 In that case, extent it backward (if possible) instead of forward.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 if (extent_start >= extent_end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 && BUF_BEG (b) != BUF_Z (b))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 extent_start = extent_end - 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 /* no zero width extent */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 if (set_endpoints_p && extent_start == extent_end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 extent_end += 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 /* Now create the extent for the extent-data. There is a 1:1 mapping between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 these, and an extent-data points at an extent (and that extent points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 back) until energize tells us to delete the extent. This is the only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 function in which ext->extent is ever not an extent. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 if (created_ext_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 ext->extent = Fmake_extent (make_int (extent_start),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 make_int (extent_end), buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 set_energize_extent_data (XEXTENT (ext->extent), ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 restore_energize_extent_state (XEXTENT (ext->extent));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 if (!EQ (buffer, extent_buffer (XEXTENT (ext->extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 signal_simple_error_2 ("extent not part of buffer", ext->extent,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 if (set_endpoints_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 Fset_extent_endpoints (ext->extent, make_int (extent_start),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 make_int (extent_end), Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 restore_energize_extent_state (XEXTENT (ext->extent));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 if (energize_extent_data (XEXTENT (ext->extent)) != ext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 extent_duplicable_p (XEXTENT (ext->extent)) = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 extent_unique_p (XEXTENT (ext->extent)) = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 /* Parse GenericData from the connection buffer. Defines them for the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 * given as argument. Creates the Emacs extents while parsing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 * Energize sends the extents ordered by increasing starting position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 I don't think the following is true any more:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 * Emacs is __much__ faster at inserting them in decreasing starting position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 * also for overlaps to work correctly the outmost extents have to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 * inserted first. This is what the recursive function is trying to do.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 read_energize_extent_data (Connection *conn, unsigned int number,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 BufferInfo *binfo, unsigned int modify_ok,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 int extent_offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 CExtent* all_extents;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 /* Gets the extents from the connection */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 all_extents = CGetN (conn, CExtent, number);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 /* adjusts the endpoints with the offset */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 for (i = 0; i < number; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 if (all_extents [i].startPosition != ~0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 all_extents [i].startPosition += extent_offset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 if (all_extents [i].endPosition != ~0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 all_extents [i].endPosition += extent_offset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 /* inserts them all */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 for (i = number - 1; i >= 0; i--)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 insert_one_extent (all_extents + i, binfo, modify_ok);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 /* Parses a CBuffer in the connection stream. If (delete_from != delete_to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 all characters in this range must be deleted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 string_buffer_compare (char *string, int string_len,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 struct buffer *buf, Bufpos bufpos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 /* !!#### needs to be rewritten for Mule */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 Bufpos first_section_end = BUF_CEILING_OF (buf, bufpos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 /* degenerate case, which we consider to be "true" */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 if (string_len == 0) return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 /* string won't fit in the buffer, so comparison fails */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 if (BUF_Z (buf) < (bufpos + string_len)) return -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 /* bad starting position, so comparison fails */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 if (bufpos < BUF_BEG (buf)) return -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 char *first_section_chars = (char *) BUF_BYTE_ADDRESS (buf, bufpos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 int comp = strncmp (string, first_section_chars,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 first_section_end - bufpos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 if (comp) return comp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 if (first_section_end < BUF_ZV (buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 /* there is a second section */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 char *second_section_chars =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 (char *) BUF_BYTE_ADDRESS (buf, first_section_end);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 int comp = strncmp (string + (first_section_end - bufpos),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 second_section_chars,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 BUF_ZV (buf) - first_section_end);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 if (comp) return comp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 /* called by unwind protect, from within ParseBuffer and HandleRemoveExtents */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 restore_buffer_state (Lisp_Object state_cons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 Lisp_Object bufferId_obj = Fcar (state_cons);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 unsigned int bufferId = (unsigned int) get_opaque_ptr (bufferId_obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 Lisp_Object buffer_modified_state = Fcar (Fcdr (state_cons));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 Lisp_Object clear_undo_list = Fcdr (Fcdr (state_cons));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 if (bufferId != 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 if (energize_connection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 && (binfo = get_buffer_info_for_id (bufferId, energize_connection))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 && !NILP (binfo->emacs_buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 /* Always ignore what Energize tells us about the buffer read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 state. For files Emacs knows better and for non-file buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 Emacs is hacking the read-only state anyway so let it be. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 XBUFFER (binfo->emacs_buffer)->read_only = buffer_modified_state;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 if (!NILP (clear_undo_list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 XBUFFER (binfo->emacs_buffer)->undo_list = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 /* this is just temporary */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 message ("Bad bufferId cons cell!");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 /* #### this shit should be using generate-new-buffer */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 rename_the_buffer (Lisp_Object new_name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 int count = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 char number [8];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 struct gcpro gcpro1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 Lisp_Object name = new_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 GCPRO1 (name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 while (!NILP (Fget_buffer (name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 sprintf (number, "<%d>", ++count);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 name = concat2 (new_name, build_string (number));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 Frename_buffer (name, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 destroy_if_energize_extent (EXTENT e, void* arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 struct Energize_Extent_Data *ext = energize_extent_data (e);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 if (ext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 Lisp_Object extent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 Lisp_Object buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 BufferInfo *binfo = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 XSETEXTENT (extent, e);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 buffer = extent_buffer (XEXTENT (extent));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 Fdelete_extent (extent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 if (BUFFERP (buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 binfo = get_buffer_info_for_emacs_buffer (buffer, energize_connection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 if (binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 free_Energize_Extent_Data (ext, binfo, OFT_GC);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 /* #### partly duplicated in free_Energize_Extent_Data() */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 set_energize_extent_data (e, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 ext->extent = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 destroy_all_energize_extents (struct buffer *buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 map_extents (BUF_BEG (buf), BUF_Z (buf), destroy_if_energize_extent,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 NULL, make_buffer (buf), 0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 ME_END_CLOSED | ME_MIGHT_MODIFY_EXTENTS);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 restore_inside_parse_buffer (Lisp_Object val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 inside_parse_buffer = XINT (val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 return (val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 hack_window_point (Lisp_Object window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 Lisp_Object old_point,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 Lisp_Object old_start,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 int keep_start_p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 BufferInfo *binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 /* If we've reverted a buffer, sometimes we want to make sure that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 the window-point doesn't move. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 if (NILP (window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 Fset_marker (XWINDOW (window)->pointm, old_point, binfo->emacs_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 if (NILP (binfo->output_mark) && keep_start_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 Fset_marker (XWINDOW (window)->start, old_start, binfo->emacs_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 XWINDOW (window)->force_start = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 read_energize_buffer_data (Connection *conn, CBuffer *cbu, Editor *editor,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 EnergizePos delete_from, EnergizePos delete_to,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 Window win, int relative_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 char *name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 ReqLen name_len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 char *pathname_str;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 ReqLen pathname_len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 char *buffer_class_str;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 ReqLen buffer_class_len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 Lisp_Object pathname = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 Lisp_Object pathname_directory = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 Lisp_Object buffer_name = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 Lisp_Object filename = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 #if 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 Lisp_Object display_window = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 int modifying_p = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 Bufpos previous_point;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 Bufpos from;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 Bufpos to;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 #if 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 Bufpos display_start = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 char *text;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 ReqLen text_len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 int get_chars_from_file = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 Lisp_Object modified_buffer_flag;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 int speccount = specpdl_depth ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 int extent_offset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 Lisp_Object restore_buffer_state_cons;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 int should_keep_window_start = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 int no_text_deleted = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 /* For some reason calling the GC before parsing the buffer data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 makes a better usage of memory and emacs leaks less when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 creating/deleting LE browser buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 However you don't want to call GC all the tiem so we only do it if the request
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 will create more than a given number of extents. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 if (cbu->nExtent > energize_extent_gc_threshold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 garbage_collect_1 ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 record_unwind_protect (save_restriction_restore, save_restriction_save ());
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 Fwiden (Fcurrent_buffer ());
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 GCPRO4 (buffer_name, pathname, pathname_directory, filename);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 name = CGetVstring (conn, &name_len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 /* read the pathname and buffer-class -- Editor Protocol > 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 pathname_str = CGetVstring (conn, &pathname_len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 buffer_class_str = CGetVstring (conn, &buffer_class_len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 if (name_len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 buffer_name = build_string (name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 if (pathname_len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 pathname = build_string (pathname_str);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 /* set up pathname_directory */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 if (!NILP (pathname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 if (NILP (Ffile_directory_p (pathname)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 pathname_directory = Ffile_name_directory (pathname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 pathname_directory = pathname;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 /* make sure that pathname_directory ends with a '/', if it exists */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 if (!NILP (pathname_directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 {
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
1614 Bufbyte *str = XSTRING_DATA (pathname_directory);
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
1615 Bytecount size = XSTRING_LENGTH (pathname_directory);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 if (str[size - 1] != '/')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 Lisp_Object tmp = make_string (str, size + 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 set_string_byte (XSTRING (tmp), size, '/');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 pathname_directory = tmp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 /* get or create the BufferInfo */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 if (binfo = get_buffer_info_for_id (cbu->bufferId, editor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 modifying_p = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 if (NILP (buffer_name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 char *dummy = "*Unnamed " IDENTITY_CRISIS " Buffer*";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 buffer_name = build_string (dummy);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 /* create new buffer */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 binfo = alloc_BufferInfo (cbu->bufferId, buffer_name, pathname,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 buffer_class_str, editor, win,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 cbu->nExtent + cbu->nClass + cbu->nGeneric);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 XBUFFER (binfo->emacs_buffer)->read_only =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 cbu->flags == CBReadOnly ? Qt : Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 /* remember where we were in which buffer before we change things */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 if (current_buffer != XBUFFER (binfo->emacs_buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 record_unwind_protect (save_excursion_restore, save_excursion_save ());
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 Fset_buffer (binfo->emacs_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 /* set default-directory */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 if (!NILP (pathname_directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 if (!NILP (Ffile_directory_p (pathname_directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 && !NILP (Ffile_executable_p (pathname_directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 Fset (Qdefault_directory, pathname_directory);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 /* Never set this to nil, that loses badly. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 /* else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 Fset (Qdefault_directory, Qnil); */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 /* set file name unless it's a directory */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 if (!NILP (pathname) && NILP (Ffile_directory_p (pathname)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 filename = Fexpand_file_name (pathname, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 Fset (Qbuffer_file_name, filename);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 /* set buffer name */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 if (!NILP (buffer_name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 if (modifying_p
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
1672 && strcmp ((char*) XSTRING_DATA (buffer_name),
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
1673 (char*) XSTRING_DATA (XBUFFER (binfo->emacs_buffer)->name)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 rename_the_buffer (buffer_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 if (modifying_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 run_hook (Venergize_kernel_modification_hook);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 /* Make sure buffer is current after the hook */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 Fset_buffer (binfo->emacs_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 modified_buffer_flag = Fbuffer_modified_p (binfo->emacs_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 /* enables buffer edits */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 restore_buffer_state_cons =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 Fcons (make_opaque_ptr ((void *) cbu->bufferId),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 Fcons (XBUFFER (binfo->emacs_buffer)->read_only, Qt));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 record_unwind_protect (restore_buffer_state, restore_buffer_state_cons);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 XBUFFER (binfo->emacs_buffer)->read_only = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 /* any changes here should take place "underneath" these hooks, I think */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 specbind (Qenergize_buffer_modified_hook, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 specbind (Qfirst_change_hook, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 specbind (Qbefore_change_functions, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 specbind (Qbefore_change_function, Qnil); /* #### */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 /* As energize does not use the after-change-function it's not useful to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 bind it to NIL */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 /* specbind (Qafter_change_functions, Qnil); */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 /* specbind (Qafter_change_function, Qnil); #### */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 specbind (Qinhibit_read_only, Qt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 record_unwind_protect (restore_inside_parse_buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 make_int (inside_parse_buffer));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 inside_parse_buffer = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 specbind (Qbuffer_undo_list, Qt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 XBUFFER (binfo->emacs_buffer)->undo_list = Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 /* BufposForEnergizePos uses the current-buffer */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 from = BufposForEnergizePos (delete_from, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 to = BufposForEnergizePos (delete_to, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 /* See if we should get the characters from the file directly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 Only protocol 0.10+ will do this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 #ifdef ENERGIZE_V2_HEADERS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 get_chars_from_file = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 if (cbu->flags != 0xff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 get_chars_from_file = cbu->flags & CBFileYourself;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 get_chars_from_file = binfo->flags & CBFileYourself;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 /* Even when we get the chars from a file there is an empty text string */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 if (get_chars_from_file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 text = CGetVstring (conn, &text_len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 text = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 text_len = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 text = CGetVstring (conn, &text_len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 /* updates the visited file modtime */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 if (modifying_p && (from != to || text_len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 /* but only when we do not read the file ourselves */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 && !get_chars_from_file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 Fset_buffer_modtime (binfo->emacs_buffer, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 if (!modifying_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 /* clears the buffer in case we re-use a non-energize buffer */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 previous_point = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 Fset_buffer (binfo->emacs_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 buffer_delete_range (current_buffer, BUF_BEG (current_buffer),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 BUF_Z (current_buffer), 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 #if 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 display_window = Fget_buffer_window (binfo->emacs_buffer, Qnil, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 previous_point = BUF_PT (current_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 #if 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 if (!NILP (display_window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 display_start =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 XINT (Fmarker_position (XWINDOW (display_window)->start));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 if (from != to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 struct buffer *buf = XBUFFER (binfo->emacs_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 Fset_buffer (binfo->emacs_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 Fwiden (Fcurrent_buffer ());
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 if (!NILP (binfo->output_mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 && marker_position (binfo->output_mark) >= from)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 Fset_marker (binfo->output_mark, make_int (from),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 binfo->emacs_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 if (((to - from) == text_len) && !get_chars_from_file &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 !string_buffer_compare (text, text_len, buf, from))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 /* the new text is the same as the old text, don't clear
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 the undo list*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 Fsetcdr (Fcdr (restore_buffer_state_cons), Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 no_text_deleted = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 destroy_all_energize_extents (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 /* Do not keep window start if we actually delete text */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 should_keep_window_start = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 Fset_buffer (binfo->emacs_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 destroy_all_energize_extents (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 if (!get_chars_from_file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 buffer_delete_range (current_buffer, from, to, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 /* Do not clear the undo list if getting the chars from the file */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 if (get_chars_from_file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 Fsetcdr (Fcdr (restore_buffer_state_cons), Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 else if (!text_len && !get_chars_from_file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 /* if there is no text and we didn't delete anything,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 don't clear the undo_list slot */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 Fsetcdr (Fcdr (restore_buffer_state_cons), Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 /* buffer type */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 if (cbu->flags != 0xff && cbu->flags != binfo->flags)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 if (!modifying_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 if (cbu->flags == CBUserInput)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 Lisp_Object buffer_local_variable_name =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 Qenergize_user_input_buffer_mark;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 binfo->output_mark = Fmake_marker ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 Fset_marker (binfo->output_mark, make_int (1),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 binfo->emacs_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 /* make sure that this guy doesn't get GC'd out from under us */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 Fmake_local_variable (buffer_local_variable_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 Fput (buffer_local_variable_name, Qpermanent_local, Qt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 Fset (buffer_local_variable_name, binfo->output_mark);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 /* Make sure buffer is current after the hook */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 Fset_buffer (binfo->emacs_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 binfo->flags = cbu->flags;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 if (get_chars_from_file && text_len != 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 /* I think this is always true, but let's make sure - jwz */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 if (text_len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 if (!NILP (binfo->output_mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 Fset_buffer (binfo->emacs_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 if (XMARKER (binfo->output_mark)->buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 Fgoto_char (binfo->output_mark, Fcurrent_buffer ());
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 /* This should not happen */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 Fgoto_char (make_int (BUF_ZV (XBUFFER (binfo->emacs_buffer))),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 Fcurrent_buffer ());
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 if (BUF_PT (current_buffer) <= previous_point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 #if 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 display_start += text_len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 previous_point += text_len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 buffer_insert_raw_string (current_buffer, text, text_len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 Fset_marker (binfo->output_mark, make_int (BUF_PT (current_buffer)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 binfo->emacs_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 else if (modifying_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 Fgoto_char (make_int (from), Fcurrent_buffer ());
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 if (!no_text_deleted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 buffer_insert_raw_string (current_buffer, text, text_len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 buffer_insert_raw_string (current_buffer, text, text_len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 previous_point = XINT (Fgoto_char (make_int (previous_point)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 Fcurrent_buffer ());
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 else if (get_chars_from_file && !modifying_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 /* !modifying_p means the buffer is being created - read the text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 from the file. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 Finsert_file_contents_internal (Fbuffer_file_name (binfo->emacs_buffer),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 /* #### coding system not correct */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 Qt, Qnil, Qnil, Qnil, Qnil, Qnil));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 if (!relative_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 extent_offset = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 else if (!NILP (binfo->output_mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 extent_offset = EnergizePosForBufpos (XINT (Fmarker_position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 (binfo->output_mark)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 extent_offset = EnergizePosForBufpos (BUF_Z(XBUFFER(binfo->emacs_buffer)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 #if 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 if (text_len || !text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 hack_window_point (display_window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 make_int (previous_point),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 make_int (display_start),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 should_keep_window_start,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 /* Classes, generics and extents */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 /* make sure that we have enough room in the hash table */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 expand_hashtable (binfo->id_to_object,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 cbu->nClass + cbu->nGeneric + cbu->nExtent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 read_energize_class_data (conn, cbu->nClass, binfo, modifying_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 read_energize_generic_data (conn, cbu->nGeneric, binfo, modifying_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 read_energize_extent_data (conn, cbu->nExtent, binfo, modifying_p, extent_offset);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 /* Restore the modified bit */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 Fset_buffer_modified_p (modified_buffer_flag, binfo->emacs_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 if (get_chars_from_file && modifying_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 /* modifying_p means the buffer already exists and the extents are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 being re-written. It may be that the file has changed on disk,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 and the extents no longer correspond to the text in the buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 which would be bad. So, check the file on disk, and if it has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 changed, offer to revert.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 As this runs lisp code which may prompt the user, and consequently
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 may accept process output, be careful to do this after we have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 finished reading the current request from the Energize connection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 if (NILP (Fverify_visited_file_modtime (binfo->emacs_buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 call1 (Qenergize_auto_revert_buffer, binfo->emacs_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 hack_window_point (display_window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 make_int (previous_point),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 make_int (display_start),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 1,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 /* restore modified hooks and globals, and return the previous buffer */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 unbind_to (speccount, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 cleanly_destroy_all_widgets (int count, LWLIB_ID *ids)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 /* This just calls lw_destroy_all_widgets, but is careful to make sure that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 this doesn't cause the frames to shrink. If one deletes psheets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 (children of the "control" area of the MainWindow) without first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 unmanaging the MainWindow, the frame resizes. So first unmanage all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 the MainWindows of all applicable frames, then remanage them. This is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 nasty, but...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 Lisp_Object frmcons, devcons, concons;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 int i, j;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 if (count == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 Lisp_Object frame = XCAR (frmcons);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 struct frame *f = XFRAME (frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 if (!FRAME_X_P (f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 /* Optimization: only unmanage the MainWindow if this frame is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 displaying one of the psheets in question. (Special casing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 the debugger panel as usual...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 for (i = 0; i < count; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 if (ids [i] == debuggerpanel_sheet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 XtUnmanageChild (FRAME_X_CONTAINER_WIDGET (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 goto next_frame;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 for (j = 0; j < FRAME_X_CURRENT_PSHEET_COUNT (f); j++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 if (ids [i] == FRAME_X_CURRENT_PSHEETS (f) [j])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 XtUnmanageChild (FRAME_X_CONTAINER_WIDGET (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 goto next_frame;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 next_frame: ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 for (i = 0; i < count; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 lw_destroy_all_widgets (ids [i]);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 if (ids [i] == debuggerpanel_sheet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 debuggerpanel_sheet = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 desired_debuggerpanel_exposed_p = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 Lisp_Object frame = XCAR (frmcons);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 struct frame *f = XFRAME (frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 if (!FRAME_X_P (f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 XtManageChild (FRAME_X_CONTAINER_WIDGET (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 /* kill an Energize buffer */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 forget_buffer (BufferInfo *binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 Lisp_Object buffer = binfo->emacs_buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 remove_buffer_info (binfo->id, buffer, binfo->editor);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 Venergize_buffers_list = Fdelq (buffer, Venergize_buffers_list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 /* if there was an associated frame */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 if (!NILP (binfo->frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 Fdelete_frame (binfo->frame, Qt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 if (binfo->n_p_sheets > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 /* Also delete the dialog boxes associated with the buffer. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 cleanly_destroy_all_widgets (binfo->n_p_sheets,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 (LWLIB_ID *) binfo->p_sheet_ids);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 free_buffer_info (binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 XBUFFER (buffer)->undo_list = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026 /* flush the buffer SOE before flushing the extents */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 free_buffer_cached_stack (XBUFFER (buffer));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028 XBUFFER (buffer)->extents = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 /********************** Request-related utilities ************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 /* outputs a single extent in the connection buffer */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 write_energize_extent_data (Connection *conn, Energize_Extent_Data *ext,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 unsigned int start, unsigned int end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 switch (ext->extentType)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 case CEAttribute:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 CWriteExtent (conn, CEAttribute, ext->id, start, end,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 (EId)ext->u.attr.attrValue);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 case CEAbbreviation:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 CWriteExtent (conn, CEAbbreviation, ext->id, start, end,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 (EId)ext->u.abbrev.isOpened);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 case CEGeneric:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 CWriteExtent (conn, CEGeneric, ext->id, start, end, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 case CEWriteProtect:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 CWriteExtent (conn, CEWriteProtect, ext->id, start, end, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 /* Function called by map_extents in SaveBufferToEnergize. Outputs the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 extents for the extents corresponding to Energize objects, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 increments the n_extents count. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065 write_energize_extent_data_mapper (EXTENT extent, void *arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067 binfo_and_n_extents *bane = (binfo_and_n_extents*)arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 Lisp_Object extent_obj;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069 Energize_Extent_Data *ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 XSETEXTENT (extent_obj, extent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 ext = extent_to_data (extent_obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 if (ext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 Bufpos first = XINT (Fextent_start_position (extent_obj));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 Bufpos last = XINT (Fextent_end_position (extent_obj));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077 write_energize_extent_data (bane->binfo->editor->conn, ext,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 EnergizePosForBufpos (first, bane->binfo),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 EnergizePosForBufpos (last, bane->binfo));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 bane->n_extents += 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 /* Sends a BufferSaved request to energize for binfo */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 write_energize_buffer_data (BufferInfo *binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 Connection *conn = binfo->editor->conn;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 EId bufferId = binfo->id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 CBuffer *cbu;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 CEditorRequest *req;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 struct buffer *cur_buff = current_buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 int speccount = specpdl_depth ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 Lisp_Object file_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 binfo_and_n_extents bane;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 /* selects the buffer as current */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 Fset_buffer (binfo->emacs_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 /* write header */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 cbu = CWriteBufferSavedHeader (conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 cbu->bufferId = bufferId;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 cbu->flags = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 cbu->nClass = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 cbu->nGeneric = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 /* file name */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 file_name = current_buffer->filename;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 if (STRINGP (file_name))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
2112 CWriteVstring0 (conn, XSTRING_DATA (file_name));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 CWriteVstring0 (conn, "");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 CWriteVstring0 (conn, ""); /* directory name */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116 CWriteVstring0 (conn, ""); /* buffer name */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 /* write the text */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119 #ifndef ENERGIZE_V2_HEADERS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 if (binfo->flags & CBFileYourself)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 /* Only the 0.10+ protocol will ask us to write the file directly. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 Lisp_Object start;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 Lisp_Object end;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125 XSETINT (start, BUF_BEG (current_buffer));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 XSETINT (end, BUF_Z (current_buffer));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 Fwrite_region_internal (start, end,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 Fbuffer_file_name (binfo->emacs_buffer),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129 /* #### coding system not correct */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 Qnil, Qt, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 CNeedOutputSize (conn, 9);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 CWriteVstringLen (conn, NULL, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 #endif /* ENERGIZE_V2_HEADERS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 Lisp_Object string = make_string_from_buffer (current_buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 BUF_BEG (current_buffer),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139 BUF_Z (current_buffer));
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
2140 CNeedOutputSize (conn, XSTRING_LENGTH (string) + 9);
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
2141 CWriteVstringLen (conn, XSTRING_DATA (string), XSTRING_LENGTH (string));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 /* write the extents */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 bane.binfo = binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 bane.n_extents = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 /* Only write the extents when not filing ourselves */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 #ifndef ENERGIZE_V2_HEADERS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 if (!(binfo->flags & CBFileYourself))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 map_extents (BUF_BEG (current_buffer), BUF_Z (current_buffer),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 write_energize_extent_data_mapper, &bane,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 binfo->emacs_buffer, 0, ME_END_CLOSED);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 /* update nextent in request's header */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160 req = (CEditorRequest *)conn->header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 req->buffersaved.buffer.nExtent = bane.n_extents;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 CWriteLength (conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 CWriteRequestBuffer (conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 /* sets the flags so that we will warn Energize about more modifications */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 binfo->modified_state = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 /* Mark the buffer as non editable so that we will ask Energize about it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169 before modifying it again */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 binfo->editable = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 /* restores the buffer as current */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 set_buffer_internal (cur_buff);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 unbind_to (speccount, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 static unsigned long
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 energize_extent_data_id (Energize_Extent_Data *ext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 return ext ? ext->id : 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 /********************** Menu ("keywords") operations **********************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 something_answered_p (void* arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 struct reply_wait* rw = (struct reply_wait*)arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 return rw->answered_p || !energize_connection || !energize_connection->conn;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 push_wait (struct reply_wait* rw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 rw->next = global_reply_wait;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 global_reply_wait = rw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 remove_wait (Lisp_Object obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204 struct reply_wait* gw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 struct reply_wait* previous;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 struct reply_wait* rw = (struct reply_wait *) get_opaque_ptr (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208 for (previous = 0, gw = global_reply_wait;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209 gw != rw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210 previous = gw, gw = gw->next);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 if (previous)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 previous->next = gw->next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 global_reply_wait = gw->next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 static struct reply_wait*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 find_wait_reply (int serial)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221 struct reply_wait* gw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222 for (gw = global_reply_wait; gw && gw->serial != serial; gw = gw->next);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 return gw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 wait_for_reply (struct reply_wait* rw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 int speccount = specpdl_depth ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 rw->answered_p = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 push_wait (rw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 record_unwind_protect (remove_wait, make_opaque_ptr (rw));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 wait_delaying_user_input (something_answered_p, rw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 unbind_to (speccount, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 return rw->answered_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 /* gets the menu for the buffer/extent pair at the head of the request buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 returns the propose choice request if succeeds, nil otherwise (kernel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 connection closed, or not connected)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 get_energize_menu (Lisp_Object buffer, Lisp_Object extent_obj, int selection_p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 Lisp_Object only_name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 Connection* conn;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 EId buffer_id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 EId extent_id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 Lisp_Object result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 struct reply_wait rw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 struct gcpro gcpro1, gcpro2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 if (!get_energize_connection_and_buffer_id (buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 (void **) &conn,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 (long *) &buffer_id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 if (EXTENTP (extent_obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 extent_id = energize_extent_data_id (extent_to_data (extent_obj));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 extent_id = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265 CWriteQueryChoicesRequest (conn, buffer_id, extent_id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 conn->header->data =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267 selection_p ? CEChasCharSelection | CEChasObjectSelection : 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 conn->header->serial = ++request_serial_number;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 CWriteRequestBuffer (conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 /* wait for the acknowledge */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 rw.serial = request_serial_number;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 rw.objectId = buffer_id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 rw.genericId = extent_id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 rw.menu_result = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 rw.only_name = only_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 GCPRO2 (rw.menu_result, rw.only_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279 wait_for_reply (&rw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 result = rw.menu_result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 execute_energize_menu (Lisp_Object buffer, Energize_Extent_Data* ext,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288 char* name, EId item_id, EId flags,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 Lisp_Object selection, Lisp_Object no_confirm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 Connection* conn;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 EId buffer_id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293 EId extent_id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294 BufferInfo* binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295 struct reply_wait rw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 if (!get_energize_connection_and_buffer_id (buffer, (void**)&conn,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 (long*)&buffer_id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 extent_id = energize_extent_data_id (ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 if ((flags & CKBuffer) && !NILP (Fbuffer_modified_p (buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 /* saves buffer if requested and needed */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 binfo = get_buffer_info_for_emacs_buffer (buffer, energize_connection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 if (binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 write_energize_buffer_data (binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311 CWriteExecuteChoicesRequest (conn, buffer_id, extent_id, item_id, 0, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 /* send the menu name */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 if (energize_connection->minor >= 7)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 CWriteVstring0 (conn, name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315 conn->header->serial = ++request_serial_number;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316 conn->header->data = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317 if (STRINGP (selection))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 conn->header->data |= CEChasCharSelection;
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
2320 CWriteVstringLen (conn, XSTRING_DATA (selection),
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
2321 XSTRING_LENGTH (selection));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323 else if (VECTORP (selection))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 EId data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327 conn->header->data |= CEChasObjectSelection;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329 /* writes the length */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330 data = vector_length (XVECTOR (selection));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 CWrite (conn, EId, &data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 /* writes the elements */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 for (i = 0; i < vector_length (XVECTOR (selection)); i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336 if (CONSP (vector_data (XVECTOR (selection)) [i]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 data = lisp_to_word (vector_data (XVECTOR (selection)) [i]);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339 data = XINT (vector_data (XVECTOR (selection)) [i]);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 CWrite (conn, EId, &data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 else if (CONSP (selection))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 Lisp_Object type = Fcar (selection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 Lisp_Object value = Fcdr (selection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347 if (EQ (type, intern ("ENERGIZE_OBJECT"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348 && STRINGP (value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350 conn->header->data |= CEChasObjectSelection;
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
2351 CWriteN (conn, char, XSTRING_DATA (value),
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
2352 XSTRING_LENGTH (value));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 else if (!NILP (selection))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 error ("unrecognized energize selection");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 if (!NILP (no_confirm))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 conn->header->data |= CECnoConfirm;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 CWriteLength (conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 CWriteRequestBuffer (conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 /* wait for the acknowledge */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 rw.serial = request_serial_number;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 rw.objectId = buffer_id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 rw.genericId = extent_id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 rw.itemId = item_id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 rw.message = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 if (wait_for_reply (&rw) && !rw.status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 char message [128];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 if (energize_connection && energize_connection->conn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 sprintf (message, IDENTITY_CRISIS " command failed: %.80s",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 (rw.message ? rw.message : "(null)"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 sprintf (message, "Connection to " IDENTITY_CRISIS " was closed.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 if (rw.message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 xfree (rw.message);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 error (message);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384 if (rw.message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 xfree (rw.message);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386 if (!energize_connection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 error ("Connection to " IDENTITY_CRISIS " was closed.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 /* Returns a list of vectors representing the menu choices. Next request
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 in connection must be a ProposeChoices. The list is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 (buffer extent <item1> ... <itemN>). <itemI> is (name id1 id2 flags).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394 Idi is (high . low). We build the list in reverse order and nreverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 it. If (only_name != 0), we only return the item of named only_name as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 a vector. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 list_choices (Lisp_Object buffer, Lisp_Object extent_obj,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 Lisp_Object only_name, CProposeChoicesRequest* creq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402 Connection *conn;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 Lisp_Object item_list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 Lisp_Object item;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406 struct Lisp_Vector *v;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 struct gcpro gcpro1, gcpro2, gcpro3;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 CChoice *choice;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409 ReqLen name_length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 char *name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411 char *arg_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413 if (energize_connection && energize_connection->conn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 conn = energize_connection->conn;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 if (!creq || creq->head.reqType != ProposeChoicesRType)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420 CSkipRequest (conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424 item = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 item_list = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 GCPRO3 (only_name, item_list, item);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 for (i = 0; i < (int)(creq->nChoices); i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431 choice = CGet (conn, CChoice);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 name = CGetVstring (conn, &name_length);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 if (!name_length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 /* the argument, if passed, is another string after the NUL (!)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 * this is a quick hack to provide cheap arguments to menus entries */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438 arg_name = strchr (name, 0240);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 if (arg_name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 *arg_name= 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 arg_name += 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445 if (!NILP (only_name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 {
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
2447 if (!strcmp ((char*) XSTRING_DATA (only_name), name))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 if (NILP (item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 item = make_vector (5, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452 v = XVECTOR (item);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 v->contents [0] = only_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 v->contents [1] = word_to_lisp (choice->choiceId);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456 v->contents [2] = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457 v->contents [3] = make_int (choice->flags);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 v->contents [4] = arg_name ? build_string (arg_name) : Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463 item = make_vector (5, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 v = XVECTOR (item);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 v->contents [0] = build_string (name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 v->contents [1] = word_to_lisp (choice->choiceId);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 v->contents [2] = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 v->contents [3] = make_int (choice->flags);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 v->contents [4] = arg_name ? build_string (arg_name) : Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 item_list = Fcons (item, item_list); /* pushes in the list */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 if (NILP (only_name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 item_list = Fcons (buffer, Fcons (extent_obj, Fnreverse (item_list)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 return NILP (only_name) ? item_list : item;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 DEFUN ("energize-list-menu", Fenergize_list_menu,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482 Senergize_list_menu, 3, 4, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483 Request the set of menu options from the Energize server that are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 appropriate to the buffer and the extent. Extent can be (), in which case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 the options are requested for the whole buffer. Selection-p tells
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486 if the selection is available on the dislpay emacs is using.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 Returns the options as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488 a list that can be passed to energize-activate-menu. Items
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 in the list can also be passed to energize-execute-menu-item.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 The list is (buffer extent or () <item1> ... <itemN>).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 where <itemI> is (name id1 id2 flags); idI is (high . low).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 If optional argument only-name is provided only the item with name only-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 is returned, or () if no such item exists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495 (buffer, extent_obj, selection_p, only_name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 Lisp_Object buffer, extent_obj, selection_p, only_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 Lisp_Object res;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 CHECK_BUFFER (buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 if (!energize_connection || !energize_connection->conn) return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 if (!NILP (only_name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504 CHECK_STRING (only_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 res = get_energize_menu (buffer, extent_obj, !NILP (selection_p),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507 only_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 notify_delayed_requests ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 return res;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512 DEFUN ("energize-execute-menu-item", Fenergize_execute_menu_item,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 Senergize_execute_menu_item, 3, 5, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514 Item is a vector received by energize-list-menu. Sends a request to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 execute the code associated to this menu inside the Energize server.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516 Optional fourth argument is a string or a vector to be used as the selection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 for entry disabled because they need the selection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 Optional fifth argument, if non NIL, tells Energize to not request
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 confirmation before executing the command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 (buffer, extent_obj, item, selection, no_confirm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 Lisp_Object buffer, extent_obj, item, selection, no_confirm;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 struct Lisp_Vector *v;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 if (!energize_connection || !energize_connection->conn) return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 CHECK_BUFFER (buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 CHECK_VECTOR (item);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530 v = XVECTOR (item);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 if (vector_length (v) != 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533 error ("Bad menu item to energize-execute-menu-item");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 /* ignore the flags for now */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 execute_energize_menu (buffer, extent_to_data (extent_obj),
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
2537 (char*) XSTRING_DATA (v->contents [0]),
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 lisp_to_word (v->contents [1]),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 XINT (v->contents [3]),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 selection,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 no_confirm);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543 return Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546 DEFUN ("energize-execute-command-internal", Fenergize_execute_command_internal,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 Senergize_execute_command_internal, 3, 5, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 Command is a string naming an energize command. Sends a request to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 execute this command inside the Energize server.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 Optional fourth argument is a string or a vector to be used as the selection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 Optional fifth argument, if non NIL, tells Energize to not request
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 confirmation before executing the command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 See also 'energize-list-menu'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 (buffer, extent_obj, command, selection, no_confirm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 Lisp_Object buffer, extent_obj, command, selection, no_confirm;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 if (!energize_connection || !energize_connection->conn) return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 CHECK_BUFFER (buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 CHECK_STRING (command);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 execute_energize_menu (buffer, extent_to_data (extent_obj),
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
2565 (char*) XSTRING_DATA (command), 0, 0, selection,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 no_confirm);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 return Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 /********************************* kill buffer interface ****************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 DEFUN ("energize-buffer-type-internal",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 Fenergize_buffer_type, Senergize_buffer_type,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 Return a symbol denoting the buffer type if buffer is an Energize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 buffer, else it returns NIL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 Lisp_Object buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 if (!energize_connection) return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 CHECK_BUFFER (buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 return get_buffer_type_for_emacs_buffer (buffer, energize_connection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 DEFUN ("set-energize-buffer-type-internal",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 Fset_energize_buffer_type_internal,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 Sset_energize_buffer_type_internal, 2, 2, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 Return the type symbol which is the new buffer-type, if the buffer is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 an Energize buffer and the type is non-NIL symbol, else it returns NIL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 (buffer, type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 Lisp_Object buffer, type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 if (!energize_connection || (NILP (type))) return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 CHECK_BUFFER (buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 CHECK_SYMBOL (type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 if (!(binfo =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 get_buffer_info_for_emacs_buffer (buffer, energize_connection)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608 return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 set_buffer_type_for_emacs_buffer (buffer, energize_connection, type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612 DEFUN ("energize-buffer-p", Fenergize_buffer_p, Senergize_buffer_p, 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613 Whether buffer is an Energize buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615 (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616 Lisp_Object buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620 if (!energize_connection) return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 CHECK_BUFFER (buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623 if (!(binfo =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624 get_buffer_info_for_emacs_buffer (buffer, energize_connection)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 return Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 DEFUN ("energize-buffer-id", Fenergize_buffer_id, Senergize_buffer_id, 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 Return (high . low) if buffer is an Energize buffer, otherwise nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633 (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 Lisp_Object buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2635 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638 if (!energize_connection) return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2640 CHECK_BUFFER (buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641 if (!(binfo =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642 get_buffer_info_for_emacs_buffer (buffer, energize_connection)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2643 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2644 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645 return word_to_lisp (binfo->id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2646 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2647
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 DEFUN ("energize-request-kill-buffer", Fenergize_request_kill_buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649 Senergize_request_kill_buffer, 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650 Sends a request to energize for killing buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2651 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2652 (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2653 Lisp_Object buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2655 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2656
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2657 if (!energize_connection) return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2659 CHECK_BUFFER (buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2660 if (!(binfo = get_buffer_info_for_emacs_buffer (buffer, energize_connection)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663 /* Tell Energize about it if connected */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664 if (energize_connection->conn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 CWriteKillBufferHeader (energize_connection->conn, binfo->id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667 CWriteRequestBuffer (energize_connection->conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670 /* Clears the internal state */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2671 forget_buffer (binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2673 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2674 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2675
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2676 /******************** Handle requests from the kernel *********************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2677
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2678 #ifdef EMACS_BTL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2679 #include "cadillac-btl-extern.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2680 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2681
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2682 /* turn logging on or off, etc. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2683 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2684 handle_logging_request (Editor *editor, CLoggingRequest *creq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2685 /* I'm a lumberjack and I'm ok... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2686 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2687 ReqLen name_len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2688 char* data_filename = CGetVstring (editor->conn, &name_len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2689
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2690 #ifdef EMACS_BTL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2691 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2692 char *execname =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2693 (STRINGP (Vinvocation_directory))?
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
2694 ((char *) XSTRING_DATA (Vinvocation_directory)):0;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2695
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2696 switch (creq->type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2697 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2698 case CLRInitBTL:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2699 cadillac_terminate_logging (); /* #### rename me */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2700 cadillac_initialize_backtrace_logging /* #### rename me */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2701 (data_filename, execname, (long) creq->limit, (long) creq->interval);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2702 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2703
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2704 case CLRInitPCL:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2705 cadillac_terminate_logging (); /* #### rename me */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2706 cadillac_initialize_pc_logging /* #### rename me */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2707 (data_filename, execname, (long) creq->limit, (long) creq->interval);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2708 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2709
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2710 case CLRStart:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2711 cadillac_start_logging (); /* #### rename me */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2712 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2713
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2714 case CLRStop:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2715 cadillac_stop_logging (); /* #### rename me */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2716 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2717
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2718 case CLRTerminate:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2719 cadillac_terminate_logging (); /* #### rename me */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2721
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2722 case CLRSetLogSignal:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2723 cadillac_set_log_signal (creq->signal); /* #### rename me */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2724 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2725
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2726 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727 error ("Bad logging request type %d", creq->type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2728 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2731 message ("Logging request, but no such code in image.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2732 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2733 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2734
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2735
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2737 /* creates a new buffer */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2738 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2739 handle_new_buffer_request (Editor *editor, CNewBufferRequest *creq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2740 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2741 read_energize_buffer_data (editor->conn, &creq->buffer, editor, 0, 0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2742 creq->transientId, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2743 if (!NILP (Venergize_create_buffer_hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2744 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2745 CBuffer *cbu = &creq->buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2746 BufferInfo *binfo = get_buffer_info_for_id (cbu->bufferId, editor);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2747 Lisp_Object buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2748 if (binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2749 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2750 Lisp_Object prev_frame;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2751 buffer = binfo->emacs_buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2752 if (!NILP (binfo->frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2753 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2754 prev_frame = Fselected_frame (Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2755 Fselect_frame (binfo->frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2756 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2757 va_run_hook_with_args (Qenergize_create_buffer_hook, 1, buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2758 if (!NILP (binfo->frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2759 Fselect_frame (prev_frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2760 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2761 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2762 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2763
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2764 /* Modifies the contents of a buffer */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2765 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2766 handle_modify_buffer_request (Editor *editor, CModifyBufferRequest *creq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2767 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2768 read_energize_buffer_data (editor->conn, &creq->newData, editor,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2769 creq->startPosition, creq->endPosition,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2770 0, creq->head.data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2771 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2772
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774 make_buffer_and_extent_visible (Lisp_Object list, Lisp_Object go_there)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2775 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2776 call2 (Qenergize_make_many_buffers_visible, list, go_there);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2777 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2778
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2779 /* pops a buffer and scroll to a extent: calls to lisp */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2780 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2781 handle_ensure_visible_request (Editor *editor, CEnsureVisibleRequest *creq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2782 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2783 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2784 Energize_Extent_Data *ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2785 Lisp_Object buffer_extent_list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2786 struct gcpro gcpro1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2787
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2788 buffer_extent_list = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2789 GCPRO1 (buffer_extent_list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2790
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2791 binfo = get_buffer_info_for_id (creq->bufferId, editor);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2792 if (!binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2793 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2794 message ("EnsureVisibleRequest: unknown buffer");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2795 goto finished;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2796 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2797
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2798 if (!NILP (binfo->frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2799 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2800 /* ignore ensure visible for postit note buffers */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2801 goto finished;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2802 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2803
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2804 if (creq->extentId)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2805 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2806 ext = get_extent_data (creq->extentId, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2807 if (!ext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2808 message ("EnsureVisibleRequest: ignoring unknown extent");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2809 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2810 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2811 ext = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2812
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2813 buffer_extent_list = Fcons (ext ? data_to_extent (ext) : Qnil, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2814 buffer_extent_list = Fcons (binfo->emacs_buffer, buffer_extent_list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2815
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2816 make_buffer_and_extent_visible (buffer_extent_list, creq->head.data ? Qt : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2817
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2818 finished:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2819 CSkipRequest (editor->conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2820 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2821 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2822
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2823 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2824 handle_ensure_many_visible_request (Editor *editor,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2825 CEnsureManyVisibleRequest *creq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2826 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2827 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2828 Energize_Extent_Data *ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2829 Lisp_Object buffer_extent_list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2830 int n;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2831 EId buffer_id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2832 EId extent_id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2833 struct gcpro gcpro1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2834
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2835 buffer_extent_list = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2836 GCPRO1 (buffer_extent_list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2837
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2838 for (n = creq->head.data,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2839 buffer_id = creq->bufferId,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2840 extent_id = creq->extentId;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2841 n;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2842 n--,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2843 buffer_id = n ? *(CGet (editor->conn, EId)) : 0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2844 extent_id = n ? *(CGet (editor->conn, EId)) : 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2845 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2846 binfo = get_buffer_info_for_id (buffer_id, editor);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2847 if (!binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2848 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2849 message ("EnsureManyVisibleRequest: ignoring unknown buffer");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2850 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2851 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2852
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2853 if (!NILP (binfo->frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2854 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2855 /* silently ignore ensure visible for postit note buffers */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2856 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2857 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2858
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2859 if (extent_id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2860 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2861 ext = get_extent_data (extent_id, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2862 if (!ext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2863 message ("EnsureManyVisibleRequest: ignoring unknown extent");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2864 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2865 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2866 ext = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2867
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2868 /* cons in reverse order and reverse the list before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2869 calling make_buffer_and_extent_visible */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2870 buffer_extent_list = Fcons (binfo->emacs_buffer, buffer_extent_list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2871 buffer_extent_list = Fcons (ext ? data_to_extent (ext) : Qnil,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2872 buffer_extent_list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2873 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2874 buffer_extent_list = Fnreverse (buffer_extent_list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2875 make_buffer_and_extent_visible (buffer_extent_list, Qt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2876
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2877 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2878 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2879
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2880 /* Update the cached menus, ie update the menubar for now. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2881 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2882 handle_propose_choices_request (Editor *editor, CProposeChoicesRequest *req)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2883 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2884 BufferInfo* binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2885 Lisp_Object buffer = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2886 Lisp_Object extent = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2887 Lisp_Object choices = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2888 struct gcpro gcpro1, gcpro2, gcpro3;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2889 struct reply_wait* rw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2890
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2891 GCPRO3 (buffer, extent, choices);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2892
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2893 /* get the buffer */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2894 binfo = get_buffer_info_for_id (req->objectId, editor);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2895 if (binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2896 buffer = binfo->emacs_buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2897 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2898 buffer = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2900 /* get the extent */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2901 if (binfo && req->genericId)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2902 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2903 Energize_Extent_Data* ext = get_extent_data (req->genericId, binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2904 if (ext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2905 extent = data_to_extent (ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2906 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2907 extent = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2908 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2909 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2910 extent = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2911
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2912 /* find if we were waiting for a reply */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2913 rw = find_wait_reply (req->head.serial);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2914
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2915 /* handle the request */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2916 if (rw && rw->objectId == req->objectId && rw->genericId == req->genericId)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2917 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2918 /* It's a reply for a get_energize_menu call */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2919 rw->answered_p = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2920 rw->status = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2921 rw->menu_result = list_choices (buffer, extent, rw->only_name, req);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2922 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2923 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2924 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2925 /* It's a menu update, call the hook */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2926 choices = list_choices (buffer, extent, Qnil, req);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2927 va_run_hook_with_args (Qenergize_menu_update_hook, 1, choices);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2928 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2929 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2930 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2931
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2932 /* Kills a buffer */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2933 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2934 unmodify_buffer_and_kill_it (Lisp_Object buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2935 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2936 int speccount = specpdl_depth ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2937
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2938 if (!BUFFER_LIVE_P (XBUFFER (buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2939 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2940
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2941 Fset_buffer_modified_p (Qnil, buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2942
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2943 /* kill it. This will call the Energize hook to do the right thing */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2944 Fkill_buffer (buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2945 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2946
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2947 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2948 handle_kill_buffer_request (Editor *editor, CKillBufferRequest *creq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2949 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2950 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2951
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2952 if (!(binfo = get_buffer_info_for_id (creq->bufferId, editor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2953 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2954 message ("KillBufferVisibleRequest: unregistered buffer");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2955 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2956 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2957
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2958 unmodify_buffer_and_kill_it (binfo->emacs_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2959 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2960
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2961 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2962 handle_remove_extents_request (Editor *editor, CRemoveExtentsRequest *creq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2963 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2964 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2965 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2966 EId *ids;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2967 Lisp_Object restore_buffer_state_cons;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2968 int speccount = specpdl_depth ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2969
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2970 if (!(binfo = get_buffer_info_for_id (creq->bufferId, editor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2971 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2972 message ("RemoveExtentsRequest: unregistered buffer");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2973 CSkipRequest (editor->conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2974 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2975 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2976
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2977 /* enable buffer edits */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2978 restore_buffer_state_cons =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2979 Fcons (make_opaque_ptr ((void *) creq->bufferId),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2980 Fcons (XBUFFER (binfo->emacs_buffer)->read_only, Qnil));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2981
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2982 record_unwind_protect (restore_buffer_state, restore_buffer_state_cons);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2983
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2984 XBUFFER (binfo->emacs_buffer)->read_only = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2985
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2986 /* save old hook values */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2987 specbind (Qenergize_buffer_modified_hook, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2988
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2989 ids = CGetN (editor->conn, EId, creq->nExtent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2990 for (i = 0; i < creq->nExtent; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2991 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2992 Energize_Extent_Data *ext = get_extent_data (ids [i], binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2993 if (ext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2994 free_Energize_Extent_Data (ext, binfo, OFT_STANDALONE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2995 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2997 /* restore modified hooks and globals */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2998 unbind_to (speccount, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2999 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3001 #ifndef ENERGIZE_V2_HEADERS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3002 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3003 save_to_energize_unwind (Lisp_Object closure)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3004 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3005 BITS32 buffer_id = (BITS32) cons_to_long (closure);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3006 /* If the buffer ID is not 0, then the call to save-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3007 didn't complete normally - so tell Energize the save was aborted. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3008 if (buffer_id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3009 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3010 Editor *editor = energize_connection;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3011 if (editor && editor->conn) /* Maybe the kernel has gone away. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3012 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3013 CWriteBufferSaveAbortedHeader (editor->conn, buffer_id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3014 CWriteRequestBuffer (editor->conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3015 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3016 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3017 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3018 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3019 #endif /* ENERGIZE_V2_HEADERS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3020
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3021
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3022 /* handles a request to save a buffer from the kernel */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3023 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3024 handle_save_buffer_request (Editor *editor, CSaveBufferRequest *creq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3025 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3026 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3027 int speccount = specpdl_depth ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3028 struct gcpro gcpro1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3029 Lisp_Object closure = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3030
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3031 if (!(binfo = get_buffer_info_for_id (creq->bufferId, editor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3032 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3033 message ("Server attempt to save a non registered buffer");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3034 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3035 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3037 if (!EQ (binfo->emacs_buffer, Fcurrent_buffer ()))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3038 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3039 record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3040 Fset_buffer (binfo->emacs_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3041 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3042
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3043 GCPRO1 (closure);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3044 if (creq->head.data == CSExecuteSave)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3045 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3046 #ifndef ENERGIZE_V2_HEADERS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3047 Lisp_Object closure = make_opaque_ptr ((void *) creq->bufferId);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3048 record_unwind_protect (save_to_energize_unwind, closure);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3049 #endif /* ENERGIZE_V2_HEADERS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3050 call0 (intern ("save-buffer"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3051 #ifndef ENERGIZE_V2_HEADERS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3052 /* clear out the id to tell the unwind-protect form that the save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3053 completed normally. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3054 set_opaque_ptr (closure, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3055 #endif /* ENERGIZE_V2_HEADERS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3056 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3057 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3058 write_energize_buffer_data (binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3059
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3060 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3061 unbind_to (speccount, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3062 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3063
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3064 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3065 handle_set_modified_flag_request (Editor* editor,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3066 CSetModifiedFlagRequest* creq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3067 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3068 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3069 int speccount = specpdl_depth ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3070
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3071 if (!(binfo = get_buffer_info_for_id (creq->bufferId, editor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3072 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3073 message ("Server attempt to set modified flag of a non registered buffer");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3074 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3075 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3076
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3077 record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3078 specbind (Qenergize_buffer_modified_hook, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3079
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3080 /* Only set buffer modified time in older protocols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3081 as we handle the file timestamps ourselves now for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3082 CBFileYourself buffers. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3083 #ifndef ENERGIZE_V2_HEADERS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3084 if ((energize_connection->minor < 10) && !(binfo->flags & CBFileYourself))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3085 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3086 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3087 Fset_buffer_modtime (binfo->emacs_buffer, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3088 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3089
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3090 Fset_buffer_modified_p (creq->state ? Qt : Qnil, binfo->emacs_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3091 binfo->modified_state = creq->state;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3092 /* Mark the buffer so that we ask permission to Energize when the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3093 * user tries to modify it again */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3094 binfo->editable = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3095 if (!creq->state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3096 mark_all_extents_as_unmodified (binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3097 unbind_to (speccount, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3098 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3099
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3101 /* handles requests regarding p_sheet associated to buffers */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3102 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3103 add_in_list_of_ids (int** ids, int* n_ids, int id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3104 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3105 if (*n_ids == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3106 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3107 *n_ids = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3108 *ids = (int*)xmalloc (sizeof (int));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3109 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3110 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3111 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3112 *n_ids += 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3113 *ids = (int*)xrealloc (*ids, sizeof (int) * (*n_ids));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3114 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3115 (*ids) [(*n_ids) - 1] = id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3116 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3118 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3119 remove_from_list_of_ids (int** ids, int* n_ids, int id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3120 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3121 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3122 if (*n_ids)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3123 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3124 /* look for id in *ids */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3125 for (i = 0; i < (*n_ids) && (*ids) [i] != id; i++);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3126 /* shift the remaining ones */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3127 for (; i < (*n_ids) - 1; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3128 (*ids) [i] = (*ids) [i + 1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3129 /* decrease the count */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3130 *n_ids -= 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3131 /* free array if empty */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3132 if (!*n_ids)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3133 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3134 xfree (*ids);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3135 *ids = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3136 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3137 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3138 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3140 extern void make_psheets_desired (struct frame *, Lisp_Object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3142 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3143 handle_buffer_sheet_request (Editor *editor, CSheetRequest *sreq,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3144 EId buffer_id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3145 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3146 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3147 char *name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3148 Connection *conn = editor->conn;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3150 if (!(binfo = get_buffer_info_for_id (buffer_id, editor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3151 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3152 message ("Server attempt to use p_sheet in a non registered buffer");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3153 CSkipRequest (conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3154 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3155 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3157 name = CGetVstring (conn, (ReqLen *) 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3158 switch ((CSheetRSubtype) sreq->head.data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3159 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3160 case CSCreate:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3161 lw_register_widget (name, name, sreq->sheetId, NULL, NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3162 handle_sheet_control_change, NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3163 add_in_list_of_ids (&binfo->p_sheet_ids, &binfo->n_p_sheets,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3164 sreq->sheetId);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3165 if (!strcmp (name, DEBUGGER_PSHEET_NAME))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3166 debuggerpanel_sheet = sreq->sheetId;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3167 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3169 case CSDelete:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3170 remove_from_list_of_ids (&binfo->p_sheet_ids, &binfo->n_p_sheets,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3171 sreq->sheetId);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3172 cleanly_destroy_all_widgets (1, &sreq->sheetId);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3173 if (sreq->sheetId == debuggerpanel_sheet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3174 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3175 desired_debuggerpanel_exposed_p = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3176 debuggerpanel_sheet = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3177 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3178 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3180 case CSHide:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3181 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3182 Lisp_Object frmcons, devcons, concons;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3184 if (sreq->sheetId == debuggerpanel_sheet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3185 desired_debuggerpanel_exposed_p = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3186 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3187 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3188 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3189 struct frame *frame = XFRAME (Fcar (frmcons));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3190 if (FRAME_X_P (frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3191 make_psheets_desired (frame, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3192 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3193 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3194 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3196 case CSShow:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3197 if (sreq->sheetId == debuggerpanel_sheet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3198 desired_debuggerpanel_exposed_p = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3199 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3200 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3201 Lisp_Object frmcons, devcons, concons;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3203 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3204 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3205 struct frame *frame = XFRAME (Fcar (frmcons));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3206 if (FRAME_X_P (frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3207 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3208 struct window *window =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3209 XWINDOW (FRAME_SELECTED_WINDOW (frame));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3210 if (EQ (window->buffer, binfo->emacs_buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3211 make_psheets_desired (frame, binfo->emacs_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3212 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3213 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3214 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3215 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3216 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3217 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3221 /* show busy */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3223 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3224 show_all_menubars_busy (int busy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3225 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3226 Lisp_Object frmcons, devcons, concons;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3228 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3229 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3230 struct frame *f = XFRAME (XCAR (frmcons));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3231 if (FRAME_X_P (f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3232 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3233 if (FRAME_X_MENUBAR_WIDGET (f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3234 lw_show_busy (FRAME_X_MENUBAR_WIDGET (f), busy);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3235 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3236 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3237 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3239 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3240 handle_show_busy_request (Editor *editor, CGenericRequest *preq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3241 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3242 /* call the show busy routine of the library for the menubar of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3243 * all frames */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3244 ReqLen len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3246 char* why = CGetVstring (editor->conn, &len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3248 show_all_menubars_busy (preq->head.data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3249 Venergize_kernel_busy = preq->head.data ? Qt : Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3250 va_run_hook_with_args (Qenergize_kernel_busy_hook, 1, build_string (why));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3251 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3253 /* This request creates, destroys, raises, or lowers a psheet or dialog box.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3254 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3255 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3256 handle_sheet_request (Connection* conn, CSheetRequest* sreq, Widget parent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3257 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3258 char* name = CGetVstring (conn, NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3260 switch ((CSheetRSubtype)sreq->head.data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3261 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3262 case CSCreate:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3263 lw_create_widget (name, name, sreq->sheetId, 0, parent,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3264 !sreq->bufferId, 0, handle_sheet_control_change, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3265 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3266 case CSDelete:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3267 cleanly_destroy_all_widgets (1, &sreq->sheetId);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3268 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3269
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3270 case CSShow:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3271 lw_pop_up_all_widgets (sreq->sheetId);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3272 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3274 case CSHide:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3275 lw_pop_down_all_widgets (sreq->sheetId);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3276 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3277 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3278 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3280 /* This request changes slot values in the psheets/dialog boxes. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3281 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3282 handle_set_control_request (Connection* conn, CGenericRequest* creq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3283 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3284 CSetControlRequest* sreq = &creq->setcontrol;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3285 widget_value val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3286 widget_value* contents;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3288 unsigned long i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3289 unsigned long n = sreq->nChoices;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3291 if (n > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3292 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3293 contents = (widget_value *) xmalloc (n * sizeof (widget_value));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3294 memset (contents, 0, (n * sizeof (widget_value)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3295 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3296 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3297 contents = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3298 memset (&val, 0, sizeof (val));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3299 val.name = CGetVstring (conn, NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3300 val.enabled = !(sreq->flags & CKInactive);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3301 val.selected = !!(sreq->flags & CKSelected);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3302 val.change = VISIBLE_CHANGE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3303 val.contents = contents;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3304
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3305 for (i = 0; i < n; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3306 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3307 widget_value* cur = &contents [i];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3308 CChoice* choice = CGet (conn, CChoice);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3309 cur->name = CGetVstring (conn, NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3310 cur->value = cur->name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3311 cur->key = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3312 cur->enabled = !(choice->flags & CKInactive);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3313 cur->selected = !!(choice->flags & CKSelected);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3314 cur->change = VISIBLE_CHANGE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3315 cur->contents = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3316 cur->call_data = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3317 cur->next = i == n - 1 ? NULL : &contents [i + 1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3318 cur->toolkit_data = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3319 if ((i == 0 && n == 1) || cur->selected)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3320 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3321 val.value = cur->name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3322 if (!*val.value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3323 val.value = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3324 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3325 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3326 lw_modify_all_widgets (sreq->sheetId, &val, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3328 if (contents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3329 xfree (contents);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3330 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3332 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3333 handle_sheet_control_change (Widget widget, EId sheet_id, void* arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3334 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3335 Connection* conn;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3336 widget_value* val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3337 widget_value* cur;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3338 widget_value* this_val = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3339 widget_value* cancel = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3340 char* this_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3341 int delete_window_p = (((int) arg) == -1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3344 if (!energize_connection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3345 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3347 conn = energize_connection->conn;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3348 if (!conn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3349 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3351 this_name = XtName (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3352 val = lw_get_all_values (sheet_id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3354 if (delete_window_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3355 /* Complete and utter kludge. If this dbox was dismissed with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3356 WM close box (WM_DELETE_WINDOW, meaning the widget was destroyed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3357 then we look for a likely "cancel" button and pretend the user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3358 clicked on that. Really the protocol should be extended for this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3359 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3360 for (cur = val; cur; cur = cur->next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3361 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3362 char *v = cur->value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3363 if (v &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3364 ((strlen (v) >= 6 && !strncmp (v, "cancel", 6)) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3365 (strlen (v) >= 5 && !strncmp (v, "abort", 5))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3366 cancel = cur;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3367 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3368
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3369 /* first send all the edited widgets */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3370 for (cur = val; cur; cur = cur->next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3371 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3372 /* do not send the widget that ran the callback */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3373 if (!strcmp (cur->name, this_name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3374 this_val = cur;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3375 else if (cur == cancel)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3376 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3377 /* send the edited widgets */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3378 else if (cur->edited)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3379 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3380 char* value = cur->value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3381 unsigned int flags = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3383 if (!cur->enabled)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3384 flags |= CKInactive;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3385 if (cur->selected)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3386 flags |= CKSelected;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3388 /* the kernel is brain dead and expect "1" and "0" as values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3389 for the checkbox objects. So if value is NULL, make it be "0"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3390 or "1" depending on the selected state. This is until we fix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3391 the kernel. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3392 if (!value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3393 value = cur->selected ? "1" : "0";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3394
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3395 CWriteSetControlRequest (conn, sheet_id, 0, cur->name, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3396 CWriteChoice (conn, 0, flags, value, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3397 CWriteLength (conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3398 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3399 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3401 if (delete_window_p && !this_val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3402 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3403 this_val = cancel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3404 /* if (! this_val) abort (); */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3405 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3407 /* Then send the widget that ran the callback */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3408 if (this_val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3409 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3410 CWriteSetControlRequest (conn, sheet_id, 0, this_val->name, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3411 CWriteChoice (conn, 0, 0, this_val->value, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3412 CWriteLength (conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3413 CWriteRequestBuffer (conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3414 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3415 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3417 /******************** Low level connection stuff ************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3418 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3419 add_in_connection_input_buffer (Connection *conn, char *s, int l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3420 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3421 /* Should be in connection.c */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3422 if (conn->inread >= conn->infill)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3423 conn->inread = conn->infill = conn->inbuffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3425 CNeedInputSize (conn, l);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3426 memcpy (conn->infill, s, l);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3427 conn->infill += l;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3428 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3430 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3431 process_one_energize_request (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3432 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3433 Editor *editor = energize_connection;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3434 CEditorRequest *req;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3435 int res = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3436
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3437 if (!editor) return make_int (res);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3439 if (!editor->conn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3440 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3441 close_energize_connection ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3442 return make_int (res);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3443 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3445 req = CReadEditorRequest (editor->conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3446 if (!req)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3447 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3448 switch (errno)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3449 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3450 case EWOULDBLOCK:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3451 /* message ("ProcessEnergizeRequest: internal error EWOULDBLOCK"); */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3452 res = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3453 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3455 case 0:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3456 case ECONNRESET:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3457 message ("Connection to " IDENTITY_CRISIS " was closed.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3458 close_energize_connection ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3459 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3461 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3462 message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3463 ("System error on connection to " IDENTITY_CRISIS ", closing.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3464 close_energize_connection ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3465 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3466 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3467 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3468 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3469 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3470 res = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3471 switch (req->head.reqType)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3472 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3473 case RefuseConnectionRType:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3474 message (IDENTITY_CRISIS " connection refused");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3475 close_energize_connection ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3476 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3478 case AcceptConnectionRType:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3479 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3480 CProtocol* proto = CGet (editor->conn, CProtocol);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3481 editor->major = proto->major;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3482 editor->minor = proto->minor;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3483 message (IDENTITY_CRISIS " connection accepted");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3484 CSkipRequest (editor->conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3485 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3486 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3487
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3488 case NewBufferRType:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3489 handle_new_buffer_request (editor, &req->newbuffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3490 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3492 case QueryBufferRType:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3493 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3494 EId buffer_id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3495 struct reply_wait* rw = find_wait_reply (req->head.serial);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3496 CGetVstring (editor->conn, 0); /* skip directory */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3497 CGetVstring (editor->conn, 0); /* skip file */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3498 buffer_id = *CGet (editor->conn, EId);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3499 if (rw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3500 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3501 rw->answered_p = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3502 rw->status = req->head.data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3503 rw->objectId = buffer_id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3504 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3505 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3506 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3508 case EnsureVisibleRType:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3509 handle_ensure_visible_request (editor, &req->ensurevisible);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3510 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3512 case EnsureManyVisibleRType:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3513 handle_ensure_many_visible_request (editor, &req->ensuremanyvisible);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3514 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3516 case ModifyBufferRType:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3517 handle_modify_buffer_request (editor, &req->modifybuffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3518 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3520 case ProposeChoicesRType:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3521 handle_propose_choices_request (editor,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3522 &req->generic.proposechoices);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3523 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3524
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3525 case ChoiceExecutedRType:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3526 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3527 struct reply_wait* rw = find_wait_reply (req->head.serial);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3528 CChoiceExecutedRequest* ce = &req->generic.choiceexecuted;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3529 if (rw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3530 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3531 rw->answered_p = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3532 rw->status = ce->head.data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3533 rw->message = CMakeVstring (editor->conn, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3534 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3535 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3536 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3538 case KillBufferRType:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3539 handle_kill_buffer_request (editor, &req->killbuffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3540 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3542 case ModifiedBufferRType:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3543 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3544 struct reply_wait* rw = find_wait_reply (req->head.serial);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3545 if (rw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3546 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3547 rw->answered_p = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3548 if (rw->objectId == req->modifiedbuffer.bufferId)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3549 rw->status = req->modifiedbuffer.state;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3550 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3551 rw->status = CMBufferLocked;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3552 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3553 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3554 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3555
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3556 case SetModifiedFlagRType:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3557 handle_set_modified_flag_request (editor, &req->setmodifiedflag);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3558 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3560 case RemoveExtentsRType:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3561 handle_remove_extents_request (editor, &req->removeextents);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3562 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3564 case RenumberExtentsRType:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3565 /* HandleDuplicateExtentRequest (editor, req); */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3566 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3568 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3569 case DialogRType:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3570 /* HandleDialogRequest (editor, req, CurrentBuffer (editor)); */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3571 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3572 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3574 case SaveBufferRType:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3575 handle_save_buffer_request (editor, &req->savebuffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3576 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3577
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3578 case SheetRType:{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3579 EId buffer_id = req->generic.sheet.bufferId;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3580 if (!buffer_id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3581 buffer_id = buffer_id_of_sheet (req->generic.sheet.sheetId);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3582 if (buffer_id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3583 handle_buffer_sheet_request (editor, &req->generic.sheet,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3584 buffer_id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3585 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3586 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3587 CSheetRSubtype type = (CSheetRSubtype)req->head.data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3588 if (type == CSDelete || type ==CSHide)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3589 /* #### ??? this does nothing. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3590 Fselect_frame (Fselected_frame (Qnil));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3591 handle_sheet_request (editor->conn, &req->generic.sheet,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3592 FRAME_X_SHELL_WIDGET
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3593 (XFRAME (Fselected_frame (Qnil))));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3594 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3595 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3596 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3598 case SetControlRType:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3599 handle_set_control_request (editor->conn, (CGenericRequest*) req);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3600 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3602 case OpenPostitRType:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3603 case KillPostitRType:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3604 message ("Don't know what to do with postit requests.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3605 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3607 case ShowBusyRType:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3608 handle_show_busy_request (editor, (CGenericRequest*)req);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3609 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3611 case LoggingRType:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3612 handle_logging_request (editor, (CLoggingRequest*)req);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3613 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3614
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3615 #ifndef ENERGIZE_V2_HEADERS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3616 case KernelEventRType:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3617 CSkipRequest (editor->conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3618 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3619 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3621 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3622 message("ProcessEnergizeRequest: can't handle request of type %d",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3623 req->head.reqType);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3624 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3625
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3626 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3627
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3628 return make_int (res);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3629 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3631 static int inside_process_energize_request_1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3633 /* this must be called ONLY by unwind_protect in process_energize_request_1 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3634 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3635 post_handle_request (Lisp_Object ignored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3636 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3637 if (inside_process_energize_request_1 <= 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3638 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3639 inside_process_energize_request_1--;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3640 if (energize_connection && energize_connection->conn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3641 CSkipRequest (energize_connection->conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3642 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3643 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3644
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3645 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3646 pop_conn (Lisp_Object arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3647 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3648 Connection *old_conn = (Connection *) get_opaque_ptr (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3649 if (! old_conn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3650 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3651 if (! energize_connection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3652 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3653 if (energize_connection->conn == old_conn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3654 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3655
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3656 if (CRequestDelayedP (energize_connection->conn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3657 /* We don't call the CWait* functions any more so this shouldn't happen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3658 But if it does someday, then we need to either copy the remaining
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3659 bits from new_conn to old_conn, or loop processing requests until
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3660 new_conn is drained.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3661 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3662 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3663
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3664 DeleteConnection (energize_connection->conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3665 energize_connection->conn = old_conn;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3666
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3667 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3668 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3669
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3670 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3671 process_energize_request_1 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3672 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3673 Lisp_Object result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3674 int speccount = specpdl_depth ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3675
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3676 if (inside_process_energize_request_1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3677 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3678 /* When the energize process filter is called recursively, push a new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3679 connection object. The read-pointer of the connection buffer could
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3680 be in the middle of a request. However, we know that the fd itself
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3681 is always pointing between requests. So making a new connection is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3682 a way of skipping past the one request we were in the process of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3683 reading when we allowed process output to be handled recursively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3684 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3685 Connection *old_conn = energize_connection->conn;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3686 Connection *new_conn =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3687 make_energize_connection ((void *) energize_connection,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3688 old_conn->fdin, old_conn->fdout);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3689 energize_connection->conn = new_conn;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3690 record_unwind_protect (pop_conn, make_opaque_ptr (old_conn));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3691 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3693 /* this must come after pop_conn() to get the right connection object */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3694 record_unwind_protect (post_handle_request, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3695
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3696 inside_process_energize_request_1++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3697
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3698 result = process_one_energize_request ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3699 notify_delayed_requests ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3700
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3701 /* decrements inside_process_energize_request_1 and possibly replaces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3702 energize_connection->conn with old_conn.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3703 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3704 unbind_to (speccount, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3705
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3706 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3707 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3708
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3709
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3710 /******** Initialize Energize-related state and set up connection ********/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3711
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3712 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3713 setup_connection (Editor *ed, unsigned int id1, unsigned int id2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3714 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3715 CEditorRequest *req = CWriteEditorRequest (ed->conn, QueryConnectionRType);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3716
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3717 /* these 2 slots are ignored */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3718 req->generic.queryconnection.major = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3719 req->generic.queryconnection.minor = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3720
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3721 req->generic.queryconnection.cadillacId1 = id1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3722 req->generic.queryconnection.cadillacId2 = id2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3723 req->generic.queryconnection.nProtocols = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3724 /* first numerical arg is major protocol number, second is minor */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3725 CWriteProtocol (ed->conn, 0, 10, "editor");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3726 CWriteLength (ed->conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3727 CWriteRequestBuffer (ed->conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3728 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3729
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3730 /* this is used as the readMethod of the energize connection, so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3731 the connection library won't do some buffering that messes us up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3732 It does this buffering only if conn->readMethod == read, so using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3733 another function turns it off.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3734 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3735 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3736 my_read (int fd, char *buf, int nb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3737 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3738 return read (fd, buf, nb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3739 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3740
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3741 static Connection *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3742 make_energize_connection (Editor *editor, int fdin, int fdout)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3743 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3744 Connection *conn = NewConnection ((void *)editor, fdin, fdout);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3745 if (conn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3746 conn->readMethod = my_read;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3747 return conn;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3748 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3749
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3750 DEFUN ("handle-energize-request", Fhandle_energize_request,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3751 Shandle_energize_request,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3752 2, 2, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3753 Filter called when a request is available from Energize.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3754 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3755 (proc, string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3756 Lisp_Object proc, string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3757 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3758 if (!NILP (string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3759 CHECK_STRING (string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3760
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3761 if (!energize_connection || !energize_connection->conn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3762 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3763 /* no need for a message here, Energize is dead */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3764 return make_int (0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3765 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3766 if (!energize_connection || (!EQ (energize_connection->proc, proc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3767 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3768 message ("Got " IDENTITY_CRISIS " request but not from current connection ");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3769 return make_int (0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3770 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3771
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3772 if (!NILP (string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3773 add_in_connection_input_buffer (energize_connection->conn,
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
3774 (char *) XSTRING_DATA (string),
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
3775 XSTRING_LENGTH (string));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3776
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3777 return process_energize_request_1 ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3778 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3780
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3781 Lisp_Object Venergize_process;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3782
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3783 /* Opens a network connection to Energize.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3784 * server is a string. It can end up with :<uid> or :<username>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3785 * in which case the uid is added to the TCP port to get the connection */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3786 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3787 connect_to_energize (char *server_str, char *arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3788 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3789 struct Lisp_Process *proc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3790 Lisp_Object lp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3791 Lisp_Object fil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3792 char *host;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3793 unsigned int port;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3794 long flags;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3795 int id1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3796 int id2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3797
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3798 if (CGetPortNumber (server_str, &host, &port))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3799 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3800
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3801 lp = Fopen_network_stream_internal (build_string ("energize"),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3802 Qnil,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3803 build_string (host),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3804 make_int (port));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3805 if (!NILP (lp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3806 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3807 int infd, outfd;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3808 /* Don't ask the user for confirmation when exiting Emacs */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3809 Fprocess_kill_without_query (lp, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3810 proc = XPROCESS (lp);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3811 energize_connection = xnew (Editor);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3812 get_process_file_descriptors (proc, &infd, &outfd);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3813 energize_connection->conn =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3814 make_energize_connection (energize_connection, infd, outfd);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3815 energize_connection->proc = lp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3816 energize_connection->binfo_hash = make_hashtable (10);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3817 energize_connection->image_table = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3818 energize_connection->gc_save = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3819 energize_connection->major = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3820 energize_connection->minor = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3821 peo = allocate_edit_options (10);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3822 request_serial_number = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3823 global_reply_wait = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3824
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3825 if ((flags = fcntl (energize_connection->conn->fdin, F_GETFL, 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3826 == -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3827 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3828
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3829 #ifdef O_NONBLOCK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3830 if (fcntl (energize_connection->conn->fdin, F_SETFL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3831 flags & ~O_NONBLOCK)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3832 == -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3833 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3834 if (fcntl (energize_connection->conn->fdin, F_SETFL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3835 flags & ~O_NDELAY)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3836 == -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3837 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3838 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3840 XSETSUBR (fil, &Shandle_energize_request);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3841 set_process_filter (lp, fil, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3842
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3843 Venergize_kernel_busy = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3844
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3845 id1 = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3846 id2 = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3847 if (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3848 sscanf (arg, "%x,%x", &id1, &id2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3850 Venergize_buffers_list = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3851
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3852 setup_connection (energize_connection, id1, id2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3853
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3854 Venergize_process = lp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3855 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3856 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3857 error ("couldn't connect to " IDENTITY_CRISIS " server");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3858 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3859 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3860 error ("couldn't determine " IDENTITY_CRISIS " server port number");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3861
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3862
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3863 #ifdef ENERGIZE_V2_HEADERS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3864 if (energize_connection->minor > 9)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3865 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3866 close_energize_connection ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3867 error ("This Emacs doesn't understand " IDENTITY_CRISIS " version 3.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3868 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3869
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3870 #endif /* ENERGIZE_V2_HEADERS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3871
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3872 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3873
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3874
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3875 /* Close the connection to energize.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3876 * Kills all the energize related buffer */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3877 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3878 close_energize_connection ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3879 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3880 Editor *ed = energize_connection;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3881
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3882 if (ed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3883 /* make this function as paranoid as we can */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3884 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3885 /* cleanup the busy state */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3886 show_all_menubars_busy (False);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3887 Venergize_kernel_busy = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3888 /* destroy all pop_up boxes */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3889 lw_destroy_all_pop_ups ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3890
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3891 if (ed->conn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3892 DeleteConnection (ed->conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3893 ed->conn = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3895 if (ed->binfo_hash)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3896 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3897 int speccount = specpdl_depth ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3898
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3899 /* we are flushing everything, so we just ignore any change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3900 hooks and don't make an effort to delete extents since they
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3901 are all going away */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3902 specbind (Qenergize_buffer_modified_hook, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3903 specbind (Qinhibit_quit, Qt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3904 call0 (intern ("de-energize-all-buffers"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3905 unbind_to (speccount, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3906
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3907 free_hashtable (ed->binfo_hash);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3908 ed->binfo_hash = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3909 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3910
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3911 /* Do this after de-energize-all-buffers or frame sizes thrash. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3912 debuggerpanel_sheet = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3913 desired_debuggerpanel_exposed_p = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3914
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3915 free_edit_options (peo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3916
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3917 if (ZEROP (ed->proc)) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3918
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3919 if (!NILP (ed->proc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3920 Fdelete_process (ed->proc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3921 ed->proc = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3922
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3923 Venergize_buffers_list = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3924
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3925 /* now kill buffers created to satisfy requests on old connection */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3926 xfree (ed);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3927 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3928
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3929 /* mark as closed */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3930 energize_connection = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3931 Venergize_process = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3932 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3933
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3934
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3935 DEFUN ("connect-to-energize-internal",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3936 Fconnect_to_energize_internal, Sconnect_to_energize_internal, 0, 2, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3937 Usage: (connect-to-energize-internal <server-name> <energizearg>)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3938 Energizearg representing two 32 bit Energize ids that will be passed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3939 to the Energize server when opening the Energize connection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3940 Only one connection can be open at a time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3941 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3942
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3943 (server_name, energize_arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3944 Lisp_Object server_name, energize_arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3945 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3946 unsigned char *server;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3947 unsigned char *arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3948
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3949 if (!NILP (energize_arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3950 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3951 CHECK_STRING (energize_arg);
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
3952 arg = XSTRING_DATA (energize_arg);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3953 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3954 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3955 arg = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3956
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3957 if (!NILP (server_name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3958 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3959 CHECK_STRING (server_name);
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
3960 server = XSTRING_DATA (server_name);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3961 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3962 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3963 server = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3964
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3965 /* since we are going ahead with this, make sure that we are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3966 really and truly disconnected first */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3967 Fclose_connection_to_energize ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3968
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3969 connect_to_energize ((char *)server, (char *)arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3970 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3971 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3972
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3973 DEFUN ("close-connection-to-energize", Fclose_connection_to_energize,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3974 Sclose_connection_to_energize, 0, 0, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3975 Close the open Energize connection, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3976 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3977 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3978 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3979 if (!energize_connection) return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3980
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3981 close_energize_connection ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3982 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3983 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3984
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3985
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3986 /* Extents stuff; this used to be in extents.c */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3987
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3988 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3989 set_extent_flags (EXTENT extent, Energize_Extent_Data *ext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3990 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3991 /* clear every flag */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3992 if (!EXTENT_LIVE_P (extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3993 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3994 extent_start_open_p (extent) = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3995 extent_end_open_p (extent) = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3996 extent_read_only_p (extent) = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3997 set_extent_mouse_face (extent, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3998 extent_unique_p (extent) = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3999 extent_duplicable_p (extent) = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4000 extent_invisible_p (extent) = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4001
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4002 set_extent_glyph (extent, 0, 0, GL_TEXT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4003 set_extent_glyph (extent, 0, 1, GL_TEXT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4004
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4005 if (ext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4006 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4007 ext->warn_modify = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4008
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4009 switch (ext->extentType)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4010 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4011 case CEAttribute:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4012 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4013
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4014 case CEAbbreviation:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4015 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4016
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4017 case CEWriteProtect:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4018 extent_read_only_p (extent) = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4019 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4020
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4021 case CEGeneric:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4022 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4023 GLYPH begin_glyph = 0; /* always the class glyph */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4024 GLYPH end_glyph = 0; /* always the instance glyph */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4025
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4026 /* if (ext->u.generic.gData->id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4027 SET_EXTENT_FLAG (extent, EF_MENU);*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4028
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4029 if (ext->u.generic.gData->glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4030 end_glyph = ext->u.generic.gData->glyph;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4031 if (ext->u.generic.gData->cl && ext->u.generic.gData->cl->glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4032 begin_glyph = ext->u.generic.gData->cl->glyph;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4033
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4034 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4035 if (begin_glyph && end_glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4036 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4037 begin_glyph = end_glyph;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4038 end_glyph = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4039 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4040 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4041
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4042 if (begin_glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4043 set_extent_glyph (extent, begin_glyph, 0, GL_TEXT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4044 if (end_glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4045 set_extent_glyph (extent, end_glyph, 1, GL_TEXT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4046
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4047 if (ext->u.generic.gData->cl &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4048 (ext->u.generic.gData->cl->flags & CCElectric))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4049 set_extent_mouse_face (extent, Qhighlight);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4050 if (ext->u.generic.gData->cl &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4051 (ext->u.generic.gData->cl->flags & CCWarnModified))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4052 ext->warn_modify = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4053 #if 0 /* #### some day (soon?)... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4054 if (ext->u.generic.gData->cl &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4055 (ext->u.generic.gData->cl->flags & CCColumn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4056 SET_EXTENT_FLAG (extent, EF_COLUMN);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4057 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4058 extent_duplicable_p (extent) = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4059 extent_unique_p (extent) = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4060 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4061 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4062
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4063 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4064 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4065 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4066 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4067 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4068
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4069 extern Lisp_Object Fset_extent_face (Lisp_Object extent, Lisp_Object name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4070
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4071 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4072 set_extent_attributes_index (EXTENT extent, Energize_Extent_Data *ext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4073 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4074 int graphic_attributes;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4075
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4076 if (!ext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4077 extent_face_id (extent) = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4078 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4079 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4080 switch (ext->extentType)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4081 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4082 case CEAttribute:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4083 graphic_attributes = ext->u.attr.attrValue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4084 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4085
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4086 case CEGeneric:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4087 graphic_attributes = ext->u.generic.gData->attribute;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4088 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4089
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4090 case CEWriteProtect:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4091 /* this type has NO display attributes */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4092 extent_face_id (extent) = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4093 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4094
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4095 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4096 graphic_attributes = GA_NO_CHANGE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4097 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4098
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4099 if (graphic_attributes >= GA_MAX)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4100 graphic_attributes = GA_NO_CHANGE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4102 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4103 /* The Venergize_attributes_mapping global is an alist of the form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4104 ( (<kernel-attribute-number> . <emacs-face-name> ) ... )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4105 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4106 Lisp_Object face = Fcdr (Fassq (make_int (graphic_attributes),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4107 Venergize_attributes_mapping));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4108 Lisp_Object e;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4109 XSETEXTENT (e, extent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4110 if (NILP (face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4111 message ("Unknown Energize attribute %d", graphic_attributes);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4112 else if (EQ (face, Qdefault))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4113 Fset_extent_face (e, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4114 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4115 Fset_extent_face (e, face);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4116 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4117 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4118 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4120 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4121 restore_energize_extent_state (EXTENT extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4122 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4123 Energize_Extent_Data *ext = energize_extent_data (extent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4124 if (!ext) return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4125 set_extent_flags (extent, ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4126 set_extent_attributes_index (extent, ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4127 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4129 DEFUN ("extent-to-generic-id", Fextent_to_generic_id, Sextent_to_generic_id,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4130 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4131 Return Energize ID of buffer of EXTENT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4132 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4133 (extent_obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4134 Lisp_Object extent_obj;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4135 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4136 CHECK_EXTENT (extent_obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4137 return word_to_lisp (energize_extent_data_id
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4138 (energize_extent_data (XEXTENT (extent_obj))));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4139 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4143 /* buffer modified routines */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4144 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4145 send_buffer_modification_state (Editor *editor, BufferInfo *binfo, int flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4146 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4147 Connection *conn = editor->conn;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4148 EId bufferId = binfo->id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4150 if (conn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4151 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4152 int state = (flag)?(CMBufferSetModified):(CMBufferSetUnmodified);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4153 CWriteModifiedBufferHeader (conn, bufferId, state);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4154 CWriteRequestBuffer (conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4155 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4156 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4158 /* returns 1 if buffer is locked (non-editable),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4159 0 if it isn't (editable), and -1 if it can't tell
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4160 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4161 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4162 check_buffer_lock (Editor *editor, BufferInfo *binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4163 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4164 Connection *conn = editor->conn;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4165 struct reply_wait rw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4167 /* If permision already granted by kernel dont' ask again */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4168 if (binfo->editable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4169 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4171 /* If can't ask say we do not know */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4172 if (!conn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4173 return -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4175 /* Ask the kernel */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4176 CWriteModifiedBufferHeader (conn, binfo->id, CMBufferQueryLock);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4177 conn->header->serial = ++request_serial_number;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4178 CWriteRequestBuffer (conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4180 rw.serial = request_serial_number;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4181 rw.objectId = binfo->id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4182 rw.status = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4184 if (!wait_for_reply (&rw))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4185 return -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4187 if (rw.status == CMBufferLocked)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4188 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4189 /* Buffer is locked by kernel so we cannot edit it */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4190 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4191 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4192 else if (rw.status == CMBufferUnlocked)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4193 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4194 /* Buffer is unlocked by kernel: edit permission granted! */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4195 binfo->editable = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4196 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4197 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4198 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4199 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4200 /* This should never happen */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4201 return -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4202 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4203 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4206 /* Ask the kernel if BUFFER is currently locked -- waits for answer */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4207 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4208 buffer_locked_p (Lisp_Object buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4209 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4210 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4212 if (!energize_connection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4213 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4215 if (NILP (buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4216 XSETBUFFER (buffer, current_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4218 CHECK_BUFFER (buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4220 binfo = get_buffer_info_for_emacs_buffer (buffer, energize_connection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4222 if (!binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4223 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4224 /* Not an Energize buffer, return Qnil: can edit buffer */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4225 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4226 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4227 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4228 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4229 /* Energize buffer, check if editable */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4230 return check_buffer_lock (energize_connection, binfo) == 0 ? Qnil : Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4231 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4232 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4236 /* Called by map_extents function called by Fenergize_send_buffer_modified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4237 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4238 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4239 notify_extent_modified (EXTENT extent, void *arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4240 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4241 /* arg is a binfo_and_state */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4242 binfo_and_state *bans = (binfo_and_state*)arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4243 Energize_Extent_Data *ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4244 BufferInfo *binfo = bans->binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4245 Connection *conn = binfo->editor->conn;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4246 EId *extent_id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4247 Lisp_Object extent_obj;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4249 XSETEXTENT (extent_obj, extent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4250 if ((ext = extent_to_data (extent_obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4251 && ext->warn_modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4252 && ext->extentType == CEGeneric
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4253 && ext->u.generic.gData
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4254 && ext->u.generic.gData->cl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4255 && (ext->u.generic.gData->cl->flags & CCWarnModified)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4256 && ext->u.generic.gData->modified_state != bans->state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4257 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4258 if (bans->tell_energize)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4259 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4260 CWriteModifiedExtentsHeader (conn, binfo->id, bans->state, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4261 extent_id = CPut (conn, EId);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4262 *extent_id = ext->id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4263 CWriteLength (conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4264 CWriteRequestBuffer (conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4265 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4266 ext->u.generic.gData->modified_state = bans->state;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4267 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4268 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4269 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4271 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4272 ceiwme_lower_mf (EXTENT e, void *arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4273 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4274 Lisp_Object extent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4275 Energize_Extent_Data *ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4276 XSETEXTENT (extent, e);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4277 ext = extent_to_data (extent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4278 if (ext && ext->warn_modify)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4279 *((EXTENT *) arg) = e;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4280 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4281 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4283 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4284 ceiwme_upper_mf (EXTENT e, void *arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4285 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4286 Lisp_Object extent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4287 Energize_Extent_Data *ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4288 XSETEXTENT (extent, e);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4289 ext = extent_to_data (extent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4290 if (ext && ext->warn_modify)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4291 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4292 *((EXTENT *) arg) = e;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4293 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4294 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4295 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4296 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4297 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4299 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4300 coerce_endpoints_to_be_inside_warn_on_modify_extents (Bufpos *from_ptr,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4301 Bufpos *to_ptr,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4302 struct buffer *b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4303 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4304 EXTENT lower_extent = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4305 EXTENT upper_extent = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4306 Bufpos lower_bound = *from_ptr;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4307 Bufpos upper_bound = *to_ptr;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4308 Lisp_Object tmp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4310 /* make sure that from <= to */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4311 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4312 Bufpos tmp_int = max (lower_bound, upper_bound);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4313 *from_ptr = lower_bound = min (lower_bound, upper_bound);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4314 *to_ptr = upper_bound = tmp_int;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4315 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4317 if (!BUFFER_NOTIFY_BACKGROUND_BIT_SET_P (b))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4318 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4320 map_extents (BUF_BEG (b), lower_bound, ceiwme_lower_mf,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4321 (void *) &lower_extent, make_buffer (b), 0, ME_END_CLOSED);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4322 if (!lower_extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4323 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4324 lower_bound = BUF_BEG (b);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4325 map_extents (upper_bound, BUF_Z (b), ceiwme_upper_mf,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4326 (void *) &upper_extent, make_buffer (b), 0, ME_END_CLOSED);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4327 if (!upper_extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4328 upper_bound = BUF_Z (b);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4329 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4330 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4331 Bufpos xstart;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4332 XSETEXTENT (tmp, upper_extent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4333 xstart = XINT (Fextent_start_position (tmp));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4334 upper_bound = max (upper_bound, xstart);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4335 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4336 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4337 /* I forget why, but if we found an lower bound, we don't need to find
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4338 an upper bound */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4339 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4340 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4341 Bufpos xstart;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4342 XSETEXTENT (tmp, lower_extent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4343 xstart = XINT (Fextent_start_position (tmp));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4344 lower_bound = min (lower_bound, xstart);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4345 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4347 *from_ptr = lower_bound;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4348 *to_ptr = upper_bound;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4349 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4350 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4352 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4353 mark_all_extents_as_unmodified (BufferInfo *binfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4354 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4355 binfo_and_state bans;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4356 bans.binfo = binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4357 bans.state = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4358 bans.tell_energize = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4360 map_extents (BUF_BEG (XBUFFER (binfo->emacs_buffer)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4361 BUF_Z (XBUFFER (binfo->emacs_buffer)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4362 notify_extent_modified, &bans,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4363 binfo->emacs_buffer, 0, ME_END_CLOSED);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4364 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4366 /* Send the BufferModified events for the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4367 * Handles both global buffer modified and extents modified. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4368 DEFUN ("energize-send-buffer-modified", Fenergize_send_buffer_modified,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4369 Senergize_send_buffer_modified,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4370 3, 3, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4371 Send a BufferModified request for the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4372 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4373 (state, from, to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4374 Lisp_Object state, from, to; /* dont use ANSI arglists in DEFUNs */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4375 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4376 int modifiedp = NILP (state)? 0 : 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4377 Lisp_Object buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4378 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4379 Bufpos from_int = XINT (from);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4380 Bufpos to_int = XINT (to);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4382 if (!energize_connection || !energize_connection->conn) return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4384 XSETBUFFER (buffer, current_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4385
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4386 Fenergize_barf_if_buffer_locked ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4388 if (binfo = get_buffer_info_for_emacs_buffer (buffer, energize_connection))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4389 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4390 /* now make sure that from and to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4391 are inside some warn_on_modify extents somewhere */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4392 coerce_endpoints_to_be_inside_warn_on_modify_extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4393 (&from_int, &to_int, current_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4394 XSETINT (from, from_int);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4395 XSETINT (to, to_int);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4397 if (binfo->modified_state != modifiedp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4398 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4399 send_buffer_modification_state (energize_connection, binfo,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4400 modifiedp);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4401 binfo->modified_state = modifiedp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4402 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4403 #ifndef ENERGIZE_V2_HEADERS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4404 if (!(binfo->flags & CBFileYourself))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4405 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4406 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4407 if (modifiedp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4408 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4409 binfo_and_state bans;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4410 bans.binfo = binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4411 bans.state = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4412 bans.tell_energize = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4413 map_extents (XINT (from), XINT (to),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4414 notify_extent_modified, &bans,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4415 binfo->emacs_buffer, 0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4416 ME_END_CLOSED);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4417 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4418 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4419 mark_all_extents_as_unmodified (binfo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4420 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4421 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4422 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4423 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4425 DEFUN ("energize-barf-if-buffer-locked", Fenergize_barf_if_buffer_locked,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4426 Senergize_barf_if_buffer_locked, 0, 0, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4427 Error if the buffer is locked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4428 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4429 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4430 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4431 Lisp_Object buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4432 XSETBUFFER (buffer, current_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4434 if (!energize_connection || !energize_connection->conn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4435 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4436
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4437 while (!NILP (buffer_locked_p (buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4438 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4439 notify_delayed_requests ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4440 Fsignal (Qbuffer_locked_by_energize, (Fcons (buffer, Qnil)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4441 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4442 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4443 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4446 DEFUN ("energize-send-region", Fenergize_send_region,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4447 Senergize_send_region,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4448 2, 2, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4449 Send region as user input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4450 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4451 (start, end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4452 Lisp_Object start, end;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4453 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4454 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4455 Lisp_Object b;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4456 CEditorRequest *req;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4458 if (!energize_connection || !energize_connection->conn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4459 error ("Not connected to " IDENTITY_CRISIS);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4461 XSETBUFFER (b, current_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4462 if (binfo = get_buffer_info_for_emacs_buffer (b, energize_connection))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4463 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4464 Bufpos st, en;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4465 Bufpos ceil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4467 get_buffer_range_char (current_buffer, start, end, &st, &en);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4469 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4470 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4471 ceil = BUF_CEILING_OF (current_buffer, st);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4473 req = CWriteEditorRequest (energize_connection->conn,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4474 UserTypedSomethingRType);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4475 req->usertypedsomething.bufferId = binfo->id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4476 CWriteVstringLen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4477 (energize_connection->conn,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4478 (char *) BUF_BYTE_ADDRESS (current_buffer, st), ceil - st);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4479 CWriteLength (energize_connection->conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4480 CWriteRequestBuffer (energize_connection->conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4481 st = ceil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4482 } while (st < en);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4483 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4484 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4485 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4486 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4487
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4488 DEFUN ("connected-to-energize-p", Fconnected_to_energize_p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4489 Sconnected_to_energize_p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4490 0, 0, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4491 Return nil if no connection to Energize.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4492 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4493 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4494 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4495 if (!energize_connection ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4496 !energize_connection->conn ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4497 !energize_connection->binfo_hash ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4498 !PROCESSP (energize_connection->proc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4499 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4500 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4501 return Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4502 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4504 DEFUN ("energize-user-input-buffer-mark", Fenergize_user_input_buffer_mark,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4505 Senergize_user_input_buffer_mark, 0, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4506 Return the mark associated to the given Energize buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4507 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4508 (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4509 Lisp_Object buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4510 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4511 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4513 XSETBUFFER (buffer, decode_buffer (buffer, 0));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4514 if (!energize_connection) return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4515 if ((binfo = get_buffer_info_for_emacs_buffer (buffer, energize_connection)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4516 return binfo->output_mark;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4517 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4518 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4519 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4521 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4522 energize_get_buffer_process (Lisp_Object buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4523 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4524 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4526 if (!BUFFERP (buf)) return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4527 if (!energize_connection) return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4528 binfo = get_buffer_info_for_emacs_buffer (buf, energize_connection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4529 if (!binfo) return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4530 if (! binfo->buffer_type) return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4531 if (!strcmp (binfo->buffer_type, "energize-debugger-buffer") ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4532 !strcmp (binfo->buffer_type, "energize-log-file-buffer"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4533 return Venergize_process;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4534 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4535 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4538 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4539 get_energize_connection_and_buffer_id (Lisp_Object buffer, void **conn_ptr,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4540 long *buffer_id_ptr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4541 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4542 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4544 if (!energize_connection || !energize_connection->conn) return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4545
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4546 binfo = get_buffer_info_for_emacs_buffer (buffer, energize_connection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4548 *conn_ptr = (void *) energize_connection->conn;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4549 *buffer_id_ptr = (long) binfo ? binfo->id : 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4550 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4551 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4552
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4553 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4554 get_energize_connection_and_current_buffer_id (void **conn_ptr,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4555 long *buffer_id_ptr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4556 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4557 Lisp_Object lisp_buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4558 XSETBUFFER (lisp_buffer, current_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4560 return get_energize_connection_and_buffer_id (lisp_buffer, conn_ptr,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4561 buffer_id_ptr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4562 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4564 int *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4565 get_psheets_for_buffer (Lisp_Object buffer, int *count_ptr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4566 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4567 BufferInfo *binfo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4568
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4569 if (!energize_connection || !energize_connection->conn) return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4571 binfo = get_buffer_info_for_emacs_buffer (buffer, energize_connection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4572 if (!binfo) return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4574 if (count_ptr) *count_ptr = binfo->n_p_sheets;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4575 return binfo->p_sheet_ids;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4576 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4577
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4578 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4579 notify_energize_sheet_hidden (EId id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4580 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4581 EId buffer_id = buffer_id_of_sheet (id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4582 if (!buffer_id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4583 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4584
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4585 if (buffer_id && energize_connection && energize_connection->conn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4586 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4587 CWriteSheetRequest (energize_connection->conn,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4588 CSHide, id, buffer_id, "");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4589 CWriteRequestBuffer (energize_connection->conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4590 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4591 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4593 DEFUN ("energize-query-buffer", Fenergize_query_buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4594 Senergize_query_buffer, 1, 2, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4595 Ask Energize to create a buffer containing the file filename.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4596 Returns the buffer or NIL if Energize cannot create the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4597 If second argument just-ask is T, just ask if Energize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4598 already knows about the file and returns T if yes, NIL otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4599 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4600 (filename, just_ask)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4601 Lisp_Object filename, just_ask;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4602 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4603 struct Lisp_String *filename_str;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4604 CEditorRequest *creq;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4605 char *dir_sep;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4606 struct reply_wait rw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4607
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4608 if (!energize_connection || !energize_connection->conn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4609 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4611 filename = Fexpand_file_name (filename, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4612 filename_str = XSTRING (filename);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4614 dir_sep = (char *) strrchr ((char *) string_data (filename_str), '/');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4616 creq = CWriteEditorRequest (energize_connection->conn, QueryBufferRType);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4617 creq->head.data = !NILP (just_ask);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4618 creq->head.serial = ++request_serial_number;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4619 CWriteVstringLen (energize_connection->conn, (char *) string_data (filename_str),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4620 (dir_sep)? (dir_sep - (char *) string_data (filename_str)): 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4621 CWriteVstringLen (energize_connection->conn,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4622 (char *) string_data (filename_str), string_length (filename_str));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4623 CWriteLength (energize_connection->conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4624 CWriteRequestBuffer (energize_connection->conn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4625
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4626 rw.serial = request_serial_number;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4627 rw.objectId = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4628
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4629 if (!wait_for_reply (&rw))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4630 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4632 if (rw.status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4633 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4634 if (rw.objectId)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4635 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4636 BufferInfo* binfo = get_buffer_info_for_id (rw.objectId,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4637 energize_connection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4638 return binfo ? binfo->emacs_buffer : Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4639 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4640 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4641 return Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4642 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4643 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4644 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4645 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4646
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4647
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4648 DEFUN ("energize-protocol-level", Fenergize_protocol_level,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4649 Senergize_protocol_level, 0, 0, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4650 Return the Energize protocol level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4651 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4652 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4653 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4654 return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4655 energize_connection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4656 ? Fcons (make_int (energize_connection->major),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4657 make_int (energize_connection->minor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4658 : Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4659 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4662 DEFUN ("energize-psheets-visible-p", Fenergize_psheets_visible_p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4663 Senergize_psheets_visible_p, 0, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4664 Whether the (optional) frame currently has open psheets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4665 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4666 (frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4667 Lisp_Object frame;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4668 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4669 if (NILP (frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4670 XSETFRAME (frame, XFRAME(Fselected_frame(Qnil)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4671 CHECK_FRAME (frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4672 if (FRAME_X_CURRENT_PSHEETS (XFRAME (frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4673 return Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4674 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4675 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4677 DEFUN ("energize-buffer-has-psheets-p", Fenergize_buffer_has_psheets_p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4678 Senergize_buffer_has_psheets_p, 0, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4679 Whether the buffer has psheets associated with it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4680 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4681 (buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4682 Lisp_Object buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4683 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4684 int count;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4685 if (NILP (buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4686 buf = Fcurrent_buffer ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4687 CHECK_BUFFER (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4688 if (get_psheets_for_buffer (buf, &count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4689 return Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4690 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4691 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4693
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4694 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4695 make_psheets_desired (struct frame *f, Lisp_Object buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4696 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4697 int count;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4698 int *psheets;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4699
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4700 if (NILP (buffer) || !(psheets = get_psheets_for_buffer (buffer, &count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4701 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4702 FRAME_X_DESIRED_PSHEETS (f) = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4703 FRAME_X_DESIRED_PSHEET_COUNT (f) = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4704 FRAME_X_DESIRED_PSHEET_BUFFER (f) = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4705 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4706 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4707 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4708 /* Do not show the debugger panel in this function. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4709 * debugger panel should never be listed in the visible psheets. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4710 extern int debuggerpanel_sheet;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4711
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4712 if (count == 1 && psheets [0] == debuggerpanel_sheet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4713 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4714
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4715 FRAME_X_DESIRED_PSHEETS (f) = psheets;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4716 FRAME_X_DESIRED_PSHEET_COUNT (f) = count;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4717 FRAME_X_DESIRED_PSHEET_BUFFER (f) = buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4718 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4719
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4720 /* Garbage the frame so that the sheets get recomputed right away and not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4721 the next time some display change happens. Possibly redisplay should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4722 notice this on its own without the garbaged flag. But once redisplay
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4723 gets smarter about such things, all garbagers should be revisited.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4724 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4725 MARK_FRAME_CHANGED (f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4726 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4727
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4728 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4729 desired_psheet_buffer (struct frame *f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4730 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4731 if (FRAME_X_P (f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4732 return FRAME_X_DESIRED_PSHEET_BUFFER (f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4733 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4734 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4735 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4737 /* This function is invoked when the user clicks on the "sheet" button.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4738 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4739 DEFUN ("energize-toggle-psheet", Fenergize_toggle_psheet,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4740 Senergize_toggle_psheet, 0, 0, "" /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4741
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4742 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4743 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4744 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4745 struct frame *frame = XFRAME(Fselected_frame(Qnil));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4746 Lisp_Object buffer = Fwindow_buffer (Fselected_window (Qnil));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4747 if (EQ (buffer, desired_psheet_buffer (frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4748 make_psheets_desired (frame, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4749 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4750 make_psheets_desired (frame, buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4751 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4752 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4753
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4754
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4755 static void energize_show_menubar_of_buffer (Lisp_Object frame,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4756 Lisp_Object buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4757 Lisp_Object psheets_too);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4758
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4759 /* This is called when a buffer becomes visible in some window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4760
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4761 Show the menubar associated with this buffer, and show the psheets as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4762 well if this buffer is the last buffer whose psheets were visible in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4763 this frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4764 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4765 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4766 energize_buffer_shown_hook (struct window *window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4767 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4768 struct frame* frame = XFRAME (window->frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4769 Lisp_Object buffer = window->buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4770 Lisp_Object pbuf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4771
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4772 if (! FRAME_X_P (frame)) return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4773 pbuf = desired_psheet_buffer (frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4775 if (!MINI_WINDOW_P (window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4776 energize_show_menubar_of_buffer (window->frame, buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4777 (EQ (buffer, pbuf) ? Qt : Qnil));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4778 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4780
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4781 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4782 find_buffer_in_different_window (window, buffer, not_in)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4783 struct window* window;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4784 Lisp_Object buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4785 struct window* not_in;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4786 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4787 Lisp_Object child;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4788 if (!NILP (window->buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4789 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4790 /* a leaf window */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4791 return (EQ (window->buffer, buffer) && (window != not_in));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4792 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4793 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4794 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4795 /* a non leaf window, visit either the hchild or the vchild */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4796 for (child = !NILP (window->vchild) ? window->vchild : window->hchild;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4797 !NILP (child);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4798 child = XWINDOW (child)->next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4799 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4800 if (find_buffer_in_different_window (XWINDOW (child), buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4801 not_in))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4802 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4803 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4804 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4805 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4806 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4807
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4808 /* returns 1 if the buffer is only visible in window on frame f */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4809 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4810 buffer_only_visible_in_this_window_p (Lisp_Object buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4811 struct frame* f,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4812 struct window* window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4813 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4814 return !find_buffer_in_different_window (XWINDOW (f->root_window), buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4815 window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4816 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4817
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4818 /* This is called just before a buffer which is visible becomes invisible,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4819 either because some other buffer is about to be made visible in its window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4820 or because that window is being deleted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4821
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4822 If this buffer's psheets are visible, hide them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4823 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4824 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4825 energize_buffer_hidden_hook (struct window *window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4826 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4827 struct frame *f = XFRAME (window->frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4828
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4829 if (! FRAME_X_P (f)) return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4830
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4831 /* hides the p_sheet if we are changing the buffer of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4832 * selected window of the frame and the p_sheet where displayed */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4833 if (EQ (window->buffer, desired_psheet_buffer (f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4834 && buffer_only_visible_in_this_window_p (window->buffer, f, window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4835 make_psheets_desired (f, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4836 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4837
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4838
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4839 /* This is called just before the selected window is no longer the selected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4840 window because some other window is being selected. The given window is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4841 not being deleted, it is merely no longer the selected one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4842
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4843 This doesn't do anything right now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4844 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4845 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4846 energize_window_deselected_hook (struct window *window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4847 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4848 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4850
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4851 /* This is called just after a window has been selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4852
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4853 Show the menubar associated with this buffer; leave the psheets as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4854 they are.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4855 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4856 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4857 energize_window_selected_hook (struct window *window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4858 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4859 struct frame* frame = XFRAME (window->frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4860 Lisp_Object buffer = window->buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4861
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4862 if (FRAME_X_P (frame) && !MINI_WINDOW_P (window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4863 energize_show_menubar_of_buffer (window->frame, buffer, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4864 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4865
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4866
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4867
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4868 int current_debuggerpanel_exposed_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4869 int desired_debuggerpanel_exposed_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4870 int debuggerpanel_sheet;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4871
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4872 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4873 energize_show_menubar_of_buffer (Lisp_Object frame,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4874 Lisp_Object buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4875 Lisp_Object psheets_too)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4876 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4877 struct frame *f = decode_x_frame (frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4878
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4879 if (! NILP (psheets_too))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4880 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4881 Lisp_Object buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4882 XSETBUFFER (buffer, current_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4883 make_psheets_desired (f, buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4884 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4885 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4886
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4887
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4888 /* edit-mode dialog box
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4889 This stuff really sucks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4890 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4891
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4892 static struct editmode {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4893 int ok, external, view, edit, window, split;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4894 char *other;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4895 } editmode;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4896
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4897 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4898 edit_mode_callback (Widget widget, LWLIB_ID id, XtPointer client_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4899 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4900 widget_value *data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4901 char *name = (char *) client_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4902
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4903 if ((int) client_data == -1) name = "cancel"; /* WM_DELETE_WINDOW */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4904
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4905 if (!strcmp (XtName (widget), "otherText")) /* screw it */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4906 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4907 else if (!strcmp (name, "externalBox"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4908 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4909 /* make the text slot be active only if "other" is selected */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4910 data = malloc_widget_value ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4911 data->name = "externalOther";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4912 if (! lw_get_some_values (id, data)) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4913 data->enabled = data->selected;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4914 data->name = "otherText";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4915 lw_modify_all_widgets (id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4916 free_widget_value (data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4917 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4918 else if (!strcmp (name, "cancel"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4919 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4920 editmode.ok = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4921 lw_destroy_all_widgets (id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4922 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4923 else if (!strcmp (name, "help"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4924 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4925 Lisp_Object v = Fmake_vector (make_int (3), Qt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4926 vector_data (XVECTOR (v)) [0] = build_string ("ok");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4927 vector_data (XVECTOR (v)) [1] = list1 (Qignore);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4928 Fpopup_dialog_box (list2 (build_string ("dbx_editmode_help"), v));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4929 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4930 else if (!strcmp (name, "ok"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4931 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4932 editmode.ok = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4933 data = malloc_widget_value ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4934 data->name = "externalEmacs";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4935 if (! lw_get_some_values (id, data)) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4936 if (data->selected) editmode.external = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4937 data->name = "externalViXterm";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4938 if (! lw_get_some_values (id, data)) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4939 if (data->selected) editmode.external = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4940 data->name = "externalViCmdtool";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4941 if (! lw_get_some_values (id, data)) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4942 if (data->selected) editmode.external = 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4943 data->name = "externalOther";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4944 if (! lw_get_some_values (id, data)) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4945 if (data->selected) editmode.external = 3;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4946 data->name = "otherText";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4947 if (! lw_get_some_values (id, data)) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4948 editmode.other = data->value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4949
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4950 data->name = "emacsView";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4951 if (! lw_get_some_values (id, data)) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4952 if (data->selected) editmode.view = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4953 data->name = "viView";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4954 if (! lw_get_some_values (id, data)) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4955 if (data->selected) editmode.view = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4956 data->name = "lessView";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4957 if (! lw_get_some_values (id, data)) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4958 if (data->selected) editmode.view = 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4959
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4960 data->name = "editEmacs";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4961 if (! lw_get_some_values (id, data)) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4962 if (data->selected) editmode.edit = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4963 data->name = "editVi";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4964 if (! lw_get_some_values (id, data)) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4965 if (data->selected) editmode.edit = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4966
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4967 data->name = "windowOne";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4968 if (! lw_get_some_values (id, data)) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4969 if (data->selected) editmode.window = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4970 data->name = "windowSeveral";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4971 if (! lw_get_some_values (id, data)) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4972 if (data->selected) editmode.window = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4973 data->name = "windowMany";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4974 if (! lw_get_some_values (id, data)) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4975 if (data->selected) editmode.window = 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4976
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4977 data->name = "splitScreens";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4978 if (! lw_get_some_values (id, data)) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4979 editmode.split = !!data->selected;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4980
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4981 free_widget_value (data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4982 lw_destroy_all_widgets (id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4983 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4984 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4985 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4986 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4987 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4988 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4989
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4990 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4991 editmode_done (void *arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4992 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4993 return (editmode.ok != 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4994 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4996 extern LWLIB_ID new_lwlib_id (void);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4997
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4998 DEFUN ("energize-edit-mode-prompt", Fenergize_edit_mode_prompt,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4999 Senergize_edit_mode_prompt, 6, 6, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5001 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5002 (external, edit_mode, view_mode, other_text, window, split)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5003 Lisp_Object external, edit_mode, view_mode, other_text, window, split;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5004 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5005 int dbox_id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5006 struct frame *f = selected_frame ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5007 widget_value *data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5008 Widget parent, dbox;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5009 Lisp_Object frame = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5010
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5011 XSETFRAME (frame, f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5012 CHECK_X_FRAME (frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5013 parent = FRAME_X_SHELL_WIDGET (f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5014
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5015 CHECK_INT (external);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5016 CHECK_INT (edit_mode);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5017 CHECK_INT (view_mode);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5018 CHECK_INT (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5019 CHECK_INT (split);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5020 CHECK_STRING (other_text);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5021
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5022 editmode.ok = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5023 editmode.external = XINT (external);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5024 editmode.view = XINT (view_mode);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5025 editmode.edit = XINT (edit_mode);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5026 editmode.window = XINT (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5027 editmode.split = XINT (split);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5028 editmode.other = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5029
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5030 data = malloc_widget_value ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5031 data->name = "editmode";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5032 data->value = "editmode";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5033 data->enabled = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5034
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5035 dbox_id = new_lwlib_id ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5036 dbox = lw_create_widget ("editmode", "editmode", dbox_id, data, parent,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5037 1, 0, edit_mode_callback, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5038 data->value = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5039
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5040 data->name = "button1"; data->call_data = data->value = "ok";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5041 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5042 data->name = "button2"; data->call_data = data->value = "cancel";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5043 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5044 data->name = "button3"; data->call_data = data->value = "help";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5045 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5046 data->name = data->call_data = "externalBox";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5047 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5048 data->name = "otherText"; data->call_data = "otherText";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5049 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5050 data->name = "message"; data->value = "editmode";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5051 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5052
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5053 data->selected = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5054 switch (editmode.external)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5055 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5056 case 0: data->name = "externalEmacs"; break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5057 case 1: data->name = "externalViXterm"; break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5058 case 2: data->name = "externalViCmdtool"; break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5059 case 3: data->name = "externalOther"; break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5060 default: abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5061 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5062 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5063 switch (editmode.view)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5064 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5065 case 0: data->name = "emacsView"; break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5066 case 1: data->name = "viView"; break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5067 case 2: data->name = "lessView"; break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5068 default: abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5069 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5070 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5071 switch (editmode.edit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5072 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5073 case 0: data->name = "editEmacs"; break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5074 case 1: data->name = "editVi"; break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5075 default: abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5076 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5077 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5078 switch (editmode.window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5079 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5080 case 0: data->name = "windowOne"; break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5081 case 1: data->name = "windowSeveral"; break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5082 case 2: data->name = "windowMany"; break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5083 default: abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5084 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5085 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5086
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5087 data->name = "otherText";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5088 data->selected = 0;
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
5089 data->value = (char *) XSTRING_DATA (other_text);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5090 data->enabled = (editmode.external == 3);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5091 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5092
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5093 data->name = "splitScreens";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5094 data->enabled = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5095 data->selected = editmode.split;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5096 data->value = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5097 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5098
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5099 free_widget_value (data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5101 lw_pop_up_all_widgets (dbox_id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5103 wait_delaying_user_input (editmode_done, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5105 if (editmode.ok == -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5106 return Fcons (external,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5107 list5 (edit_mode, view_mode, other_text, window, split));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5108 else if (editmode.ok == 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5109 return Fcons (make_int (editmode.external),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5110 list5 (make_int (editmode.view),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5111 make_int (editmode.edit),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5112 build_string (editmode.other ? editmode.other : ""),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5113 make_int (editmode.window),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5114 make_int (editmode.split)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5115 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5116 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5117 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5119 static LWLIB_ID search_id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5120 static int last_search_up_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5122 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5123 hide_search_dialog (Widget w, LWLIB_ID id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5124 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5125 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5126 /* I'd like to do this, but the widget occasionally gets FUCKED */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5127 XUnmapWindow (XtDisplay (w), XtWindow (w));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5128 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5129 lw_destroy_all_widgets (id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5130 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5131 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5134 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5135 search_callback (Widget widget, LWLIB_ID id, XtPointer client_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5136 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5137 Widget parent = widget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5138 widget_value *data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5139 char *name = (char *) client_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5140 Lisp_Object search, replace;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5141 Lisp_Object case_sensitive_p, regexp_p, direction, match_word_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5142 Lisp_Object device = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5144 if ((int) client_data == -1) name = "done"; /* WM_DELETE_WINDOW */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5146 while (parent && XtClass (parent) != xmDialogShellWidgetClass)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5147 parent = XtParent (parent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5148 if (! parent) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5150 if (!strcmp (name, "done"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5151 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5152 hide_search_dialog (parent, id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5153 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5154 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5155 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5156 else if (!strcmp (name, "help"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5157 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5158 Lisp_Object v = Fmake_vector (3, Qt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5159 vector_data (XVECTOR (v)) [0] = build_string ("ok");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5160 vector_data (XVECTOR (v)) [1] = list1 (Qignore);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5161 Fpopup_dialog_box (list2 (build_string ("dbx_search_help"), v));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5162 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5163 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5164 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5166 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5167 struct device *d = get_device_from_display (XtDisplay (widget));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5168 XSETDEVICE (device, d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5169 DEVICE_X_MOUSE_TIMESTAMP (d) = DEVICE_X_GLOBAL_MOUSE_TIMESTAMP (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5170 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5172 if (!strcmp (name, "gotoStart"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5173 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5174 signal_special_Xt_user_event (device, Qcall_interactively,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5175 Qbeginning_of_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5176 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5177 else if (!strcmp (name, "gotoEnd"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5178 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5179 signal_special_Xt_user_event (device, Qcall_interactively,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5180 Qend_of_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5181 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5182 else if (!strcmp (name, "scrollForward"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5183 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5184 signal_special_Xt_user_event (device, Qcall_interactively,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5185 Qscroll_up);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5186 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5187 else if (!strcmp (name, "scrollBack"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5188 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5189 signal_special_Xt_user_event (device, Qcall_interactively,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5190 Qdown_up);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5191 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5192 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5193 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5194 data = malloc_widget_value ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5195 data->name = "searchText";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5196 if (! lw_get_some_values (id, data)) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5197 search = build_string (data->value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5198 data->name = "replaceText";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5199 if (! lw_get_some_values (id, data)) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5200 replace = build_string (data->value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5201 data->name = "regexpSearch";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5202 if (! lw_get_some_values (id, data)) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5203 regexp_p = (data->selected ? Qt : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5204 data->name = "caseSearch";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5205 if (! lw_get_some_values (id, data)) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5206 case_sensitive_p = (data->selected ? Qt : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5207 data->name = "matchWord";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5208 if (! lw_get_some_values (id, data)) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5209 match_word_p = (data->selected ? Qt : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5211 data->name = "directionForward";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5212 if (! lw_get_some_values (id, data)) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5213 direction = data->selected ? Qt : Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5215 if (!strcmp (name, "search"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5216 replace = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5217 else if (!strcmp (name, "replace"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5218 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5219 else if (!strcmp (name, "replace_all"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5220 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5221 replace = list1 (replace);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5222 /* hide_search_dialog (parent, id); */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5223 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5224 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5225 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5227 free_widget_value (data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5229 signal_special_Xt_user_event (device,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5230 intern ("energize-search-internal"),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5231 (NILP (replace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5232 ? list5 (case_sensitive_p, match_word_p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5233 regexp_p, direction, search)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5234 : list6 (case_sensitive_p, match_word_p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5235 regexp_p, direction, search,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5236 replace)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5237 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5238 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5241 DEFUN ("energize-search", Fenergize_search, Senergize_search, 0, 0, "" /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5242 Pop up the search-and-replace dialog box.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5243 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5244 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5245 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5246 int dbox_id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5247 struct frame *f = selected_frame ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5248 widget_value *data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5249 Widget parent, dbox;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5250 Lisp_Object frame = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5252 XSETFRAME (frame, f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5253 CHECK_X_FRAME (frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5254 parent = FRAME_X_SHELL_WIDGET (f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5256 data = malloc_widget_value ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5258 dbox_id = (search_id ? search_id : new_lwlib_id());
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5259 dbox = lw_create_widget ("search", "search", dbox_id, NULL, parent,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5260 1, 0, search_callback, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5261 data->enabled = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5262 data->value = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5264 data->name = "button1"; data->value = data->call_data = "search";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5265 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5266 data->name = "button2"; data->value = data->call_data = "replace";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5267 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5268 data->name = "button3"; data->value = data->call_data = "replace_all";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5269 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5270 data->name = "button4"; data->value = data->call_data = "done";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5271 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5273 data->value = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5274 data->name = data->call_data = "gotoStart";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5275 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5276 data->name = data->call_data = "gotoEnd";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5277 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5278 data->name = data->call_data = "scrollBack";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5279 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5280 data->name = data->call_data = "scrollForward";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5281 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5283 data->value = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5284 data->name = data->call_data = "caseSearch";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5285 data->selected = NILP (current_buffer->case_fold_search);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5286 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5288 data->name = data->call_data = "directionForward";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5289 data->selected = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5290 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5291 data->name = data->call_data = "directionBackward";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5292 data->selected = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5293 lw_modify_all_widgets (dbox_id, data, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5295 free_widget_value (data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5297 lw_pop_up_all_widgets (dbox_id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5298 last_search_up_p = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5299 if (search_id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5300 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5301 Widget w = lw_get_widget (dbox_id, parent, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5302 if (! w) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5303 XMapRaised (XtDisplay (w), XtWindow (w));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5304 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5305 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5306 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5307 search_id = dbox_id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5308 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5310 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5311 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5315 /*************** Definition of Emacs Lisp-callable functions ***************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5317 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5318 syms_of_energize (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5319 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5320 defsubr (&Senergize_send_buffer_modified);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5321 defsubr (&Senergize_list_menu);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5322 defsubr (&Senergize_execute_menu_item);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5323 defsubr (&Senergize_execute_command_internal);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5324 defsubr (&Sconnect_to_energize_internal);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5325 defsubr (&Sconnected_to_energize_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5326 defsubr (&Sclose_connection_to_energize);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5327 defsubr (&Shandle_energize_request);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5328 defsubr (&Senergize_buffer_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5329 defsubr (&Senergize_buffer_type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5330 defsubr (&Sset_energize_buffer_type_internal);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5331 defsubr (&Senergize_buffer_id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5332 defsubr (&Senergize_request_kill_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5333 defsubr (&Senergize_send_region);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5334 defsubr (&Senergize_user_input_buffer_mark);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5335 defsubr (&Senergize_update_menubar);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5336 defsubr (&Senergize_extent_menu_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5337 defsubr (&Senergize_query_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5338 defsubr (&Senergize_barf_if_buffer_locked);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5339 defsubr (&Senergize_psheets_visible_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5340 defsubr (&Senergize_buffer_has_psheets_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5341 defsubr (&Senergize_toggle_psheet);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5342 defsubr (&Senergize_protocol_level);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5343 defsubr (&Senergize_edit_mode_prompt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5344 defsubr (&Senergize_search);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5345 defsubr (&Sextent_to_generic_id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5347 defsymbol (&Qenergize_create_buffer_hook, "energize-create-buffer-hook");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5348 defsymbol (&Qenergize_buffer_modified_hook, "energize-buffer-modified-hook");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5350 defsymbol (&Qenergize_kernel_busy, "energize-kernel-busy");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5352 defsymbol (&Qenergize_kernel_busy_hook, "energize-kernel-busy-hook");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5353 defsymbol (&Qenergize_menu_update_hook, "energize-menu-update-hook");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5354 defsymbol (&Qbuffer_locked_by_energize, "buffer-locked-by-energize");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5355 defsymbol (&Qenergize_user_input_buffer_mark,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5356 "energize-user-input-buffer-mark");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5357 defsymbol (&Qenergize_make_many_buffers_visible,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5358 "energize-make-many-buffers-visible");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5359 defsymbol (&Qenergize, "energize");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5360 defsymbol (&Qenergize_auto_revert_buffer, "energize-auto-revert-buffer");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5361 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5363 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5364 vars_of_energize (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5365 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5366 energize_connection = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5367 inside_process_energize_request_1 = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5368
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5369 staticpro (&Venergize_buffers_list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5370 Venergize_buffers_list = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5372 staticpro (&Vall_energize_pixmaps);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5373 Vall_energize_pixmaps = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5375 Fprovide (intern ("energize"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5377 search_id = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5379 DEFVAR_LISP ("energize-process", &Venergize_process /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5380 The Lisp object representing the Energize connection, or nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5381 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5382 Venergize_process = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5384 DEFVAR_LISP ("energize-create-buffer-hook", &Venergize_create_buffer_hook /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5385 Hook called when buffer is created by energize; takes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5386 BUFFER as its only argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5387 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5388 Venergize_create_buffer_hook = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5391 DEFVAR_LISP ("energize-kernel-modification-hook",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5392 &Venergize_kernel_modification_hook /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5393 Hook called when a buffer is being modified by energize;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5394 takes no arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5395 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5396 Venergize_kernel_modification_hook = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5398 DEFVAR_BOOL ("ignore-kernel",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5399 &ignore_kernel /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5400 Set when the kernel should be ignored -- for debugging.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5401 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5402 ignore_kernel = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5403
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5404 DEFVAR_LISP ("energize-kernel-busy", &Venergize_kernel_busy /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5405 True if the Energize kernel is busy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5406 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5407 Venergize_kernel_busy = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5408 DEFVAR_LISP ("energize-kernel-busy-hook", &Venergize_kernel_busy_hook /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5409 Hook called when the Energize kernel becomes busy or non busy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5410 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5411 Venergize_kernel_busy_hook = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5412
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5413 DEFVAR_LISP ("energize-menu-update-hook", &Venergize_menu_update_hook /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5414 Hook called when the Energize kernel updates the menubar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5415 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5416 Venergize_menu_update_hook = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5418 DEFVAR_LISP ("energize-attributes-mapping", &Venergize_attributes_mapping /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5419 A-list to map kernel attributes indexes to Emacs attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5420 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5421 Venergize_attributes_mapping = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5423 DEFVAR_INT ("energize-extent-gc-threshold", &energize_extent_gc_threshold /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5424 Number of extents in a ModifyBuffer request above which to do a GC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5425 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5426 energize_extent_gc_threshold = 20;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5428 pure_put (Qbuffer_locked_by_energize, Qerror_conditions,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5429 list2 (Qbuffer_locked_by_energize, Qerror));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5430 pure_put (Qbuffer_locked_by_energize, Qerror_message,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5431 build_string ("Buffer is currently locked by kernel"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5432 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5434 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5435 complex_vars_of_energize (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5436 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5437 image_cache = make_strings_hashtable (50);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5438 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5440 #endif /* ENERGIZE */