Mercurial > emacs
comparison src/keyboard.c @ 985:952aa214a3d0
* keyboard.c (Fexecute_mouse_event): dyked-out function deleted.
We're not going to use this mouse interface.
(Vmouse_window, Vmouse_event, Vmouse_event_function,
Vmouse_left_hook, Vmap_frame_hook, Vunmap_frame_hook,
Vmouse_motion_handler): Variables deleted; they were to be used by
Fexecute_mouse_event.
(syms_of_keyboard): Same.
(command_loop_1): Remove dyked-out code to support
Fexecute_mouse_event.
(read_char): Same.
* keyboard.c (Vlast_event_frame): Don't define this window if
MULTI_FRAME is not #defined.
(syms_of_keyboard): Same.
(kbd_buffer_store_event): Don't try to work with Vlast_event_frame
if MULTI_FRAME is not #defined.
(kbd_buffer_get_event): Same.
* keyboard.c (Fdiscard_input): Removed dyked-out code from when
unread_command_char's quiescent value was -1, not nil.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Fri, 14 Aug 1992 02:29:49 +0000 |
parents | eb74884fc95a |
children | f1df63f98e5c |
comparison
equal
deleted
inserted
replaced
984:4fda1fce3579 | 985:952aa214a3d0 |
---|---|
178 /* The command being executed by the command loop. | 178 /* The command being executed by the command loop. |
179 Commands may set this, and the value set will be copied into last_command | 179 Commands may set this, and the value set will be copied into last_command |
180 instead of the actual command. */ | 180 instead of the actual command. */ |
181 Lisp_Object this_command; | 181 Lisp_Object this_command; |
182 | 182 |
183 #ifndef HAVE_X11 | 183 #ifdef MULTI_FRAME |
184 /* Window of last mouse click. */ | |
185 extern Lisp_Object Vmouse_window; | |
186 | |
187 /* List containing details of last mouse click. */ | |
188 extern Lisp_Object Vmouse_event; | |
189 #endif /* defined HAVE_X11 */ | |
190 | |
191 /* Hook to call on each mouse event after running its definition. */ | |
192 Lisp_Object Vmouse_event_function; | |
193 | |
194 /* Hook to call when mouse leaves frame. */ | |
195 Lisp_Object Vmouse_left_hook; | |
196 | |
197 /* Hook to call when a frame is mapped. */ | |
198 Lisp_Object Vmap_frame_hook; | |
199 | |
200 /* Hook to call when a frame is unmapped. */ | |
201 Lisp_Object Vunmap_frame_hook; | |
202 | |
203 /* Handler for non-grabbed (no keys depressed) mouse motion. */ | |
204 Lisp_Object Vmouse_motion_handler; | |
205 | |
206 /* The frame in which the last input event occurred. | 184 /* The frame in which the last input event occurred. |
207 command_loop_1 will select this frame before running the | 185 command_loop_1 will select this frame before running the |
208 command bound to an event sequence, and read_key_sequence will | 186 command bound to an event sequence, and read_key_sequence will |
209 toss the existing prefix if the user starts typing at a | 187 toss the existing prefix if the user starts typing at a |
210 new frame. */ | 188 new frame. */ |
211 Lisp_Object Vlast_event_frame; | 189 Lisp_Object Vlast_event_frame; |
190 #endif | |
212 | 191 |
213 /* The timestamp of the last input event we received from the X server. | 192 /* The timestamp of the last input event we received from the X server. |
214 X Windows wants this for selection ownership. */ | 193 X Windows wants this for selection ownership. */ |
215 unsigned long last_event_timestamp; | 194 unsigned long last_event_timestamp; |
216 | 195 |
846 /* Now we have read a key sequence of length I, | 825 /* Now we have read a key sequence of length I, |
847 or else I is 0 and we found end of file. */ | 826 or else I is 0 and we found end of file. */ |
848 | 827 |
849 if (i == 0) /* End of file -- happens only in */ | 828 if (i == 0) /* End of file -- happens only in */ |
850 return Qnil; /* a kbd macro, at the end. */ | 829 return Qnil; /* a kbd macro, at the end. */ |
851 | |
852 #if 0 | |
853 #ifdef HAVE_X_WINDOWS | |
854 if (FRAME_X_P (selected_frame)) | |
855 { | |
856 if (i == -1) /* Mouse event */ | |
857 { | |
858 nonundocount = 0; | |
859 if (NILP (Vprefix_arg) && NILP (Vexecuting_macro) && | |
860 !EQ (minibuf_window, selected_window)) | |
861 Fundo_boundary (); | |
862 | |
863 if (defining_kbd_macro) | |
864 { | |
865 /* Be nice if this worked... */ | |
866 } | |
867 Fexecute_mouse_event (read_key_sequence_cmd); | |
868 no_redisplay = 0; | |
869 goto directly_done; | |
870 } | |
871 | |
872 if (i == -2) /* Lisp Symbol */ | |
873 { | |
874 nonundocount = 0; | |
875 if (NILP (Vprefix_arg) && NILP (Vexecuting_macro) && | |
876 !EQ (minibuf_window, selected_window)) | |
877 Fundo_boundary (); | |
878 | |
879 goto directly_done; | |
880 } | |
881 } | |
882 #endif /* HAVE_X_WINDOWS */ | |
883 #endif | |
884 | 830 |
885 last_command_char = keybuf[i - 1]; | 831 last_command_char = keybuf[i - 1]; |
886 | 832 |
887 cmd = read_key_sequence_cmd; | 833 cmd = read_key_sequence_cmd; |
888 if (!NILP (Vexecuting_macro)) | 834 if (!NILP (Vexecuting_macro)) |
1117 if (!NILP (unread_command_char)) | 1063 if (!NILP (unread_command_char)) |
1118 { | 1064 { |
1119 c = unread_command_char; | 1065 c = unread_command_char; |
1120 unread_command_char = Qnil; | 1066 unread_command_char = Qnil; |
1121 | 1067 |
1122 #if 0 /* We're not handling mouse keys specially anymore. */ | |
1123 if (!EQ (XTYPE (obj), Lisp_Int)) /* Mouse thing */ | |
1124 { | |
1125 num_input_chars++; | |
1126 last_input_char = 0; | |
1127 return obj; | |
1128 } | |
1129 #endif | |
1130 | |
1131 if (this_command_key_count == 0) | 1068 if (this_command_key_count == 0) |
1132 goto reread_first; | 1069 goto reread_first; |
1133 else | 1070 else |
1134 goto reread; | 1071 goto reread; |
1135 } | 1072 } |
1244 c = kbd_buffer_get_event (); | 1181 c = kbd_buffer_get_event (); |
1245 | 1182 |
1246 if (NILP (c)) | 1183 if (NILP (c)) |
1247 abort (); /* Don't think this can happen. */ | 1184 abort (); /* Don't think this can happen. */ |
1248 | 1185 |
1249 #if 0 /* I think that all the different kinds of events should be | |
1250 handled together now... */ | |
1251 if (XTYPE (c) != Lisp_Int) | |
1252 { | |
1253 start_polling (); | |
1254 return c; | |
1255 } | |
1256 c = XINT (obj); | |
1257 #endif | |
1258 | |
1259 /* Terminate Emacs in batch mode if at eof. */ | 1186 /* Terminate Emacs in batch mode if at eof. */ |
1260 if (noninteractive && c < 0) | 1187 if (noninteractive && c < 0) |
1261 Fkill_emacs (make_number (1)); | 1188 Fkill_emacs (make_number (1)); |
1262 | 1189 |
1263 non_reread: | 1190 non_reread: |
1484 register int c = XFASTINT (event->code) & 0377; | 1411 register int c = XFASTINT (event->code) & 0377; |
1485 | 1412 |
1486 if (c == quit_char | 1413 if (c == quit_char |
1487 || ((c == (0200 | quit_char)) && !meta_key)) | 1414 || ((c == (0200 | quit_char)) && !meta_key)) |
1488 { | 1415 { |
1416 extern SIGTYPE interrupt_signal (); | |
1417 | |
1418 #ifdef MULTI_FRAME | |
1489 /* If this results in a quit_char being returned to Emacs as | 1419 /* If this results in a quit_char being returned to Emacs as |
1490 input, set last-event-frame properly. If this doesn't | 1420 input, set last-event-frame properly. If this doesn't |
1491 get returned to Emacs as an event, the next event read | 1421 get returned to Emacs as an event, the next event read |
1492 will set Vlast_event_frame again, so this is safe to do. */ | 1422 will set Vlast_event_frame again, so this is safe to do. */ |
1493 extern SIGTYPE interrupt_signal (); | |
1494 Vlast_event_frame = FRAME_FOCUS_FRAME (event->frame); | 1423 Vlast_event_frame = FRAME_FOCUS_FRAME (event->frame); |
1424 #endif | |
1425 | |
1495 last_event_timestamp = event->timestamp; | 1426 last_event_timestamp = event->timestamp; |
1496 interrupt_signal (); | 1427 interrupt_signal (); |
1497 return; | 1428 return; |
1498 } | 1429 } |
1499 | 1430 |
1612 kbd_fetch_ptr = kbd_buffer; | 1543 kbd_fetch_ptr = kbd_buffer; |
1613 /* Do the redirection specified by the focus_frame | 1544 /* Do the redirection specified by the focus_frame |
1614 member now, before we return this event. */ | 1545 member now, before we return this event. */ |
1615 kbd_fetch_ptr->frame = | 1546 kbd_fetch_ptr->frame = |
1616 XFRAME (FRAME_FOCUS_FRAME (kbd_fetch_ptr->frame)); | 1547 XFRAME (FRAME_FOCUS_FRAME (kbd_fetch_ptr->frame)); |
1548 | |
1549 #ifdef MULTI_FRAME | |
1617 XSET (Vlast_event_frame, Lisp_Frame, kbd_fetch_ptr->frame); | 1550 XSET (Vlast_event_frame, Lisp_Frame, kbd_fetch_ptr->frame); |
1551 #endif | |
1552 | |
1618 last_event_timestamp = kbd_fetch_ptr->timestamp; | 1553 last_event_timestamp = kbd_fetch_ptr->timestamp; |
1619 obj = make_lispy_event (kbd_fetch_ptr); | 1554 obj = make_lispy_event (kbd_fetch_ptr); |
1620 kbd_fetch_ptr->kind = no_event; | 1555 kbd_fetch_ptr->kind = no_event; |
1621 kbd_fetch_ptr++; | 1556 kbd_fetch_ptr++; |
1622 if (XTYPE (obj) == Lisp_Int) | 1557 if (XTYPE (obj) == Lisp_Int) |
1627 FRAME_PTR frame; | 1562 FRAME_PTR frame; |
1628 Lisp_Object x, y; | 1563 Lisp_Object x, y; |
1629 unsigned long time; | 1564 unsigned long time; |
1630 | 1565 |
1631 (*mouse_position_hook) (&frame, &x, &y, &time); | 1566 (*mouse_position_hook) (&frame, &x, &y, &time); |
1567 #ifdef MULTI_FRAME | |
1632 XSET (Vlast_event_frame, Lisp_Frame, frame); | 1568 XSET (Vlast_event_frame, Lisp_Frame, frame); |
1569 #endif | |
1633 | 1570 |
1634 obj = make_lispy_movement (frame, x, y, time); | 1571 obj = make_lispy_movement (frame, x, y, time); |
1635 } | 1572 } |
1636 else | 1573 else |
1637 /* We were promised by the above while loop that there was | 1574 /* We were promised by the above while loop that there was |
2877 return tem; | 2814 return tem; |
2878 } | 2815 } |
2879 return Qnil; | 2816 return Qnil; |
2880 } | 2817 } |
2881 | 2818 |
2882 #if 0 | |
2883 DEFUN ("execute-mouse-event", Fexecute_mouse_event, Sexecute_mouse_event, | |
2884 1, 1, 0, | |
2885 "Execute the definition of the mouse-click event EVENT.\n\ | |
2886 The handler function is found by looking the event's key sequence up\n\ | |
2887 in the buffer's local mouse map and in `global-mouse-map'.\n\ | |
2888 \n\ | |
2889 After running the handler, call the value of `mouse-event-function'\n\ | |
2890 with EVENT as arg.") | |
2891 (event) | |
2892 Lisp_Object event; | |
2893 { | |
2894 Lisp_Object tem; | |
2895 Lisp_Object mouse_cmd; | |
2896 Lisp_Object keyseq, window, frame_part, pos, time; | |
2897 | |
2898 #ifndef HAVE_X11 | |
2899 Vmouse_event = event; | |
2900 #endif | |
2901 | |
2902 if (EQ (event, Qnil)) | |
2903 { | |
2904 bitch_at_user (); | |
2905 return Qnil; | |
2906 } | |
2907 | |
2908 CHECK_CONS (event, 0); | |
2909 pos = Fcar (event); | |
2910 window = Fcar (Fcdr (event)); | |
2911 frame_part = Fcar (Fcdr (Fcdr (event))); | |
2912 keyseq = Fcar (Fcdr (Fcdr (Fcdr (event)))); | |
2913 time = Fcar (Fcdr (Fcdr (Fcdr (Fcdr (event))))); | |
2914 CHECK_STRING (keyseq, 0); | |
2915 CHECK_WINDOW (window, 0); | |
2916 | |
2917 /* Look up KEYSEQ in the buffer's local mouse map, then in global one. */ | |
2918 | |
2919 mouse_cmd = Qnil; | |
2920 | |
2921 if (!NILP (XWINDOW (window)->buffer)) | |
2922 { | |
2923 Lisp_Object local_map; | |
2924 | |
2925 local_map = XBUFFER (XWINDOW (window)->buffer)->mouse_map; | |
2926 tem = Fkeymapp (local_map); | |
2927 if (!NILP (tem)) | |
2928 mouse_cmd = Flookup_key (local_map, keyseq); | |
2929 /* A number as value means the key is too long; treat as undefined. */ | |
2930 if (XTYPE (mouse_cmd) == Lisp_Int) | |
2931 mouse_cmd = Qnil; | |
2932 } | |
2933 | |
2934 tem = Fkeymapp (Vglobal_mouse_map); | |
2935 if (NILP (mouse_cmd) && !NILP (tem)) | |
2936 mouse_cmd = Flookup_key (Vglobal_mouse_map, keyseq); | |
2937 if (XTYPE (mouse_cmd) == Lisp_Int) | |
2938 mouse_cmd = Qnil; | |
2939 | |
2940 if (NILP (mouse_cmd)) | |
2941 { | |
2942 /* This button/shift combination is not defined. | |
2943 If it is a button-down event, ring the bell. */ | |
2944 #ifdef HAVE_X11 | |
2945 if (XSTRING (keyseq)->data[XSTRING (keyseq)->size - 1] & 0x18 == 0) | |
2946 #else | |
2947 if (XSTRING (keyseq)->data[XSTRING (keyseq)->size - 1] & 4 == 0) | |
2948 #endif | |
2949 bitch_at_user (); | |
2950 } | |
2951 else | |
2952 { | |
2953 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (window))); | |
2954 | |
2955 #ifndef HAVE_X11 | |
2956 Vmouse_window = f->selected_window; | |
2957 #endif /* HAVE_X11 */ | |
2958 /* It's defined; call the definition. */ | |
2959 Vprefix_arg = Qnil; | |
2960 if (!NILP (frame_part)) | |
2961 { | |
2962 /* For a scroll-bar click, set the prefix arg | |
2963 to the number of lines down from the top the click was. | |
2964 Many scroll commands want to scroll by this many lines. */ | |
2965 Lisp_Object position; | |
2966 Lisp_Object length; | |
2967 Lisp_Object offset; | |
2968 | |
2969 position = Fcar (pos); | |
2970 length = Fcar (Fcdr (pos)); | |
2971 offset = Fcar (Fcdr (Fcdr (pos))); | |
2972 | |
2973 if (XINT (length) != 0) | |
2974 XSET (Vprefix_arg, Lisp_Int, | |
2975 (FRAME_HEIGHT (f) * (XINT (position) + XINT (offset)) | |
2976 / (XINT (length) + 2 * XINT (offset)))); | |
2977 } | |
2978 Fcommand_execute (mouse_cmd, Qnil); | |
2979 } | |
2980 | |
2981 if (!NILP (Vmouse_event_function)) /* Not `event' so no need for GCPRO */ | |
2982 call1 (Vmouse_event_function, Vmouse_event); | |
2983 return Qnil; | |
2984 } | |
2985 #endif | |
2986 | |
2987 DEFUN ("execute-extended-command", Fexecute_extended_command, Sexecute_extended_command, | 2819 DEFUN ("execute-extended-command", Fexecute_extended_command, Sexecute_extended_command, |
2988 1, 1, "P", | 2820 1, 1, "P", |
2989 "Read function name, then read its arguments and call it.") | 2821 "Read function name, then read its arguments and call it.") |
2990 (prefixarg) | 2822 (prefixarg) |
2991 Lisp_Object prefixarg; | 2823 Lisp_Object prefixarg; |
3147 () | 2979 () |
3148 { | 2980 { |
3149 defining_kbd_macro = 0; | 2981 defining_kbd_macro = 0; |
3150 update_mode_lines++; | 2982 update_mode_lines++; |
3151 | 2983 |
3152 #if 0 | |
3153 unread_command_char = make_number (-1); | |
3154 #endif | |
3155 unread_command_char = Qnil; | 2984 unread_command_char = Qnil; |
3156 | 2985 |
3157 discard_tty_input (); | 2986 discard_tty_input (); |
3158 | 2987 |
3159 kbd_fetch_ptr = kbd_store_ptr; | 2988 kbd_fetch_ptr = kbd_store_ptr; |
3390 sigfree (); | 3219 sigfree (); |
3391 /* Prevent another signal from doing this before we finish. */ | 3220 /* Prevent another signal from doing this before we finish. */ |
3392 clear_waiting_for_input (); | 3221 clear_waiting_for_input (); |
3393 input_pending = 0; | 3222 input_pending = 0; |
3394 | 3223 |
3395 #if 0 | |
3396 unread_command_char = make_number (-1); | |
3397 #endif | |
3398 unread_command_char = Qnil; | 3224 unread_command_char = Qnil; |
3399 | 3225 |
3400 _longjmp (getcjmp, 1); | 3226 _longjmp (getcjmp, 1); |
3401 } | 3227 } |
3402 | 3228 |
3645 | 3471 |
3646 DEFVAR_INT ("num-input-keys", &num_input_keys, | 3472 DEFVAR_INT ("num-input-keys", &num_input_keys, |
3647 "*Number of complete keys read from the keyboard so far."); | 3473 "*Number of complete keys read from the keyboard so far."); |
3648 num_input_keys = 0; | 3474 num_input_keys = 0; |
3649 | 3475 |
3476 #ifdef MULTI_FRAME | |
3650 DEFVAR_LISP ("last-event-frame", &Vlast_event_frame, | 3477 DEFVAR_LISP ("last-event-frame", &Vlast_event_frame, |
3651 "*The frame in which the most recently read event occurred."); | 3478 "*The frame in which the most recently read event occurred."); |
3652 Vlast_event_frame = Qnil; | 3479 Vlast_event_frame = Qnil; |
3480 #endif | |
3653 | 3481 |
3654 DEFVAR_LISP ("help-char", &help_char, | 3482 DEFVAR_LISP ("help-char", &help_char, |
3655 "Character to recognize as meaning Help.\n\ | 3483 "Character to recognize as meaning Help.\n\ |
3656 When it is read, do `(eval help-form)', and display result if it's a string.\n\ | 3484 When it is read, do `(eval help-form)', and display result if it's a string.\n\ |
3657 If the value of `help-form' is nil, this char can be read normally."); | 3485 If the value of `help-form' is nil, this char can be read normally."); |
3672 "String used as translate table for keyboard input, or nil.\n\ | 3500 "String used as translate table for keyboard input, or nil.\n\ |
3673 Each character is looked up in this string and the contents used instead.\n\ | 3501 Each character is looked up in this string and the contents used instead.\n\ |
3674 If string is of length N, character codes N and up are untranslated."); | 3502 If string is of length N, character codes N and up are untranslated."); |
3675 Vkeyboard_translate_table = Qnil; | 3503 Vkeyboard_translate_table = Qnil; |
3676 | 3504 |
3677 #ifdef HAVE_X_WINDOWS | |
3678 DEFVAR_LISP ("mouse-event-function", &Vmouse_event_function, | |
3679 "Function to call for each mouse event, after the event's definition.\n\ | |
3680 Called, if non-nil, with one argument, which is the event-list.\n\ | |
3681 See the variable `mouse-event' for the format of this list."); | |
3682 Vmouse_event_function = Qnil; | |
3683 | |
3684 DEFVAR_LISP ("mouse-left-hook", &Vmouse_left_hook, | |
3685 "Function to call when mouse leaves window. No arguments."); | |
3686 Vmouse_left_hook = Qnil; | |
3687 | |
3688 DEFVAR_LISP ("map-frame-hook", &Vmap_frame_hook, | |
3689 "Function to call when frame is mapped. No arguments."); | |
3690 Vmap_frame_hook = Qnil; | |
3691 | |
3692 DEFVAR_LISP ("unmap-frame-hook", &Vunmap_frame_hook, | |
3693 "Function to call when frame is unmapped. No arguments."); | |
3694 Vunmap_frame_hook = Qnil; | |
3695 | |
3696 DEFVAR_LISP ("mouse-motion-handler", &Vmouse_motion_handler, | |
3697 "Handler for motion events. No arguments."); | |
3698 Vmouse_motion_handler = Qnil; | |
3699 #endif | |
3700 | |
3701 DEFVAR_BOOL ("menu-prompting", &menu_prompting, | 3505 DEFVAR_BOOL ("menu-prompting", &menu_prompting, |
3702 "Non-nil means prompt with menus in echo area when appropriate.\n\ | 3506 "Non-nil means prompt with menus in echo area when appropriate.\n\ |
3703 This is done when reading from a keymap that has a prompt string,\n\ | 3507 This is done when reading from a keymap that has a prompt string,\n\ |
3704 for elements that have prompt strings."); | 3508 for elements that have prompt strings."); |
3705 menu_prompting = 1; | 3509 menu_prompting = 1; |