comparison src/event-stream.c @ 380:8626e4521993 r21-2-5

Import from CVS: tag r21-2-5
author cvs
date Mon, 13 Aug 2007 11:07:10 +0200
parents cc15677e0335
children aabb7f5b1c81
comparison
equal deleted inserted replaced
379:76b7d63099ad 380:8626e4521993
45 The command builder should deal only with key and button events. 45 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 46 Other command events should be able to come in the MIDDLE of a key
47 sequence, without disturbing the key sequence composition, or the 47 sequence, without disturbing the key sequence composition, or the
48 command builder structure representing it. 48 command builder structure representing it.
49 49
50 Someone should rethink univeral-argument and figure out how an 50 Someone should rethink universal-argument and figure out how an
51 arbitrary command can influence the next command (universal-argument 51 arbitrary command can influence the next command (universal-argument
52 or univeral-coding-system-argument) or the next key (hyperify). 52 or universal-coding-system-argument) or the next key (hyperify).
53 53
54 Both C-h and Help in the middle of a key sequence should trigger 54 Both C-h and Help in the middle of a key sequence should trigger
55 prefix-help-command. help-char is stupid. Maybe we need 55 prefix-help-command. help-char is stupid. Maybe we need
56 keymap-of-last-resort? 56 keymap-of-last-resort?
57 57
247 Lisp_Object Vmenu_accelerator_modifiers; 247 Lisp_Object Vmenu_accelerator_modifiers;
248 248
249 /* whether menu accelerators are enabled */ 249 /* whether menu accelerators are enabled */
250 Lisp_Object Vmenu_accelerator_enabled; 250 Lisp_Object Vmenu_accelerator_enabled;
251 251
252 /* keymap for auxillary menu accelerator functions */ 252 /* keymap for auxiliary menu accelerator functions */
253 Lisp_Object Vmenu_accelerator_map; 253 Lisp_Object Vmenu_accelerator_map;
254 254
255 Lisp_Object Qmenu_force; 255 Lisp_Object Qmenu_force;
256 Lisp_Object Qmenu_fallback; 256 Lisp_Object Qmenu_fallback;
257 Lisp_Object Qmenu_quit; 257 Lisp_Object Qmenu_quit;
390 390
391 static Lisp_Object 391 static Lisp_Object
392 mark_command_builder (Lisp_Object obj, void (*markobj) (Lisp_Object)) 392 mark_command_builder (Lisp_Object obj, void (*markobj) (Lisp_Object))
393 { 393 {
394 struct command_builder *builder = XCOMMAND_BUILDER (obj); 394 struct command_builder *builder = XCOMMAND_BUILDER (obj);
395 (markobj) (builder->prefix_events); 395 markobj (builder->prefix_events);
396 (markobj) (builder->current_events); 396 markobj (builder->current_events);
397 (markobj) (builder->most_current_event); 397 markobj (builder->most_current_event);
398 (markobj) (builder->last_non_munged_event); 398 markobj (builder->last_non_munged_event);
399 (markobj) (builder->munge_me[0].first_mungeable_event); 399 markobj (builder->munge_me[0].first_mungeable_event);
400 (markobj) (builder->munge_me[1].first_mungeable_event); 400 markobj (builder->munge_me[1].first_mungeable_event);
401 return builder->console; 401 return builder->console;
402 } 402 }
403 403
404 static void 404 static void
405 finalize_command_builder (void *header, int for_disksave) 405 finalize_command_builder (void *header, int for_disksave)
779 Emchar c; 779 Emchar c;
780 int did_translate = 0; 780 int did_translate = 0;
781 781
782 if (XEVENT_TYPE (event) != key_press_event) 782 if (XEVENT_TYPE (event) != key_press_event)
783 return; 783 return;
784 if (!HASHTABLEP (Vkeyboard_translate_table)) 784 if (!HASH_TABLEP (Vkeyboard_translate_table))
785 return; 785 return;
786 if (EQ (Fhashtable_fullness (Vkeyboard_translate_table), Qzero)) 786 if (EQ (Fhash_table_count (Vkeyboard_translate_table), Qzero))
787 return; 787 return;
788 788
789 c = event_to_character (XEVENT (event), 0, 0, 0); 789 c = event_to_character (XEVENT (event), 0, 0, 0);
790 if (c != -1) 790 if (c != -1)
791 { 791 {
894 Fcurrent_window_configuration (Qnil)); 894 Fcurrent_window_configuration (Qnil));
895 reset_key_echo (command_builder, 1); 895 reset_key_echo (command_builder, 1);
896 896
897 help = Feval (Vhelp_form); 897 help = Feval (Vhelp_form);
898 if (STRINGP (help)) 898 if (STRINGP (help))
899 internal_with_output_to_temp_buffer ("*Help*", 899 internal_with_output_to_temp_buffer (build_string ("*Help*"),
900 print_help, help, Qnil); 900 print_help, help, Qnil);
901 Fnext_command_event (event, Qnil); 901 Fnext_command_event (event, Qnil);
902 /* Remove the help from the frame */ 902 /* Remove the help from the frame */
903 unbind_to (speccount, Qnil); 903 unbind_to (speccount, Qnil);
904 /* Hmmmm. Tricky. The unbind restores an old window configuration, 904 /* Hmmmm. Tricky. The unbind restores an old window configuration,
1127 1127
1128 static Lisp_Object 1128 static Lisp_Object
1129 mark_timeout (Lisp_Object obj, void (*markobj) (Lisp_Object)) 1129 mark_timeout (Lisp_Object obj, void (*markobj) (Lisp_Object))
1130 { 1130 {
1131 struct timeout *tm = (struct timeout *) XOPAQUE_DATA (obj); 1131 struct timeout *tm = (struct timeout *) XOPAQUE_DATA (obj);
1132 (markobj) (tm->function); 1132 markobj (tm->function);
1133 return tm->object; 1133 return tm->object;
1134 } 1134 }
1135 1135
1136 /* Generate a timeout and return its ID. */ 1136 /* Generate a timeout and return its ID. */
1137 1137
1811 /* #### Do we really want to check OUGHT ?? 1811 /* #### Do we really want to check OUGHT ??
1812 * It seems to make sense, though I have never seen us 1812 * It seems to make sense, though I have never seen us
1813 * get here and have it be non-nil. 1813 * get here and have it be non-nil.
1814 */ 1814 */
1815 if (FRAMEP (DEVICE_FRAME_THAT_OUGHT_TO_HAVE_FOCUS (d))) 1815 if (FRAMEP (DEVICE_FRAME_THAT_OUGHT_TO_HAVE_FOCUS (d)))
1816 old_frame = DEVICE_FRAME_THAT_OUGHT_TO_HAVE_FOCUS (d); 1816 old_frame = DEVICE_FRAME_THAT_OUGHT_TO_HAVE_FOCUS (d);
1817 else if (FRAMEP (DEVICE_FRAME_WITH_FOCUS_FOR_HOOKS (d))) 1817 else if (FRAMEP (DEVICE_FRAME_WITH_FOCUS_FOR_HOOKS (d)))
1818 old_frame = DEVICE_FRAME_WITH_FOCUS_FOR_HOOKS (d); 1818 old_frame = DEVICE_FRAME_WITH_FOCUS_FOR_HOOKS (d);
1819 1819
1820 /* #### Can old_frame ever be NIL? play it safe.. */ 1820 /* #### Can old_frame ever be NIL? play it safe.. */
1821 if (!NILP (old_frame)) 1821 if (!NILP (old_frame))
2322 XCAR (XCDR (Vlast_command_event_time)) = 2322 XCAR (XCDR (Vlast_command_event_time)) =
2323 make_int ((EMACS_SECS (t) >> 0) & 0xffff); 2323 make_int ((EMACS_SECS (t) >> 0) & 0xffff);
2324 XCAR (XCDR (XCDR (Vlast_command_event_time))) 2324 XCAR (XCDR (XCDR (Vlast_command_event_time)))
2325 = make_int (EMACS_USECS (t)); 2325 = make_int (EMACS_USECS (t));
2326 } 2326 }
2327
2328 /* If this key came from the keyboard or from a keyboard macro, then 2327 /* If this key came from the keyboard or from a keyboard macro, then
2329 it goes into the recent-keys and this-command-keys vectors. 2328 it goes into the recent-keys and this-command-keys vectors.
2330 If this key came from the keyboard, and we're defining a keyboard 2329 If this key came from the keyboard, and we're defining a keyboard
2331 macro, then it goes into the macro. 2330 macro, then it goes into the macro.
2332 */ 2331 */
2368 echo area while this function is waiting for an event. 2367 echo area while this function is waiting for an event.
2369 2368
2370 The event returned will be a keyboard, mouse press, or mouse release event. 2369 The event returned will be a keyboard, mouse press, or mouse release event.
2371 If there are non-command events available (mouse motion, sub-process output, 2370 If there are non-command events available (mouse motion, sub-process output,
2372 etc) then these will be executed (with `dispatch-event') and discarded. This 2371 etc) then these will be executed (with `dispatch-event') and discarded. This
2373 function is provided as a convenience; it is rougly equivalent to the lisp code 2372 function is provided as a convenience; it is roughly equivalent to the lisp code
2374 2373
2375 (while (progn 2374 (while (progn
2376 (next-event event prompt) 2375 (next-event event prompt)
2377 (not (or (key-press-event-p event) 2376 (not (or (key-press-event-p event)
2378 (button-press-event-p event) 2377 (button-press-event-p event)
2508 cause it to return immediately. 2507 cause it to return immediately.
2509 2508
2510 All of these routines install timeouts, so we clear the installed 2509 All of these routines install timeouts, so we clear the installed
2511 timeout as well. 2510 timeout as well.
2512 2511
2513 Note: It's very easy to break the desired behaviours of these 2512 Note: It's very easy to break the desired behaviors of these
2514 3 routines. If you make any changes to anything in this area, run 2513 3 routines. If you make any changes to anything in this area, run
2515 the regression tests at the bottom of the file. -- dmoore */ 2514 the regression tests at the bottom of the file. -- dmoore */
2516 2515
2517 2516
2518 static Lisp_Object 2517 static Lisp_Object
2772 /* If we're in a macro, or noninteractive, or early in temacs, then 2771 /* If we're in a macro, or noninteractive, or early in temacs, then
2773 don't wait. */ 2772 don't wait. */
2774 if (noninteractive || !NILP (Vexecuting_macro)) 2773 if (noninteractive || !NILP (Vexecuting_macro))
2775 return Qnil; 2774 return Qnil;
2776 2775
2777 /* Recusive call from a filter function or timeout handler. */ 2776 /* Recursive call from a filter function or timeout handler. */
2778 if (!NILP(recursive_sit_for)) 2777 if (!NILP(recursive_sit_for))
2779 { 2778 {
2780 if (!event_stream_event_pending_p (1) && NILP (nodisplay)) 2779 if (!event_stream_event_pending_p (1) && NILP (nodisplay))
2781 { 2780 {
2782 run_pre_idle_hook (); 2781 run_pre_idle_hook ();
4000 } 3999 }
4001 4000
4002 /* Vthis_command_keys having value Qnil means that the next time 4001 /* Vthis_command_keys having value Qnil means that the next time
4003 push_this_command_keys is called, it should start over. 4002 push_this_command_keys is called, it should start over.
4004 The times at which the command-keys are reset 4003 The times at which the command-keys are reset
4005 (instead of merely being augmented) are pretty conterintuitive. 4004 (instead of merely being augmented) are pretty counterintuitive.
4006 (More specifically: 4005 (More specifically:
4007 4006
4008 -- We do not reset this-command-keys when we finish reading a 4007 -- We do not reset this-command-keys when we finish reading a
4009 command. This is because some commands (e.g. C-u) act 4008 command. This is because some commands (e.g. C-u) act
4010 like command prefixes; they signal this by setting prefix-arg 4009 like command prefixes; they signal this by setting prefix-arg
4351 #if 0 /* #### here was an attempted fix that didn't work */ 4350 #if 0 /* #### here was an attempted fix that didn't work */
4352 if (XEVENT (event)->event_type == misc_user_event) 4351 if (XEVENT (event)->event_type == misc_user_event)
4353 ; 4352 ;
4354 else 4353 else
4355 #endif 4354 #endif
4356 if (!NILP (con->prefix_arg)) 4355 if (!NILP (con->prefix_arg))
4357 { 4356 {
4358 /* Commands that set the prefix arg don't update last-command, don't 4357 /* Commands that set the prefix arg don't update last-command, don't
4359 reset the echoing state, and don't go into keyboard macros unless 4358 reset the echoing state, and don't go into keyboard macros unless
4360 followed by another command. */ 4359 followed by another command. */
4361 maybe_echo_keys (command_builder, 0); 4360 maybe_echo_keys (command_builder, 0);
4967 } 4966 }
4968 4967
4969 void 4968 void
4970 vars_of_event_stream (void) 4969 vars_of_event_stream (void)
4971 { 4970 {
4972 #ifdef HAVE_X_WINDOWS
4973 vars_of_event_Xt ();
4974 #endif
4975 #if defined(HAVE_TTY) && (defined (DEBUG_TTY_EVENT_STREAM) || !defined (HAVE_X_WINDOWS))
4976 vars_of_event_tty ();
4977 #endif
4978 #ifdef HAVE_MS_WINDOWS
4979 vars_of_event_mswindows ();
4980 #endif
4981
4982 recent_keys_ring_index = 0; 4971 recent_keys_ring_index = 0;
4983 recent_keys_ring_size = 100; 4972 recent_keys_ring_size = 100;
4984 Vrecent_keys_ring = Qnil; 4973 Vrecent_keys_ring = Qnil;
4985 staticpro (&Vrecent_keys_ring); 4974 staticpro (&Vrecent_keys_ring);
4986 4975
5338 } 5327 }
5339 5328
5340 void 5329 void
5341 complex_vars_of_event_stream (void) 5330 complex_vars_of_event_stream (void)
5342 { 5331 {
5343 Vkeyboard_translate_table = Fmake_hashtable (make_int (100), Qnil); 5332 Vkeyboard_translate_table =
5333 make_lisp_hash_table (100, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ);
5344 5334
5345 DEFVAR_LISP ("menu-accelerator-map", &Vmenu_accelerator_map /* 5335 DEFVAR_LISP ("menu-accelerator-map", &Vmenu_accelerator_map /*
5346 Keymap for use when the menubar is active. 5336 Keymap for use when the menubar is active.
5347 The actions menu-quit, menu-up, menu-down, menu-left, menu-right, 5337 The actions menu-quit, menu-up, menu-down, menu-left, menu-right,
5348 menu-select and menu-escape can be mapped to keys in this map. 5338 menu-select and menu-escape can be mapped to keys in this map.
5462 (tst)^Ja^G ==> ((quit) 97) with no signal 5452 (tst)^Ja^G ==> ((quit) 97) with no signal
5463 (tst)^J^Ga ==> ((quit) 97) with no signal 5453 (tst)^J^Ga ==> ((quit) 97) with no signal
5464 (tst)^Jabc^G ==> ((quit) 97) with no signal, and "bc" inserted in buffer 5454 (tst)^Jabc^G ==> ((quit) 97) with no signal, and "bc" inserted in buffer
5465 5455
5466 ; with sit-for only do the 2nd test. 5456 ; with sit-for only do the 2nd test.
5467 ; Do all 3 tests with (accept-proccess-output nil 20) 5457 ; Do all 3 tests with (accept-process-output nil 20)
5468 5458
5469 Do this: 5459 Do this:
5470 (setq enable-recursive-minibuffers t 5460 (setq enable-recursive-minibuffers t
5471 minibuffer-max-depth nil) 5461 minibuffer-max-depth nil)
5472 ESC ESC ESC ESC - there are now two minibuffers active 5462 ESC ESC ESC ESC - there are now two minibuffers active