Mercurial > hg > xemacs-beta
comparison src/event-stream.c @ 404:2f8bb876ab1d r21-2-32
Import from CVS: tag r21-2-32
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:16:07 +0200 |
parents | a86b2b5e0111 |
children | b8cc9ab3f761 |
comparison
equal
deleted
inserted
replaced
403:9f011ab08d48 | 404:2f8bb876ab1d |
---|---|
20 along with XEmacs; see the file COPYING. If not, write to | 20 along with XEmacs; see the file COPYING. If not, write to |
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
22 Boston, MA 02111-1307, USA. */ | 22 Boston, MA 02111-1307, USA. */ |
23 | 23 |
24 /* Synched up with: Not in FSF. */ | 24 /* Synched up with: Not in FSF. */ |
25 | |
26 /* Authorship: | |
27 | |
28 Created 1991 by Jamie Zawinski. | |
29 A great deal of work over the ages by Ben Wing (Mule-ization for 19.12, | |
30 device abstraction for 19.12/19.13, async timers for 19.14, | |
31 rewriting of focus code for 19.12, pre-idle hook for 19.12, | |
32 redoing of signal and quit handling for 19.9 and 19.12, | |
33 misc-user events to clean up menu/scrollbar handling for 19.11, | |
34 function-key-map/key-translation-map/keyboard-translate-table for | |
35 19.13/19.14, open-dribble-file for 19.13, much other cleanup). | |
36 focus-follows-mouse from Chuck Thompson, 1995. | |
37 XIM stuff by Martin Buchholz, c. 1996?. | |
38 */ | |
25 | 39 |
26 /* This file has been Mule-ized. */ | 40 /* This file has been Mule-ized. */ |
27 | 41 |
28 /* | 42 /* |
29 * DANGER!! | 43 * DANGER!! |
36 */ | 50 */ |
37 | 51 |
38 /* TODO: | 52 /* TODO: |
39 This stuff is way too hard to maintain - needs rework. | 53 This stuff is way too hard to maintain - needs rework. |
40 | 54 |
41 (global-set-key "\C-p" global-map) causes a crash - need recursion check. | |
42 | |
43 C-x @ h <scrollbar-drag> x causes a crash. | 55 C-x @ h <scrollbar-drag> x causes a crash. |
44 | 56 |
45 The command builder should deal only with key and button events. | 57 The command builder should deal only with key and button events. |
46 Other command events should be able to come in the MIDDLE of a key | 58 Other command events should be able to come in the MIDDLE of a key |
47 sequence, without disturbing the key sequence composition, or the | 59 sequence, without disturbing the key sequence composition, or the |
59 instead of RETYPING, the key sequence. | 71 instead of RETYPING, the key sequence. |
60 */ | 72 */ |
61 | 73 |
62 #include <config.h> | 74 #include <config.h> |
63 #include "lisp.h" | 75 #include "lisp.h" |
64 | |
65 #ifdef HAVE_X_WINDOWS | |
66 #include "console-x.h" /* for menu accelerators ... */ | |
67 #include "gui-x.h" | |
68 #include "../lwlib/lwlib.h" | |
69 #else | |
70 #define lw_menu_active 0 | |
71 #endif | |
72 | 76 |
73 #include "blocktype.h" | 77 #include "blocktype.h" |
74 #include "buffer.h" | 78 #include "buffer.h" |
75 #include "commands.h" | 79 #include "commands.h" |
76 #include "device.h" | 80 #include "device.h" |
79 #include "frame.h" | 83 #include "frame.h" |
80 #include "insdel.h" /* for buffer_reset_changes */ | 84 #include "insdel.h" /* for buffer_reset_changes */ |
81 #include "keymap.h" | 85 #include "keymap.h" |
82 #include "lstream.h" | 86 #include "lstream.h" |
83 #include "macros.h" /* for defining_keyboard_macro */ | 87 #include "macros.h" /* for defining_keyboard_macro */ |
88 #include "menubar.h" /* #### for evil kludges. */ | |
84 #include "process.h" | 89 #include "process.h" |
85 #include "window.h" | 90 #include "window.h" |
86 | 91 |
87 #include "sysdep.h" /* init_poll_for_quit() */ | 92 #include "sysdep.h" /* init_poll_for_quit() */ |
88 #include "syssignal.h" /* SIGCHLD, etc. */ | 93 #include "syssignal.h" /* SIGCHLD, etc. */ |
105 | 110 |
106 /* Hooks to run before and after each command. */ | 111 /* Hooks to run before and after each command. */ |
107 Lisp_Object Vpre_command_hook, Vpost_command_hook; | 112 Lisp_Object Vpre_command_hook, Vpost_command_hook; |
108 Lisp_Object Qpre_command_hook, Qpost_command_hook; | 113 Lisp_Object Qpre_command_hook, Qpost_command_hook; |
109 | 114 |
115 /* See simple.el */ | |
116 Lisp_Object Qhandle_pre_motion_command, Qhandle_post_motion_command; | |
117 | |
110 /* Hook run when XEmacs is about to be idle. */ | 118 /* Hook run when XEmacs is about to be idle. */ |
111 Lisp_Object Qpre_idle_hook, Vpre_idle_hook; | 119 Lisp_Object Qpre_idle_hook, Vpre_idle_hook; |
112 | 120 |
113 /* Control gratuitous keyboard focus throwing. */ | 121 /* Control gratuitous keyboard focus throwing. */ |
114 int focus_follows_mouse; | 122 int focus_follows_mouse; |
115 | 123 |
116 #ifdef ILL_CONCEIVED_HOOK | 124 #if 0 /* FSF Emacs crap */ |
117 /* Hook run after a command if there's no more input soon. */ | 125 /* Hook run after a command if there's no more input soon. */ |
118 Lisp_Object Qpost_command_idle_hook, Vpost_command_idle_hook; | 126 Lisp_Object Qpost_command_idle_hook, Vpost_command_idle_hook; |
119 | 127 |
120 /* Delay time in microseconds before running post-command-idle-hook. */ | 128 /* Delay time in microseconds before running post-command-idle-hook. */ |
121 int post_command_idle_delay; | 129 int post_command_idle_delay; |
122 #endif /* ILL_CONCEIVED_HOOK */ | 130 |
123 | |
124 #ifdef DEFERRED_ACTION_CRAP | |
125 /* List of deferred actions to be performed at a later time. | 131 /* List of deferred actions to be performed at a later time. |
126 The precise format isn't relevant here; we just check whether it is nil. */ | 132 The precise format isn't relevant here; we just check whether it is nil. */ |
127 Lisp_Object Vdeferred_action_list; | 133 Lisp_Object Vdeferred_action_list; |
128 | 134 |
129 /* Function to call to handle deferred actions, when there are any. */ | 135 /* Function to call to handle deferred actions, when there are any. */ |
130 Lisp_Object Vdeferred_action_function; | 136 Lisp_Object Vdeferred_action_function; |
131 Lisp_Object Qdeferred_action_function; | 137 Lisp_Object Qdeferred_action_function; |
132 #endif /* DEFERRED_ACTION_CRAP */ | 138 #endif /* FSF Emacs crap */ |
133 | 139 |
134 /* Non-nil disable property on a command means | 140 /* Non-nil disable property on a command means |
135 do not execute it; call disabled-command-hook's value instead. */ | 141 do not execute it; call disabled-command-hook's value instead. */ |
136 Lisp_Object Qdisabled, Vdisabled_command_hook; | 142 Lisp_Object Qdisabled, Vdisabled_command_hook; |
137 | 143 |
162 Lisp_Object Vunread_command_event; /* obsoleteness support */ | 168 Lisp_Object Vunread_command_event; /* obsoleteness support */ |
163 | 169 |
164 static Lisp_Object Qunread_command_events, Qunread_command_event; | 170 static Lisp_Object Qunread_command_events, Qunread_command_event; |
165 | 171 |
166 /* Previous command, represented by a Lisp object. | 172 /* Previous command, represented by a Lisp object. |
167 Does not include prefix commands and arg setting commands */ | 173 Does not include prefix commands and arg setting commands. */ |
168 Lisp_Object Vlast_command; | 174 Lisp_Object Vlast_command; |
169 | 175 |
176 /* Contents of this-command-properties for the last command. */ | |
177 Lisp_Object Vlast_command_properties; | |
178 | |
170 /* If a command sets this, the value goes into | 179 /* If a command sets this, the value goes into |
171 previous-command for the next command. */ | 180 last-command for the next command. */ |
172 Lisp_Object Vthis_command; | 181 Lisp_Object Vthis_command; |
182 | |
183 /* If a command sets this, the value goes into | |
184 last-command-properties for the next command. */ | |
185 Lisp_Object Vthis_command_properties; | |
173 | 186 |
174 /* The value of point when the last command was executed. */ | 187 /* The value of point when the last command was executed. */ |
175 Bufpos last_point_position; | 188 Bufpos last_point_position; |
176 | 189 |
177 /* The frame that was current when the last command was started. */ | 190 /* The frame that was current when the last command was started. */ |
232 int recent_keys_ring_index; | 245 int recent_keys_ring_index; |
233 | 246 |
234 /* Boolean specifying whether keystrokes should be added to | 247 /* Boolean specifying whether keystrokes should be added to |
235 recent-keys. */ | 248 recent-keys. */ |
236 int inhibit_input_event_recording; | 249 int inhibit_input_event_recording; |
237 | |
238 /* prefix key(s) that must match in order to activate menu. | |
239 This is ugly. fix me. | |
240 */ | |
241 Lisp_Object Vmenu_accelerator_prefix; | |
242 | |
243 /* list of modifier keys to match accelerator for top level menus */ | |
244 Lisp_Object Vmenu_accelerator_modifiers; | |
245 | |
246 /* whether menu accelerators are enabled */ | |
247 Lisp_Object Vmenu_accelerator_enabled; | |
248 | |
249 /* keymap for auxiliary menu accelerator functions */ | |
250 Lisp_Object Vmenu_accelerator_map; | |
251 | |
252 Lisp_Object Qmenu_force; | |
253 Lisp_Object Qmenu_fallback; | |
254 Lisp_Object Qmenu_quit; | |
255 Lisp_Object Qmenu_up; | |
256 Lisp_Object Qmenu_down; | |
257 Lisp_Object Qmenu_left; | |
258 Lisp_Object Qmenu_right; | |
259 Lisp_Object Qmenu_select; | |
260 Lisp_Object Qmenu_escape; | |
261 | 250 |
262 Lisp_Object Qself_insert_defer_undo; | 251 Lisp_Object Qself_insert_defer_undo; |
263 | 252 |
264 /* this is in keymap.c */ | 253 /* this is in keymap.c */ |
265 extern Lisp_Object Fmake_keymap (Lisp_Object name); | 254 extern Lisp_Object Fmake_keymap (Lisp_Object name); |
285 #endif | 274 #endif |
286 | 275 |
287 | 276 |
288 /* The callback routines for the window system or terminal driver */ | 277 /* The callback routines for the window system or terminal driver */ |
289 struct event_stream *event_stream; | 278 struct event_stream *event_stream; |
290 | |
291 /* This structure is what we use to encapsulate the state of a command sequence | |
292 being composed; key events are executed by adding themselves to the command | |
293 builder; if the command builder is then complete (does not still represent | |
294 a prefix key sequence) it executes the corresponding command. | |
295 */ | |
296 struct command_builder | |
297 { | |
298 struct lcrecord_header header; | |
299 Lisp_Object console; /* back pointer to the console this command | |
300 builder is for */ | |
301 /* Qnil, or a Lisp_Event representing the first event read | |
302 * after the last command completed. Threaded. */ | |
303 /* #### NYI */ | |
304 Lisp_Object prefix_events; | |
305 /* Qnil, or a Lisp_Event representing event in the current | |
306 * keymap-lookup sequence. Subsequent events are threaded via | |
307 * the event's next slot */ | |
308 Lisp_Object current_events; | |
309 /* Last elt of above */ | |
310 Lisp_Object most_current_event; | |
311 /* Last elt before function map code took over. What this means is: | |
312 All prefixes up to (but not including) this event have non-nil | |
313 bindings, but the prefix including this event has a nil binding. | |
314 Any events in the chain after this one were read solely because | |
315 we're part of a possible function key. If we end up with | |
316 something that's not part of a possible function key, we have to | |
317 unread all of those events. */ | |
318 Lisp_Object last_non_munged_event; | |
319 /* One set of values for function-key-map, one for key-translation-map */ | |
320 struct munging_key_translation | |
321 { | |
322 /* First event that can begin a possible function key sequence | |
323 (to be translated according to function-key-map). Normally | |
324 this is the first event in the chain. However, once we've | |
325 translated a sequence through function-key-map, this will point | |
326 to the first event after the translated sequence: we don't ever | |
327 want to translate any events twice through function-key-map, or | |
328 things could get really screwed up (e.g. if the user created a | |
329 translation loop). If this is nil, then the next-read event is | |
330 the first that can begin a function key sequence. */ | |
331 Lisp_Object first_mungeable_event; | |
332 } munge_me[2]; | |
333 | |
334 Bufbyte *echo_buf; | |
335 Bytecount echo_buf_length; /* size of echo_buf */ | |
336 Bytecount echo_buf_index; /* index into echo_buf | |
337 * -1 before doing echoing for new cmd */ | |
338 /* Self-insert-command is magic in that it doesn't always push an undo- | |
339 boundary: up to 20 consecutive self-inserts can happen before an undo- | |
340 boundary is pushed. This variable is that counter. | |
341 */ | |
342 int self_insert_countdown; | |
343 }; | |
344 | 279 |
345 static void echo_key_event (struct command_builder *, Lisp_Object event); | 280 static void echo_key_event (struct command_builder *, Lisp_Object event); |
346 static void maybe_kbd_translate (Lisp_Object event); | 281 static void maybe_kbd_translate (Lisp_Object event); |
347 | 282 |
348 /* This structure is basically a typeahead queue: things like | 283 /* This structure is basically a typeahead queue: things like |
503 | 438 |
504 static int | 439 static int |
505 event_stream_event_pending_p (int user) | 440 event_stream_event_pending_p (int user) |
506 { | 441 { |
507 return event_stream && event_stream->event_pending_p (user); | 442 return event_stream && event_stream->event_pending_p (user); |
443 } | |
444 | |
445 static void | |
446 event_stream_force_event_pending (struct frame* f) | |
447 { | |
448 if (event_stream->force_event_pending) | |
449 event_stream->force_event_pending (f); | |
508 } | 450 } |
509 | 451 |
510 static int | 452 static int |
511 maybe_read_quit_event (Lisp_Event *event) | 453 maybe_read_quit_event (Lisp_Event *event) |
512 { | 454 { |
732 else | 674 else |
733 echo_keystrokes = 0; | 675 echo_keystrokes = 0; |
734 | 676 |
735 if (minibuf_level == 0 | 677 if (minibuf_level == 0 |
736 && echo_keystrokes > 0.0 | 678 && echo_keystrokes > 0.0 |
737 && !lw_menu_active) | 679 #if defined (HAVE_X_WINDOWS) && defined (LWLIB_MENUBARS_LUCID) |
680 && !x_kludge_lw_menu_active () | |
681 #endif | |
682 ) | |
738 { | 683 { |
739 if (!no_snooze) | 684 if (!no_snooze) |
740 { | 685 { |
741 /* #### C-g here will cause QUIT. Setting dont_check_for_quit | 686 /* #### C-g here will cause QUIT. Setting dont_check_for_quit |
742 doesn't work. See check_quit. */ | 687 doesn't work. See check_quit. */ |
2121 struct console *con = XCONSOLE (Vselected_console); | 2066 struct console *con = XCONSOLE (Vselected_console); |
2122 struct command_builder *command_builder = | 2067 struct command_builder *command_builder = |
2123 XCOMMAND_BUILDER (con->command_builder); | 2068 XCOMMAND_BUILDER (con->command_builder); |
2124 int store_this_key = 0; | 2069 int store_this_key = 0; |
2125 struct gcpro gcpro1; | 2070 struct gcpro gcpro1; |
2126 #ifdef LWLIB_MENUBARS_LUCID | |
2127 extern int in_menu_callback; /* defined in menubar-x.c */ | |
2128 #endif /* LWLIB_MENUBARS_LUCID */ | |
2129 | 2071 |
2130 GCPRO1 (event); | 2072 GCPRO1 (event); |
2131 /* DO NOT do QUIT anywhere within this function or the functions it calls. | 2073 /* DO NOT do QUIT anywhere within this function or the functions it calls. |
2132 We want to read the ^G as an event. */ | 2074 We want to read the ^G as an event. */ |
2133 | 2075 |
2397 else | 2339 else |
2398 execute_internal_event (event); | 2340 execute_internal_event (event); |
2399 } | 2341 } |
2400 UNGCPRO; | 2342 UNGCPRO; |
2401 return event; | 2343 return event; |
2344 } | |
2345 | |
2346 DEFUN ("dispatch-non-command-events", Fdispatch_non_command_events, 0, 0, 0, /* | |
2347 Dispatch any pending "magic" events. | |
2348 | |
2349 This function is useful for forcing the redisplay of native | |
2350 widgets. Normally these are redisplayed through a native window-system | |
2351 event encoded as magic event, rather than by the redisplay code. This | |
2352 function does not call redisplay or do any of the other things that | |
2353 `next-event' does. | |
2354 */ | |
2355 ()) | |
2356 { | |
2357 /* This function can GC */ | |
2358 Lisp_Object event = Qnil; | |
2359 struct gcpro gcpro1; | |
2360 GCPRO1 (event); | |
2361 event = Fmake_event (Qnil, Qnil); | |
2362 | |
2363 /* Make sure that there will be something in the native event queue | |
2364 so that externally managed things (e.g. widgets) get some CPU | |
2365 time. */ | |
2366 event_stream_force_event_pending (selected_frame ()); | |
2367 | |
2368 while (event_stream_event_pending_p (0)) | |
2369 { | |
2370 QUIT; /* next_event_internal() does not QUIT. */ | |
2371 | |
2372 /* We're a generator of the command_event_queue, so we can't be a | |
2373 consumer as well. Also, we have no reason to consult the | |
2374 command_event_queue; there are only user and eval-events there, | |
2375 and we'd just have to put them back anyway. | |
2376 */ | |
2377 next_event_internal (event, 0); /* blocks */ | |
2378 /* See the comment in accept-process-output about Vquit_flag */ | |
2379 if (XEVENT_TYPE (event) == magic_event || | |
2380 XEVENT_TYPE (event) == timeout_event || | |
2381 XEVENT_TYPE (event) == process_event || | |
2382 XEVENT_TYPE (event) == pointer_motion_event) | |
2383 execute_internal_event (event); | |
2384 else | |
2385 { | |
2386 enqueue_command_event_1 (event); | |
2387 break; | |
2388 } | |
2389 } | |
2390 | |
2391 Fdeallocate_event (event); | |
2392 UNGCPRO; | |
2393 return Qnil; | |
2402 } | 2394 } |
2403 | 2395 |
2404 static void | 2396 static void |
2405 reset_current_events (struct command_builder *command_builder) | 2397 reset_current_events (struct command_builder *command_builder) |
2406 { | 2398 { |
3094 return Qnil; | 3086 return Qnil; |
3095 | 3087 |
3096 return event_binding (event0, 1); | 3088 return event_binding (event0, 1); |
3097 } | 3089 } |
3098 | 3090 |
3099 #if defined(HAVE_X_WINDOWS) && defined(LWLIB_MENUBARS_LUCID) | |
3100 static void | |
3101 menu_move_up (void) | |
3102 { | |
3103 widget_value *current = lw_get_entries (False); | |
3104 widget_value *entries = lw_get_entries (True); | |
3105 widget_value *prev = NULL; | |
3106 | |
3107 while (entries != current) | |
3108 { | |
3109 if (entries->name /*&& entries->enabled*/) prev = entries; | |
3110 entries = entries->next; | |
3111 assert (entries); | |
3112 } | |
3113 | |
3114 if (!prev) | |
3115 /* move to last item */ | |
3116 { | |
3117 while (entries->next) | |
3118 { | |
3119 if (entries->name /*&& entries->enabled*/) prev = entries; | |
3120 entries = entries->next; | |
3121 } | |
3122 if (prev) | |
3123 { | |
3124 if (entries->name /*&& entries->enabled*/) | |
3125 prev = entries; | |
3126 } | |
3127 else | |
3128 { | |
3129 /* no selectable items in this menu, pop up to previous level */ | |
3130 lw_pop_menu (); | |
3131 return; | |
3132 } | |
3133 } | |
3134 lw_set_item (prev); | |
3135 } | |
3136 | |
3137 static void | |
3138 menu_move_down (void) | |
3139 { | |
3140 widget_value *current = lw_get_entries (False); | |
3141 widget_value *new = current; | |
3142 | |
3143 while (new->next) | |
3144 { | |
3145 new = new->next; | |
3146 if (new->name /*&& new->enabled*/) break; | |
3147 } | |
3148 | |
3149 if (new==current||!(new->name/*||new->enabled*/)) | |
3150 { | |
3151 new = lw_get_entries (True); | |
3152 while (new!=current) | |
3153 { | |
3154 if (new->name /*&& new->enabled*/) break; | |
3155 new = new->next; | |
3156 } | |
3157 if (new==current&&!(new->name /*|| new->enabled*/)) | |
3158 { | |
3159 lw_pop_menu (); | |
3160 return; | |
3161 } | |
3162 } | |
3163 | |
3164 lw_set_item (new); | |
3165 } | |
3166 | |
3167 static void | |
3168 menu_move_left (void) | |
3169 { | |
3170 int level = lw_menu_level (); | |
3171 int l = level; | |
3172 widget_value *current; | |
3173 | |
3174 while (level-- >= 3) | |
3175 lw_pop_menu (); | |
3176 | |
3177 menu_move_up (); | |
3178 current = lw_get_entries (False); | |
3179 if (l > 2 && current->contents) | |
3180 lw_push_menu (current->contents); | |
3181 } | |
3182 | |
3183 static void | |
3184 menu_move_right (void) | |
3185 { | |
3186 int level = lw_menu_level (); | |
3187 int l = level; | |
3188 widget_value *current; | |
3189 | |
3190 while (level-- >= 3) | |
3191 lw_pop_menu (); | |
3192 | |
3193 menu_move_down (); | |
3194 current = lw_get_entries (False); | |
3195 if (l > 2 && current->contents) | |
3196 lw_push_menu (current->contents); | |
3197 } | |
3198 | |
3199 static void | |
3200 menu_select_item (widget_value *val) | |
3201 { | |
3202 if (val == NULL) | |
3203 val = lw_get_entries (False); | |
3204 | |
3205 /* is match a submenu? */ | |
3206 | |
3207 if (val->contents) | |
3208 { | |
3209 /* enter the submenu */ | |
3210 | |
3211 lw_set_item (val); | |
3212 lw_push_menu (val->contents); | |
3213 } | |
3214 else | |
3215 { | |
3216 /* Execute the menu entry by calling the menu's `select' | |
3217 callback function | |
3218 */ | |
3219 lw_kill_menus (val); | |
3220 } | |
3221 } | |
3222 | |
3223 static Lisp_Object | |
3224 command_builder_operate_menu_accelerator (struct command_builder *builder) | |
3225 { | |
3226 /* this function can GC */ | |
3227 | |
3228 struct console *con = XCONSOLE (Vselected_console); | |
3229 Lisp_Object evee = builder->most_current_event; | |
3230 Lisp_Object binding; | |
3231 widget_value *entries; | |
3232 | |
3233 extern int lw_menu_accelerate; /* lwlib.c */ | |
3234 | |
3235 #if 0 | |
3236 { | |
3237 int i; | |
3238 Lisp_Object t; | |
3239 char buf[50]; | |
3240 | |
3241 t = builder->current_events; | |
3242 i = 0; | |
3243 while (!NILP (t)) | |
3244 { | |
3245 i++; | |
3246 sprintf (buf,"OPERATE (%d): ",i); | |
3247 write_c_string (buf, Qexternal_debugging_output); | |
3248 print_internal (t, Qexternal_debugging_output, 1); | |
3249 write_c_string ("\n", Qexternal_debugging_output); | |
3250 t = XEVENT_NEXT (t); | |
3251 } | |
3252 } | |
3253 #endif /* 0 */ | |
3254 | |
3255 /* menu accelerator keys don't go into keyboard macros */ | |
3256 if (!NILP (con->defining_kbd_macro) && NILP (Vexecuting_macro)) | |
3257 con->kbd_macro_ptr = con->kbd_macro_end; | |
3258 | |
3259 /* don't echo menu accelerator keys */ | |
3260 /*reset_key_echo (builder, 1);*/ | |
3261 | |
3262 if (!lw_menu_accelerate) | |
3263 { | |
3264 /* `convert' mouse display to keyboard display | |
3265 by entering the open submenu | |
3266 */ | |
3267 entries = lw_get_entries (False); | |
3268 if (entries->contents) | |
3269 { | |
3270 lw_push_menu (entries->contents); | |
3271 lw_display_menu (CurrentTime); | |
3272 } | |
3273 } | |
3274 | |
3275 /* compare event to the current menu accelerators */ | |
3276 | |
3277 entries=lw_get_entries (True); | |
3278 | |
3279 while (entries) | |
3280 { | |
3281 Lisp_Object accel; | |
3282 VOID_TO_LISP (accel, entries->accel); | |
3283 if (entries->name && !NILP (accel)) | |
3284 { | |
3285 if (event_matches_key_specifier_p (XEVENT (evee), accel)) | |
3286 { | |
3287 /* a match! */ | |
3288 | |
3289 menu_select_item (entries); | |
3290 | |
3291 if (lw_menu_active) lw_display_menu (CurrentTime); | |
3292 | |
3293 reset_this_command_keys (Vselected_console, 1); | |
3294 /*reset_command_builder_event_chain (builder);*/ | |
3295 return Vmenu_accelerator_map; | |
3296 } | |
3297 } | |
3298 entries = entries->next; | |
3299 } | |
3300 | |
3301 /* try to look up event in menu-accelerator-map */ | |
3302 | |
3303 binding = event_binding_in (evee, Vmenu_accelerator_map, 1); | |
3304 | |
3305 if (NILP (binding)) | |
3306 { | |
3307 /* beep at user for undefined key */ | |
3308 return Qnil; | |
3309 } | |
3310 else | |
3311 { | |
3312 if (EQ (binding, Qmenu_quit)) | |
3313 { | |
3314 /* turn off menus and set quit flag */ | |
3315 lw_kill_menus (NULL); | |
3316 Vquit_flag = Qt; | |
3317 } | |
3318 else if (EQ (binding, Qmenu_up)) | |
3319 { | |
3320 int level = lw_menu_level (); | |
3321 if (level > 2) | |
3322 menu_move_up (); | |
3323 } | |
3324 else if (EQ (binding, Qmenu_down)) | |
3325 { | |
3326 int level = lw_menu_level (); | |
3327 if (level > 2) | |
3328 menu_move_down (); | |
3329 else | |
3330 menu_select_item (NULL); | |
3331 } | |
3332 else if (EQ (binding, Qmenu_left)) | |
3333 { | |
3334 int level = lw_menu_level (); | |
3335 if (level > 3) | |
3336 { | |
3337 lw_pop_menu (); | |
3338 lw_display_menu (CurrentTime); | |
3339 } | |
3340 else | |
3341 menu_move_left (); | |
3342 } | |
3343 else if (EQ (binding, Qmenu_right)) | |
3344 { | |
3345 int level = lw_menu_level (); | |
3346 if (level > 2 && | |
3347 lw_get_entries (False)->contents) | |
3348 { | |
3349 widget_value *current = lw_get_entries (False); | |
3350 if (current->contents) | |
3351 menu_select_item (NULL); | |
3352 } | |
3353 else | |
3354 menu_move_right (); | |
3355 } | |
3356 else if (EQ (binding, Qmenu_select)) | |
3357 menu_select_item (NULL); | |
3358 else if (EQ (binding, Qmenu_escape)) | |
3359 { | |
3360 int level = lw_menu_level (); | |
3361 | |
3362 if (level > 2) | |
3363 { | |
3364 lw_pop_menu (); | |
3365 lw_display_menu (CurrentTime); | |
3366 } | |
3367 else | |
3368 { | |
3369 /* turn off menus quietly */ | |
3370 lw_kill_menus (NULL); | |
3371 } | |
3372 } | |
3373 else if (KEYMAPP (binding)) | |
3374 { | |
3375 /* prefix key */ | |
3376 reset_this_command_keys (Vselected_console, 1); | |
3377 /*reset_command_builder_event_chain (builder);*/ | |
3378 return binding; | |
3379 } | |
3380 else | |
3381 { | |
3382 /* turn off menus and execute binding */ | |
3383 lw_kill_menus (NULL); | |
3384 reset_this_command_keys (Vselected_console, 1); | |
3385 /*reset_command_builder_event_chain (builder);*/ | |
3386 return binding; | |
3387 } | |
3388 } | |
3389 | |
3390 if (lw_menu_active) lw_display_menu (CurrentTime); | |
3391 | |
3392 reset_this_command_keys (Vselected_console, 1); | |
3393 /*reset_command_builder_event_chain (builder);*/ | |
3394 | |
3395 return Vmenu_accelerator_map; | |
3396 } | |
3397 | |
3398 static Lisp_Object | |
3399 menu_accelerator_junk_on_error (Lisp_Object errordata, Lisp_Object ignored) | |
3400 { | |
3401 Vmenu_accelerator_prefix = Qnil; | |
3402 Vmenu_accelerator_modifiers = Qnil; | |
3403 Vmenu_accelerator_enabled = Qnil; | |
3404 if (!NILP (errordata)) | |
3405 { | |
3406 Lisp_Object args[2]; | |
3407 | |
3408 args[0] = build_string ("Error in menu accelerators (setting to nil)"); | |
3409 /* #### This should call | |
3410 (with-output-to-string (display-error errordata)) | |
3411 but that stuff is all in Lisp currently. */ | |
3412 args[1] = errordata; | |
3413 warn_when_safe_lispobj | |
3414 (Qerror, Qwarning, | |
3415 emacs_doprnt_string_lisp ((const Bufbyte *) "%s: %s", | |
3416 Qnil, -1, 2, args)); | |
3417 } | |
3418 | |
3419 return Qnil; | |
3420 } | |
3421 | |
3422 static Lisp_Object | |
3423 menu_accelerator_safe_compare (Lisp_Object event0) | |
3424 { | |
3425 if (CONSP (Vmenu_accelerator_prefix)) | |
3426 { | |
3427 Lisp_Object t; | |
3428 t=Vmenu_accelerator_prefix; | |
3429 while (!NILP (t) | |
3430 && !NILP (event0) | |
3431 && event_matches_key_specifier_p (XEVENT (event0), Fcar (t))) | |
3432 { | |
3433 t = Fcdr (t); | |
3434 event0 = XEVENT_NEXT (event0); | |
3435 } | |
3436 if (!NILP (t)) | |
3437 return Qnil; | |
3438 } | |
3439 else if (NILP (event0)) | |
3440 return Qnil; | |
3441 else if (event_matches_key_specifier_p (XEVENT (event0), Vmenu_accelerator_prefix)) | |
3442 event0 = XEVENT_NEXT (event0); | |
3443 else | |
3444 return Qnil; | |
3445 return event0; | |
3446 } | |
3447 | |
3448 static Lisp_Object | |
3449 menu_accelerator_safe_mod_compare (Lisp_Object cons) | |
3450 { | |
3451 return (event_matches_key_specifier_p (XEVENT (XCAR (cons)), XCDR (cons)) | |
3452 ? Qt | |
3453 : Qnil); | |
3454 } | |
3455 | |
3456 static Lisp_Object | |
3457 command_builder_find_menu_accelerator (struct command_builder *builder) | |
3458 { | |
3459 /* this function can GC */ | |
3460 Lisp_Object event0 = builder->current_events; | |
3461 struct console *con = XCONSOLE (Vselected_console); | |
3462 struct frame *f = XFRAME (CONSOLE_SELECTED_FRAME (con)); | |
3463 Widget menubar_widget; | |
3464 | |
3465 /* compare entries in event0 against the menu prefix */ | |
3466 | |
3467 if ((!CONSOLE_X_P (XCONSOLE (builder->console))) || NILP (event0) || | |
3468 XEVENT (event0)->event_type != key_press_event) | |
3469 return Qnil; | |
3470 | |
3471 if (!NILP (Vmenu_accelerator_prefix)) | |
3472 { | |
3473 event0 = condition_case_1 (Qerror, | |
3474 menu_accelerator_safe_compare, | |
3475 event0, | |
3476 menu_accelerator_junk_on_error, | |
3477 Qnil); | |
3478 } | |
3479 | |
3480 if (NILP (event0)) | |
3481 return Qnil; | |
3482 | |
3483 menubar_widget = FRAME_X_MENUBAR_WIDGET (f); | |
3484 if (menubar_widget | |
3485 && CONSP (Vmenu_accelerator_modifiers)) | |
3486 { | |
3487 Lisp_Object fake; | |
3488 Lisp_Object last = Qnil; | |
3489 struct gcpro gcpro1; | |
3490 Lisp_Object matchp; | |
3491 | |
3492 widget_value *val; | |
3493 LWLIB_ID id = XPOPUP_DATA (f->menubar_data)->id; | |
3494 | |
3495 val = lw_get_all_values (id); | |
3496 if (val) | |
3497 { | |
3498 val = val->contents; | |
3499 | |
3500 fake = Fcopy_sequence (Vmenu_accelerator_modifiers); | |
3501 last = fake; | |
3502 | |
3503 while (!NILP (Fcdr (last))) | |
3504 last = Fcdr (last); | |
3505 | |
3506 Fsetcdr (last, Fcons (Qnil, Qnil)); | |
3507 last = Fcdr (last); | |
3508 } | |
3509 | |
3510 fake = Fcons (Qnil, fake); | |
3511 | |
3512 GCPRO1 (fake); | |
3513 | |
3514 while (val) | |
3515 { | |
3516 Lisp_Object accel; | |
3517 VOID_TO_LISP (accel, val->accel); | |
3518 if (val->name && !NILP (accel)) | |
3519 { | |
3520 Fsetcar (last, accel); | |
3521 Fsetcar (fake, event0); | |
3522 matchp = condition_case_1 (Qerror, | |
3523 menu_accelerator_safe_mod_compare, | |
3524 fake, | |
3525 menu_accelerator_junk_on_error, | |
3526 Qnil); | |
3527 if (!NILP (matchp)) | |
3528 { | |
3529 /* we found one! */ | |
3530 | |
3531 lw_set_menu (menubar_widget, val); | |
3532 /* yah - yet another hack. | |
3533 pretend emacs timestamp is the same as an X timestamp, | |
3534 which for the moment it is. (read events.h) | |
3535 */ | |
3536 lw_map_menu (XEVENT (event0)->timestamp); | |
3537 | |
3538 if (val->contents) | |
3539 lw_push_menu (val->contents); | |
3540 | |
3541 lw_display_menu (CurrentTime); | |
3542 | |
3543 /* menu accelerator keys don't go into keyboard macros */ | |
3544 if (!NILP (con->defining_kbd_macro) && NILP (Vexecuting_macro)) | |
3545 con->kbd_macro_ptr = con->kbd_macro_end; | |
3546 | |
3547 /* don't echo menu accelerator keys */ | |
3548 /*reset_key_echo (builder, 1);*/ | |
3549 reset_this_command_keys (Vselected_console, 1); | |
3550 UNGCPRO; | |
3551 | |
3552 return Vmenu_accelerator_map; | |
3553 } | |
3554 } | |
3555 | |
3556 val = val->next; | |
3557 } | |
3558 | |
3559 UNGCPRO; | |
3560 } | |
3561 return Qnil; | |
3562 } | |
3563 | |
3564 | |
3565 DEFUN ("accelerate-menu", Faccelerate_menu, 0, 0, "_", /* | |
3566 Make the menubar active. Menu items can be selected using menu accelerators | |
3567 or by actions defined in menu-accelerator-map. | |
3568 */ | |
3569 ()) | |
3570 { | |
3571 struct console *con = XCONSOLE (Vselected_console); | |
3572 struct frame *f = XFRAME (CONSOLE_SELECTED_FRAME (con)); | |
3573 LWLIB_ID id; | |
3574 widget_value *val; | |
3575 | |
3576 if (NILP (f->menubar_data)) | |
3577 error ("Frame has no menubar."); | |
3578 | |
3579 id = XPOPUP_DATA (f->menubar_data)->id; | |
3580 val = lw_get_all_values (id); | |
3581 val = val->contents; | |
3582 lw_set_menu (FRAME_X_MENUBAR_WIDGET (f), val); | |
3583 lw_map_menu (CurrentTime); | |
3584 | |
3585 lw_display_menu (CurrentTime); | |
3586 | |
3587 /* menu accelerator keys don't go into keyboard macros */ | |
3588 if (!NILP (con->defining_kbd_macro) && NILP (Vexecuting_macro)) | |
3589 con->kbd_macro_ptr = con->kbd_macro_end; | |
3590 | |
3591 return Qnil; | |
3592 } | |
3593 #endif /* HAVE_X_WINDOWS && HAVE_MENUBARS */ | |
3594 | |
3595 /* See if we can do function-key-map or key-translation-map translation | 3091 /* See if we can do function-key-map or key-translation-map translation |
3596 on the current events in the command builder. If so, do this, and | 3092 on the current events in the command builder. If so, do this, and |
3597 return the resulting binding, if any. */ | 3093 return the resulting binding, if any. */ |
3598 | 3094 |
3599 static Lisp_Object | 3095 static Lisp_Object |
3711 XEVENT (evee)->event.eval.object); | 3207 XEVENT (evee)->event.eval.object); |
3712 else | 3208 else |
3713 return Qnil; | 3209 return Qnil; |
3714 } | 3210 } |
3715 | 3211 |
3716 /* if we're currently in a menu accelerator, check there for further events */ | 3212 /* if we're currently in a menu accelerator, check there for further |
3213 events */ | |
3214 /* #### fuck me! who wrote this crap? think "abstraction", baby. */ | |
3717 #if defined(HAVE_X_WINDOWS) && defined(LWLIB_MENUBARS_LUCID) | 3215 #if defined(HAVE_X_WINDOWS) && defined(LWLIB_MENUBARS_LUCID) |
3718 if (lw_menu_active) | 3216 if (x_kludge_lw_menu_active ()) |
3719 { | 3217 { |
3720 return command_builder_operate_menu_accelerator (builder); | 3218 return command_builder_operate_menu_accelerator (builder); |
3721 } | 3219 } |
3722 else | 3220 else |
3723 { | 3221 { |
3764 && !NILP (Vretry_undefined_key_binding_unshifted)) | 3262 && !NILP (Vretry_undefined_key_binding_unshifted)) |
3765 { | 3263 { |
3766 Lisp_Object terminal = builder->most_current_event; | 3264 Lisp_Object terminal = builder->most_current_event; |
3767 struct key_data* key = & XEVENT (terminal)->event.key; | 3265 struct key_data* key = & XEVENT (terminal)->event.key; |
3768 Emchar c = 0; | 3266 Emchar c = 0; |
3769 if ((key->modifiers & MOD_SHIFT) | 3267 if ((key->modifiers & XEMACS_MOD_SHIFT) |
3770 || (CHAR_OR_CHAR_INTP (key->keysym) | 3268 || (CHAR_OR_CHAR_INTP (key->keysym) |
3771 && ((c = XCHAR_OR_CHAR_INT (key->keysym)), c >= 'A' && c <= 'Z'))) | 3269 && ((c = XCHAR_OR_CHAR_INT (key->keysym)), c >= 'A' && c <= 'Z'))) |
3772 { | 3270 { |
3773 Lisp_Event terminal_copy = *XEVENT (terminal); | 3271 Lisp_Event terminal_copy = *XEVENT (terminal); |
3774 | 3272 |
3775 if (key->modifiers & MOD_SHIFT) | 3273 if (key->modifiers & XEMACS_MOD_SHIFT) |
3776 key->modifiers &= (~ MOD_SHIFT); | 3274 key->modifiers &= (~ XEMACS_MOD_SHIFT); |
3777 else | 3275 else |
3778 key->keysym = make_char (c + 'a' - 'A'); | 3276 key->keysym = make_char (c + 'a' - 'A'); |
3779 | 3277 |
3780 result = command_builder_find_leaf (builder, allow_misc_user_events_p); | 3278 result = command_builder_find_leaf (builder, allow_misc_user_events_p); |
3781 if (!NILP (result)) | 3279 if (!NILP (result)) |
4172 pushing a new event. | 3670 pushing a new event. |
4173 */ | 3671 */ |
4174 Fcopy_event (event, recent); | 3672 Fcopy_event (event, recent); |
4175 e = XEVENT (recent); | 3673 e = XEVENT (recent); |
4176 if (e->event_type == key_press_event) | 3674 if (e->event_type == key_press_event) |
4177 e->event.key.modifiers |= MOD_META; | 3675 e->event.key.modifiers |= XEMACS_MOD_META; |
4178 else if (e->event_type == button_press_event | 3676 else if (e->event_type == button_press_event |
4179 || e->event_type == button_release_event) | 3677 || e->event_type == button_release_event) |
4180 e->event.button.modifiers |= MOD_META; | 3678 e->event.button.modifiers |= XEMACS_MOD_META; |
4181 else | 3679 else |
4182 abort (); | 3680 abort (); |
4183 | 3681 |
4184 { | 3682 { |
4185 int tckn = event_chain_count (Vthis_command_keys); | 3683 int tckn = event_chain_count (Vthis_command_keys); |
4206 struct gcpro gcpro1; | 3704 struct gcpro gcpro1; |
4207 GCPRO1 (leaf); | 3705 GCPRO1 (leaf); |
4208 | 3706 |
4209 if (KEYMAPP (leaf)) | 3707 if (KEYMAPP (leaf)) |
4210 { | 3708 { |
4211 if (!lw_menu_active) | 3709 #if defined (HAVE_X_WINDOWS) && defined (LWLIB_MENUBARS_LUCID) |
3710 if (!x_kludge_lw_menu_active ()) | |
3711 #else | |
3712 if (1) | |
3713 #endif | |
4212 { | 3714 { |
4213 Lisp_Object prompt = Fkeymap_prompt (leaf, Qt); | 3715 Lisp_Object prompt = Fkeymap_prompt (leaf, Qt); |
4214 if (STRINGP (prompt)) | 3716 if (STRINGP (prompt)) |
4215 { | 3717 { |
4216 /* Append keymap prompt to key echo buffer */ | 3718 /* Append keymap prompt to key echo buffer */ |
4226 maybe_echo_keys (command_builder, 1); | 3728 maybe_echo_keys (command_builder, 1); |
4227 } | 3729 } |
4228 else | 3730 else |
4229 maybe_echo_keys (command_builder, 0); | 3731 maybe_echo_keys (command_builder, 0); |
4230 } | 3732 } |
4231 else if (!NILP (Vquit_flag)) { | 3733 else if (!NILP (Vquit_flag)) |
4232 Lisp_Object quit_event = Fmake_event(Qnil, Qnil); | 3734 { |
4233 Lisp_Event *e = XEVENT (quit_event); | 3735 Lisp_Object quit_event = Fmake_event (Qnil, Qnil); |
4234 /* if quit happened during menu acceleration, pretend we read it */ | 3736 Lisp_Event *e = XEVENT (quit_event); |
4235 struct console *con = XCONSOLE (Fselected_console ()); | 3737 /* if quit happened during menu acceleration, pretend we read it */ |
4236 int ch = CONSOLE_QUIT_CHAR (con); | 3738 struct console *con = XCONSOLE (Fselected_console ()); |
4237 | 3739 int ch = CONSOLE_QUIT_CHAR (con); |
4238 character_to_event (ch, e, con, 1, 1); | 3740 |
4239 e->channel = make_console (con); | 3741 character_to_event (ch, e, con, 1, 1); |
4240 | 3742 e->channel = make_console (con); |
4241 enqueue_command_event (quit_event); | 3743 |
4242 Vquit_flag = Qnil; | 3744 enqueue_command_event (quit_event); |
4243 } | 3745 Vquit_flag = Qnil; |
3746 } | |
4244 } | 3747 } |
4245 else if (!NILP (leaf)) | 3748 else if (!NILP (leaf)) |
4246 { | 3749 { |
4247 if (EQ (Qcommand, echo_area_status (f)) | 3750 if (EQ (Qcommand, echo_area_status (f)) |
4248 && command_builder->echo_buf_index > 0) | 3751 && command_builder->echo_buf_index > 0) |
4357 } | 3860 } |
4358 else | 3861 else |
4359 { | 3862 { |
4360 /* Start a new command next time */ | 3863 /* Start a new command next time */ |
4361 Vlast_command = Vthis_command; | 3864 Vlast_command = Vthis_command; |
3865 Vlast_command_properties = Vthis_command_properties; | |
3866 Vthis_command_properties = Qnil; | |
3867 | |
4362 /* Emacs 18 doesn't unconditionally clear the echoed keystrokes, | 3868 /* Emacs 18 doesn't unconditionally clear the echoed keystrokes, |
4363 so we don't either */ | 3869 so we don't either */ |
4364 reset_this_command_keys (make_console (con), 0); | 3870 reset_this_command_keys (make_console (con), 0); |
4365 } | 3871 } |
4366 } | 3872 } |
4377 XSETBUFFER (last_point_position_buffer, current_buffer); | 3883 XSETBUFFER (last_point_position_buffer, current_buffer); |
4378 /* This function can GC */ | 3884 /* This function can GC */ |
4379 safe_run_hook_trapping_errors | 3885 safe_run_hook_trapping_errors |
4380 ("Error in `pre-command-hook' (setting hook to nil)", | 3886 ("Error in `pre-command-hook' (setting hook to nil)", |
4381 Qpre_command_hook, 1); | 3887 Qpre_command_hook, 1); |
3888 | |
3889 /* This is a kludge, but necessary; see simple.el */ | |
3890 call0 (Qhandle_pre_motion_command); | |
4382 } | 3891 } |
4383 | 3892 |
4384 /* Run the post command hook. */ | 3893 /* Run the post command hook. */ |
4385 | 3894 |
4386 static void | 3895 static void |
4396 we don't want the user to accidentally remove it. | 3905 we don't want the user to accidentally remove it. |
4397 */ | 3906 */ |
4398 | 3907 |
4399 Lisp_Object win = Fselected_window (Qnil); | 3908 Lisp_Object win = Fselected_window (Qnil); |
4400 | 3909 |
4401 #if 0 | |
4402 /* If the last command deleted the frame, `win' might be nil. | 3910 /* If the last command deleted the frame, `win' might be nil. |
4403 It seems safest to do nothing in this case. */ | 3911 It seems safest to do nothing in this case. */ |
3912 /* Note: Someone added the following comment and put #if 0's around | |
3913 this code, not realizing that doing this invites a crash in the | |
3914 line after. */ | |
4404 /* #### This doesn't really fix the problem, | 3915 /* #### This doesn't really fix the problem, |
4405 if delete-frame is called by some hook */ | 3916 if delete-frame is called by some hook */ |
4406 if (NILP (win)) | 3917 if (NILP (win)) |
4407 return; | 3918 return; |
4408 #endif | 3919 |
3920 /* This is a kludge, but necessary; see simple.el */ | |
3921 call0 (Qhandle_post_motion_command); | |
4409 | 3922 |
4410 if (! zmacs_region_stays | 3923 if (! zmacs_region_stays |
4411 && (!MINI_WINDOW_P (XWINDOW (win)) | 3924 && (!MINI_WINDOW_P (XWINDOW (win)) |
4412 || EQ (zmacs_region_buffer (), WINDOW_BUFFER (XWINDOW (win))))) | 3925 || EQ (zmacs_region_buffer (), WINDOW_BUFFER (XWINDOW (win))))) |
4413 zmacs_deactivate_region (); | 3926 zmacs_deactivate_region (); |
4416 | 3929 |
4417 safe_run_hook_trapping_errors | 3930 safe_run_hook_trapping_errors |
4418 ("Error in `post-command-hook' (setting hook to nil)", | 3931 ("Error in `post-command-hook' (setting hook to nil)", |
4419 Qpost_command_hook, 1); | 3932 Qpost_command_hook, 1); |
4420 | 3933 |
4421 #ifdef DEFERRED_ACTION_CRAP | 3934 #if 0 /* FSF Emacs crap */ |
4422 if (!NILP (Vdeferred_action_list)) | 3935 if (!NILP (Vdeferred_action_list)) |
4423 call0 (Vdeferred_action_function); | 3936 call0 (Vdeferred_action_function); |
4424 #endif | 3937 |
4425 | |
4426 #ifdef ILL_CONCEIVED_HOOK | |
4427 if (NILP (Vunread_command_events) | 3938 if (NILP (Vunread_command_events) |
4428 && NILP (Vexecuting_macro) | 3939 && NILP (Vexecuting_macro) |
4429 && !NILP (Vpost_command_idle_hook) | 3940 && !NILP (Vpost_command_idle_hook) |
4430 && !NILP (Fsit_for (make_float ((double) post_command_idle_delay | 3941 && !NILP (Fsit_for (make_float ((double) post_command_idle_delay |
4431 / 1000000), Qnil))) | 3942 / 1000000), Qnil))) |
4432 safe_run_hook_trapping_errors | 3943 safe_run_hook_trapping_errors |
4433 ("Error in `post-command-idle-hook' (setting hook to nil)", | 3944 ("Error in `post-command-idle-hook' (setting hook to nil)", |
4434 Qpost_command_idle_hook, 1); | 3945 Qpost_command_idle_hook, 1); |
4435 #endif | 3946 #endif /* FSF Emacs crap */ |
4436 | 3947 |
4437 #if 0 /* FSFmacs */ | 3948 #if 0 /* FSF Emacs */ |
4438 if (!NILP (current_buffer->mark_active)) | 3949 if (!NILP (current_buffer->mark_active)) |
4439 { | 3950 { |
4440 if (!NILP (Vdeactivate_mark) && !NILP (Vtransient_mark_mode)) | 3951 if (!NILP (Vdeactivate_mark) && !NILP (Vtransient_mark_mode)) |
4441 { | 3952 { |
4442 current_buffer->mark_active = Qnil; | 3953 current_buffer->mark_active = Qnil; |
4444 } | 3955 } |
4445 else if (current_buffer != prev_buffer || | 3956 else if (current_buffer != prev_buffer || |
4446 BUF_MODIFF (current_buffer) != prev_modiff) | 3957 BUF_MODIFF (current_buffer) != prev_modiff) |
4447 run_hook (intern ("activate-mark-hook")); | 3958 run_hook (intern ("activate-mark-hook")); |
4448 } | 3959 } |
4449 #endif /* FSFmacs */ | 3960 #endif /* FSF Emacs */ |
4450 | 3961 |
4451 /* #### Kludge!!! This is necessary to make sure that things | 3962 /* #### Kludge!!! This is necessary to make sure that things |
4452 are properly positioned even if post-command-hook moves point. | 3963 are properly positioned even if post-command-hook moves point. |
4453 #### There should be a cleaner way of handling this. */ | 3964 #### There should be a cleaner way of handling this. */ |
4454 call0 (Qauto_show_make_point_visible); | 3965 call0 (Qauto_show_make_point_visible); |
4933 DEFSUBR (Fadd_timeout); | 4444 DEFSUBR (Fadd_timeout); |
4934 DEFSUBR (Fdisable_timeout); | 4445 DEFSUBR (Fdisable_timeout); |
4935 DEFSUBR (Fadd_async_timeout); | 4446 DEFSUBR (Fadd_async_timeout); |
4936 DEFSUBR (Fdisable_async_timeout); | 4447 DEFSUBR (Fdisable_async_timeout); |
4937 DEFSUBR (Fdispatch_event); | 4448 DEFSUBR (Fdispatch_event); |
4449 DEFSUBR (Fdispatch_non_command_events); | |
4938 DEFSUBR (Fread_key_sequence); | 4450 DEFSUBR (Fread_key_sequence); |
4939 DEFSUBR (Fthis_command_keys); | 4451 DEFSUBR (Fthis_command_keys); |
4940 DEFSUBR (Freset_this_command_lengths); | 4452 DEFSUBR (Freset_this_command_lengths); |
4941 DEFSUBR (Fopen_dribble_file); | 4453 DEFSUBR (Fopen_dribble_file); |
4942 #if defined(HAVE_X_WINDOWS) && defined(LWLIB_MENUBARS_LUCID) | |
4943 DEFSUBR (Faccelerate_menu); | |
4944 #endif | |
4945 | 4454 |
4946 defsymbol (&Qpre_command_hook, "pre-command-hook"); | 4455 defsymbol (&Qpre_command_hook, "pre-command-hook"); |
4947 defsymbol (&Qpost_command_hook, "post-command-hook"); | 4456 defsymbol (&Qpost_command_hook, "post-command-hook"); |
4948 defsymbol (&Qunread_command_events, "unread-command-events"); | 4457 defsymbol (&Qunread_command_events, "unread-command-events"); |
4949 defsymbol (&Qunread_command_event, "unread-command-event"); | 4458 defsymbol (&Qunread_command_event, "unread-command-event"); |
4950 defsymbol (&Qpre_idle_hook, "pre-idle-hook"); | 4459 defsymbol (&Qpre_idle_hook, "pre-idle-hook"); |
4951 #ifdef ILL_CONCEIVED_HOOK | 4460 defsymbol (&Qhandle_pre_motion_command, "handle-pre-motion-command"); |
4461 defsymbol (&Qhandle_post_motion_command, "handle-post-motion-command"); | |
4462 #if 0 /* FSF Emacs crap */ | |
4952 defsymbol (&Qpost_command_idle_hook, "post-command-idle-hook"); | 4463 defsymbol (&Qpost_command_idle_hook, "post-command-idle-hook"); |
4953 #endif | |
4954 #ifdef DEFERRED_ACTION_CRAP | |
4955 defsymbol (&Qdeferred_action_function, "deferred-action-function"); | 4464 defsymbol (&Qdeferred_action_function, "deferred-action-function"); |
4956 #endif | 4465 #endif |
4957 defsymbol (&Qretry_undefined_key_binding_unshifted, | 4466 defsymbol (&Qretry_undefined_key_binding_unshifted, |
4958 "retry-undefined-key-binding-unshifted"); | 4467 "retry-undefined-key-binding-unshifted"); |
4959 defsymbol (&Qauto_show_make_point_visible, | 4468 defsymbol (&Qauto_show_make_point_visible, |
4960 "auto-show-make-point-visible"); | 4469 "auto-show-make-point-visible"); |
4961 | |
4962 defsymbol (&Qmenu_force, "menu-force"); | |
4963 defsymbol (&Qmenu_fallback, "menu-fallback"); | |
4964 | |
4965 defsymbol (&Qmenu_quit, "menu-quit"); | |
4966 defsymbol (&Qmenu_up, "menu-up"); | |
4967 defsymbol (&Qmenu_down, "menu-down"); | |
4968 defsymbol (&Qmenu_left, "menu-left"); | |
4969 defsymbol (&Qmenu_right, "menu-right"); | |
4970 defsymbol (&Qmenu_select, "menu-select"); | |
4971 defsymbol (&Qmenu_escape, "menu-escape"); | |
4972 | 4470 |
4973 defsymbol (&Qself_insert_defer_undo, "self-insert-defer-undo"); | 4471 defsymbol (&Qself_insert_defer_undo, "self-insert-defer-undo"); |
4974 defsymbol (&Qcancel_mode_internal, "cancel-mode-internal"); | 4472 defsymbol (&Qcancel_mode_internal, "cancel-mode-internal"); |
4975 } | 4473 } |
4976 | 4474 |
5061 the keyboard focus. XEmacs cannot in general detect when this mode is | 4559 the keyboard focus. XEmacs cannot in general detect when this mode is |
5062 used by the window manager, so it is up to the user to set it. | 4560 used by the window manager, so it is up to the user to set it. |
5063 */ ); | 4561 */ ); |
5064 focus_follows_mouse = 0; | 4562 focus_follows_mouse = 0; |
5065 | 4563 |
5066 #ifdef ILL_CONCEIVED_HOOK | 4564 #if 0 /* FSF Emacs crap */ |
5067 /* Ill-conceived because it's not run in all sorts of cases | 4565 /* Ill-conceived because it's not run in all sorts of cases |
5068 where XEmacs is blocking. That's what `pre-idle-hook' | 4566 where XEmacs is blocking. That's what `pre-idle-hook' |
5069 is designed to solve. */ | 4567 is designed to solve. */ |
5070 xxDEFVAR_LISP ("post-command-idle-hook", &Vpost_command_idle_hook /* | 4568 xxDEFVAR_LISP ("post-command-idle-hook", &Vpost_command_idle_hook /* |
5071 Normal hook run after each command is executed, if idle. | 4569 Normal hook run after each command is executed, if idle. |
5078 xxDEFVAR_INT ("post-command-idle-delay", &post_command_idle_delay /* | 4576 xxDEFVAR_INT ("post-command-idle-delay", &post_command_idle_delay /* |
5079 Delay time before running `post-command-idle-hook'. | 4577 Delay time before running `post-command-idle-hook'. |
5080 This is measured in microseconds. | 4578 This is measured in microseconds. |
5081 */ ); | 4579 */ ); |
5082 post_command_idle_delay = 5000; | 4580 post_command_idle_delay = 5000; |
5083 #endif /* ILL_CONCEIVED_HOOK */ | 4581 |
5084 | |
5085 #ifdef DEFERRED_ACTION_CRAP | |
5086 /* Random FSFmacs crap. There is absolutely nothing to gain, | 4582 /* Random FSFmacs crap. There is absolutely nothing to gain, |
5087 and a great deal to lose, in using this in place of just | 4583 and a great deal to lose, in using this in place of just |
5088 setting `post-command-hook'. */ | 4584 setting `post-command-hook'. */ |
5089 xxDEFVAR_LISP ("deferred-action-list", &Vdeferred_action_list /* | 4585 xxDEFVAR_LISP ("deferred-action-list", &Vdeferred_action_list /* |
5090 List of deferred actions to be performed at a later time. | 4586 List of deferred actions to be performed at a later time. |
5096 Function to call to handle deferred actions, after each command. | 4592 Function to call to handle deferred actions, after each command. |
5097 This function is called with no arguments after each command | 4593 This function is called with no arguments after each command |
5098 whenever `deferred-action-list' is non-nil. | 4594 whenever `deferred-action-list' is non-nil. |
5099 */ ); | 4595 */ ); |
5100 Vdeferred_action_function = Qnil; | 4596 Vdeferred_action_function = Qnil; |
5101 #endif /* DEFERRED_ACTION_CRAP */ | 4597 #endif /* FSF Emacs crap */ |
5102 | 4598 |
5103 DEFVAR_LISP ("last-command-event", &Vlast_command_event /* | 4599 DEFVAR_LISP ("last-command-event", &Vlast_command_event /* |
5104 Last keyboard or mouse button event that was part of a command. This | 4600 Last keyboard or mouse button event that was part of a command. This |
5105 variable is off limits: you may not set its value or modify the event that | 4601 variable is off limits: you may not set its value or modify the event that |
5106 is its value, as it is destructively modified by `read-key-sequence'. If | 4602 is its value, as it is destructively modified by `read-key-sequence'. If |
5185 The command now being executed. | 4681 The command now being executed. |
5186 The command can set this variable; whatever is put here | 4682 The command can set this variable; whatever is put here |
5187 will be in `last-command' during the following command. | 4683 will be in `last-command' during the following command. |
5188 */ ); | 4684 */ ); |
5189 Vthis_command = Qnil; | 4685 Vthis_command = Qnil; |
4686 | |
4687 DEFVAR_LISP ("last-command-properties", &Vlast_command_properties /* | |
4688 Value of `this-command-properties' for the last command. | |
4689 Used by commands to help synchronize consecutive commands, in preference | |
4690 to looking at `last-command' directly. | |
4691 */ ); | |
4692 Vlast_command_properties = Qnil; | |
4693 | |
4694 DEFVAR_LISP ("this-command-properties", &Vthis_command_properties /* | |
4695 Properties set by the current command. | |
4696 At the beginning of each command, the current value of this variable is | |
4697 copied to `last-command-properties', and then it is set to nil. Use `putf' | |
4698 to add properties to this variable. Commands should use this to communicate | |
4699 with pre/post-command hooks, subsequent commands, wrapping commands, etc. | |
4700 in preference to looking at and/or setting `this-command'. | |
4701 */ ); | |
4702 Vthis_command_properties = Qnil; | |
5190 | 4703 |
5191 DEFVAR_LISP ("help-char", &Vhelp_char /* | 4704 DEFVAR_LISP ("help-char", &Vhelp_char /* |
5192 Character to recognize as meaning Help. | 4705 Character to recognize as meaning Help. |
5193 When it is read, do `(eval help-form)', and display result if it's a string. | 4706 When it is read, do `(eval help-form)', and display result if it's a string. |
5194 If the value of `help-form' is nil, this char can be read normally. | 4707 If the value of `help-form' is nil, this char can be read normally. |
5299 | 4812 |
5300 DEFVAR_BOOL ("inhibit-input-event-recording", &inhibit_input_event_recording /* | 4813 DEFVAR_BOOL ("inhibit-input-event-recording", &inhibit_input_event_recording /* |
5301 Non-nil inhibits recording of input-events to recent-keys ring. | 4814 Non-nil inhibits recording of input-events to recent-keys ring. |
5302 */ ); | 4815 */ ); |
5303 inhibit_input_event_recording = 0; | 4816 inhibit_input_event_recording = 0; |
5304 | |
5305 DEFVAR_LISP("menu-accelerator-prefix", &Vmenu_accelerator_prefix /* | |
5306 Prefix key(s) that must be typed before menu accelerators will be activated. | |
5307 Set this to a value acceptable by define-key. | |
5308 */ ); | |
5309 Vmenu_accelerator_prefix = Qnil; | |
5310 | |
5311 DEFVAR_LISP ("menu-accelerator-modifiers", &Vmenu_accelerator_modifiers /* | |
5312 Modifier keys which must be pressed to get to the top level menu accelerators. | |
5313 This is a list of modifier key symbols. All modifier keys must be held down | |
5314 while a valid menu accelerator key is pressed in order for the top level | |
5315 menu to become active. | |
5316 | |
5317 See also menu-accelerator-enabled and menu-accelerator-prefix. | |
5318 */ ); | |
5319 Vmenu_accelerator_modifiers = list1 (Qmeta); | |
5320 | |
5321 DEFVAR_LISP ("menu-accelerator-enabled", &Vmenu_accelerator_enabled /* | |
5322 Whether menu accelerator keys can cause the menubar to become active. | |
5323 If 'menu-force or 'menu-fallback, then menu accelerator keys can | |
5324 be used to activate the top level menu. Once the menubar becomes active, the | |
5325 accelerator keys can be used regardless of the value of this variable. | |
5326 | |
5327 menu-force is used to indicate that the menu accelerator key takes | |
5328 precedence over bindings in the current keymap(s). menu-fallback means | |
5329 that bindings in the current keymap take precedence over menu accelerator keys. | |
5330 Thus a top level menu with an accelerator of "T" would be activated on a | |
5331 keypress of Meta-t if menu-accelerator-enabled is menu-force. | |
5332 However, if menu-accelerator-enabled is menu-fallback, then | |
5333 Meta-t will not activate the menubar and will instead run the function | |
5334 transpose-words, to which it is normally bound. | |
5335 | |
5336 See also menu-accelerator-modifiers and menu-accelerator-prefix. | |
5337 */ ); | |
5338 Vmenu_accelerator_enabled = Qnil; | |
5339 } | 4817 } |
5340 | 4818 |
5341 void | 4819 void |
5342 complex_vars_of_event_stream (void) | 4820 complex_vars_of_event_stream (void) |
5343 { | 4821 { |
5344 Vkeyboard_translate_table = | 4822 Vkeyboard_translate_table = |
5345 make_lisp_hash_table (100, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ); | 4823 make_lisp_hash_table (100, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ); |
5346 | |
5347 DEFVAR_LISP ("menu-accelerator-map", &Vmenu_accelerator_map /* | |
5348 Keymap for use when the menubar is active. | |
5349 The actions menu-quit, menu-up, menu-down, menu-left, menu-right, | |
5350 menu-select and menu-escape can be mapped to keys in this map. | |
5351 | |
5352 menu-quit Immediately deactivate the menubar and any open submenus without | |
5353 selecting an item. | |
5354 menu-up Move the menu cursor up one row in the current menu. If the | |
5355 move extends past the top of the menu, wrap around to the bottom. | |
5356 menu-down Move the menu cursor down one row in the current menu. If the | |
5357 move extends past the bottom of the menu, wrap around to the top. | |
5358 If executed while the cursor is in the top level menu, move down | |
5359 into the selected menu. | |
5360 menu-left Move the cursor from a submenu into the parent menu. If executed | |
5361 while the cursor is in the top level menu, move the cursor to the | |
5362 left. If the move extends past the left edge of the menu, wrap | |
5363 around to the right edge. | |
5364 menu-right Move the cursor into a submenu. If the cursor is located in the | |
5365 top level menu or is not currently on a submenu heading, then move | |
5366 the cursor to the next top level menu entry. If the move extends | |
5367 past the right edge of the menu, wrap around to the left edge. | |
5368 menu-select Activate the item under the cursor. If the cursor is located on | |
5369 a submenu heading, then move the cursor into the submenu. | |
5370 menu-escape Pop up to the next level of menus. Moves from a submenu into its | |
5371 parent menu. From the top level menu, this deactivates the | |
5372 menubar. | |
5373 | |
5374 This keymap can also contain normal key-command bindings, in which case the | |
5375 menubar is deactivated and the corresponding command is executed. | |
5376 | |
5377 The action bindings used by the menu accelerator code are designed to mimic | |
5378 the actions of menu traversal keys in a commonly used PC operating system. | |
5379 */ ); | |
5380 Vmenu_accelerator_map = Fmake_keymap(Qnil); | |
5381 } | 4824 } |
5382 | 4825 |
5383 void | 4826 void |
5384 init_event_stream (void) | 4827 init_event_stream (void) |
5385 { | 4828 { |