comparison src/keyboard.c @ 1565:a681f63f93fa

* keyboard.c (read_key_sequence): Removed the replay_sequence_new_buffer label; replay_sequence should be here instead. * keyboard.c (Vlast_event_frame): Arrange for this to exist iff MULTI_FRAME is defined. [not MULTI_FRAME] (syms_of_keyboard): Don't DEFVAR Vlast_event_frame. [not MULTI_FRAME] (read_char): Don't try to set Vlast_event_frame. [not MULTI_FRAME] (kbd_buffer_store_event): Don't try to set Vlast_event_frame for quit characters. [not MULTI_FRAME] (kbd_buffer_get_event): Don't try to generate switch-frame events.
author Jim Blandy <jimb@redhat.com>
date Sat, 07 Nov 1992 07:07:16 +0000
parents 8cc7bc81d2aa
children 11cd7c23f538
comparison
equal deleted inserted replaced
1564:b327816041d1 1565:a681f63f93fa
196 /* The command being executed by the command loop. 196 /* The command being executed by the command loop.
197 Commands may set this, and the value set will be copied into last_command 197 Commands may set this, and the value set will be copied into last_command
198 instead of the actual command. */ 198 instead of the actual command. */
199 Lisp_Object this_command; 199 Lisp_Object this_command;
200 200
201 #ifdef MULTI_FRAME
201 /* The frame in which the last input event occurred, or Qmacro if the 202 /* The frame in which the last input event occurred, or Qmacro if the
202 last event came from a macro. 203 last event came from a macro.
203 command_loop_1 will select this frame before running the 204 command_loop_1 will select this frame before running the
204 command bound to an event sequence, and read_key_sequence will 205 command bound to an event sequence, and read_key_sequence will
205 toss the existing prefix if the user starts typing at a 206 toss the existing prefix if the user starts typing at a
206 new frame. 207 new frame. */
207
208 On a non-multi-frame Emacs, this will be either Qmacro or
209 selected_frame. */
210 Lisp_Object Vlast_event_frame; 208 Lisp_Object Vlast_event_frame;
209 #endif
211 210
212 /* The timestamp of the last input event we received from the X server. 211 /* The timestamp of the last input event we received from the X server.
213 X Windows wants this for selection ownership. */ 212 X Windows wants this for selection ownership. */
214 unsigned long last_event_timestamp; 213 unsigned long last_event_timestamp;
215 214
1133 goto reread; 1132 goto reread;
1134 } 1133 }
1135 1134
1136 if (!NILP (Vexecuting_macro)) 1135 if (!NILP (Vexecuting_macro))
1137 { 1136 {
1137 #ifdef MULTI_FRAME
1138 /* We set this to Qmacro; since that's not a frame, nobody will 1138 /* We set this to Qmacro; since that's not a frame, nobody will
1139 try to switch frames on us, and the selected window will 1139 try to switch frames on us, and the selected window will
1140 remain unchanged. 1140 remain unchanged.
1141 1141
1142 Since this event came from a macro, it would be misleading to 1142 Since this event came from a macro, it would be misleading to
1143 leave Vlast_event_frame set to whereever the last real event 1143 leave Vlast_event_frame set to whereever the last real event
1144 came from. Normally, command_loop_1 selects 1144 came from. Normally, command_loop_1 selects
1145 Vlast_event_frame after each command is read, but events read 1145 Vlast_event_frame after each command is read, but events read
1146 from a macro should never cause a new frame to be selected. */ 1146 from a macro should never cause a new frame to be selected. */
1147 Vlast_event_frame = Qmacro; 1147 Vlast_event_frame = Qmacro;
1148 #endif
1148 1149
1149 if (executing_macro_index >= XFASTINT (Flength (Vexecuting_macro))) 1150 if (executing_macro_index >= XFASTINT (Flength (Vexecuting_macro)))
1150 { 1151 {
1151 XSET (c, Lisp_Int, -1); 1152 XSET (c, Lisp_Int, -1);
1152 return c; 1153 return c;
1177 redisplay (); 1178 redisplay ();
1178 1179
1179 if (_setjmp (getcjmp)) 1180 if (_setjmp (getcjmp))
1180 { 1181 {
1181 XSET (c, Lisp_Int, quit_char); 1182 XSET (c, Lisp_Int, quit_char);
1183 #ifdef MULTI_FRAME
1182 XSET (Vlast_event_frame, Lisp_Frame, selected_frame); 1184 XSET (Vlast_event_frame, Lisp_Frame, selected_frame);
1185 #endif
1183 1186
1184 goto non_reread; 1187 goto non_reread;
1185 } 1188 }
1186 1189
1187 /* Message turns off echoing unless more keystrokes turn it on again. */ 1190 /* Message turns off echoing unless more keystrokes turn it on again. */
1490 if (c == quit_char 1493 if (c == quit_char
1491 || ((c == (0200 | quit_char)) && !meta_key)) 1494 || ((c == (0200 | quit_char)) && !meta_key))
1492 { 1495 {
1493 extern SIGTYPE interrupt_signal (); 1496 extern SIGTYPE interrupt_signal ();
1494 1497
1498 #ifdef MULTI_FRAME
1495 /* If this results in a quit_char being returned to Emacs as 1499 /* If this results in a quit_char being returned to Emacs as
1496 input, set last-event-frame properly. If this doesn't 1500 input, set last-event-frame properly. If this doesn't
1497 get returned to Emacs as an event, the next event read 1501 get returned to Emacs as an event, the next event read
1498 will set Vlast_event_frame again, so this is safe to do. */ 1502 will set Vlast_event_frame again, so this is safe to do. */
1499 Vlast_event_frame = FRAME_FOCUS_FRAME (event->frame); 1503 Vlast_event_frame = FRAME_FOCUS_FRAME (event->frame);
1504 #endif
1500 1505
1501 last_event_timestamp = event->timestamp; 1506 last_event_timestamp = event->timestamp;
1502 interrupt_signal (); 1507 interrupt_signal ();
1503 return; 1508 return;
1504 } 1509 }
1592 somewhere. If the event queue is empty, then there must be a 1597 somewhere. If the event queue is empty, then there must be a
1593 mouse movement enabled and available. */ 1598 mouse movement enabled and available. */
1594 if (kbd_fetch_ptr != kbd_store_ptr) 1599 if (kbd_fetch_ptr != kbd_store_ptr)
1595 { 1600 {
1596 struct input_event *event; 1601 struct input_event *event;
1597 Lisp_Object frame;
1598 1602
1599 event = ((kbd_fetch_ptr < kbd_buffer + KBD_BUFFER_SIZE) 1603 event = ((kbd_fetch_ptr < kbd_buffer + KBD_BUFFER_SIZE)
1600 ? kbd_fetch_ptr 1604 ? kbd_fetch_ptr
1601 : kbd_buffer); 1605 : kbd_buffer);
1602 1606
1603 last_event_timestamp = event->timestamp; 1607 last_event_timestamp = event->timestamp;
1604 XSET (frame, Lisp_Frame, XFRAME (FRAME_FOCUS_FRAME (event->frame))); 1608
1605 1609 {
1606 /* If this event is on a different frame, return a switch-frame this 1610 #ifdef MULTI_FRAME
1607 time, and leave the event in the queue for next time. */ 1611 Lisp_Object frame;
1608 if (! EQ (frame, Vlast_event_frame)) 1612
1609 { 1613 /* If this event is on a different frame, return a switch-frame this
1610 Vlast_event_frame = frame; 1614 time, and leave the event in the queue for next time. */
1611 obj = make_lispy_switch_frame (frame); 1615 XSET (frame, Lisp_Frame, XFRAME (FRAME_FOCUS_FRAME (event->frame)));
1612 } 1616 if (! EQ (frame, Vlast_event_frame))
1613 else 1617 {
1614 { 1618 Vlast_event_frame = frame;
1615 obj = make_lispy_event (event); 1619 obj = make_lispy_switch_frame (frame);
1616 if (XTYPE (obj) == Lisp_Int) 1620 }
1617 XSET (obj, Lisp_Int, XINT (obj) & (meta_key ? 0377 : 0177)); 1621 else
1622 #endif
1623 {
1624 obj = make_lispy_event (event);
1625 if (XTYPE (obj) == Lisp_Int)
1626 XSET (obj, Lisp_Int, XINT (obj) & (meta_key ? 0377 : 0177));
1618 1627
1619 /* Wipe out this event, to catch bugs. */ 1628 /* Wipe out this event, to catch bugs. */
1620 event->kind = no_event; 1629 event->kind = no_event;
1621 1630
1622 kbd_fetch_ptr = event + 1; 1631 kbd_fetch_ptr = event + 1;
1623 } 1632 }
1633 }
1624 } 1634 }
1625 else if (do_mouse_tracking && mouse_moved) 1635 else if (do_mouse_tracking && mouse_moved)
1626 { 1636 {
1627 FRAME_PTR frame; 1637 FRAME_PTR frame;
1628 Lisp_Object x, y; 1638 Lisp_Object x, y;
1629 unsigned long time; 1639 unsigned long time;
1630 1640
1631 (*mouse_position_hook) (&frame, &x, &y, &time); 1641 (*mouse_position_hook) (&frame, &x, &y, &time);
1632 1642
1643 #ifdef MULTI_FRAME
1633 /* Decide if we should generate a switch-frame event. Don't generate 1644 /* Decide if we should generate a switch-frame event. Don't generate
1634 switch-frame events for motion outside of all Emacs frames. */ 1645 switch-frame events for motion outside of all Emacs frames. */
1635 if (frame && frame != XFRAME (Vlast_event_frame)) 1646 if (frame && frame != XFRAME (Vlast_event_frame))
1636 { 1647 {
1637 XSET (Vlast_event_frame, Lisp_Frame, frame); 1648 XSET (Vlast_event_frame, Lisp_Frame, frame);
1638 obj = make_lispy_switch_frame (Vlast_event_frame); 1649 obj = make_lispy_switch_frame (Vlast_event_frame);
1639 } 1650 }
1640 else 1651 else
1652 #endif
1641 obj = make_lispy_movement (frame, x, y, time); 1653 obj = make_lispy_movement (frame, x, y, time);
1642 } 1654 }
1643 else 1655 else
1644 /* We were promised by the above while loop that there was 1656 /* We were promised by the above while loop that there was
1645 something for us to read! */ 1657 something for us to read! */
2952 we will need to restore them if we replay a key sequence. */ 2964 we will need to restore them if we replay a key sequence. */
2953 if (INTERACTIVE) 2965 if (INTERACTIVE)
2954 echo_start = echo_length (); 2966 echo_start = echo_length ();
2955 keys_start = this_command_key_count; 2967 keys_start = this_command_key_count;
2956 2968
2957 replay_sequence_new_buffer: 2969 replay_sequence:
2958 /* Build our list of keymaps. 2970 /* Build our list of keymaps.
2959 If the sequence starts with a mouse click, we may need to switch buffers 2971 If we recognize a function key and replace its escape sequence in
2960 and jump back here; that's what replay_sequence_new_buffer is for. */ 2972 keybuf with its symbol, or if the sequence starts with a mouse
2973 click and we need to switch buffers, we jump back here to rebuild
2974 the initial keymaps from the current buffer. */
2961 { 2975 {
2962 Lisp_Object *maps; 2976 Lisp_Object *maps;
2963 2977
2964 nmaps = current_minor_maps (0, &maps) + 2; 2978 nmaps = current_minor_maps (0, &maps) + 2;
2965 if (nmaps > nmaps_allocated) 2979 if (nmaps > nmaps_allocated)
2976 /* Find an accurate initial value for first_binding. */ 2990 /* Find an accurate initial value for first_binding. */
2977 for (first_binding = 0; first_binding < nmaps; first_binding++) 2991 for (first_binding = 0; first_binding < nmaps; first_binding++)
2978 if (! NILP (submaps[first_binding])) 2992 if (! NILP (submaps[first_binding]))
2979 break; 2993 break;
2980 2994
2981 replay_sequence:
2982 /* We jump here when a function key substitution has forced us to 2995 /* We jump here when a function key substitution has forced us to
2983 reprocess the current key sequence. keybuf[0..mock_input] is the 2996 reprocess the current key sequence. keybuf[0..mock_input] is the
2984 sequence we want to reread. */ 2997 sequence we want to reread. */
2985 t = 0; 2998 t = 0;
2986 2999
3087 keybuf[t] = key; 3100 keybuf[t] = key;
3088 mock_input = t + 1; 3101 mock_input = t + 1;
3089 } 3102 }
3090 3103
3091 set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); 3104 set_buffer_internal (XBUFFER (XWINDOW (window)->buffer));
3092 goto replay_sequence_new_buffer; 3105 goto replay_sequence;
3093 } 3106 }
3094 else if (XTYPE (posn) == Lisp_Symbol) 3107 else if (XTYPE (posn) == Lisp_Symbol)
3095 { 3108 {
3096 if (t + 1 >= bufsize) 3109 if (t + 1 >= bufsize)
3097 error ("key sequence too long"); 3110 error ("key sequence too long");
3849 kbd_fetch_ptr = kbd_buffer; 3862 kbd_fetch_ptr = kbd_buffer;
3850 kbd_store_ptr = kbd_buffer; 3863 kbd_store_ptr = kbd_buffer;
3851 do_mouse_tracking = 0; 3864 do_mouse_tracking = 0;
3852 input_pending = 0; 3865 input_pending = 0;
3853 3866
3867 #ifdef MULTI_FRAME
3868 /* This means that we don't get a switch-frame event before the first
3869 character typed. */
3870 XSET (Vlast_event_frame, Lisp_Frame, selected_frame);
3871 #endif
3872
3854 if (!noninteractive) 3873 if (!noninteractive)
3855 { 3874 {
3856 signal (SIGINT, interrupt_signal); 3875 signal (SIGINT, interrupt_signal);
3857 #ifdef HAVE_TERMIO 3876 #ifdef HAVE_TERMIO
3858 /* For systems with SysV TERMIO, C-g is set up for both SIGINT and 3877 /* For systems with SysV TERMIO, C-g is set up for both SIGINT and
4072 4091
4073 DEFVAR_INT ("num-input-keys", &num_input_keys, 4092 DEFVAR_INT ("num-input-keys", &num_input_keys,
4074 "*Number of complete keys read from the keyboard so far."); 4093 "*Number of complete keys read from the keyboard so far.");
4075 num_input_keys = 0; 4094 num_input_keys = 0;
4076 4095
4096 #ifdef MULTI_FRAME
4077 DEFVAR_LISP ("last-event-frame", &Vlast_event_frame, 4097 DEFVAR_LISP ("last-event-frame", &Vlast_event_frame,
4078 "*The frame in which the most recently read event occurred.\n\ 4098 "*The frame in which the most recently read event occurred.\n\
4079 If the last event came from a keyboard macro, this is set to `macro'."); 4099 If the last event came from a keyboard macro, this is set to `macro'.");
4080 Vlast_event_frame = Qnil; 4100 Vlast_event_frame = Qnil;
4101 #endif
4081 4102
4082 DEFVAR_LISP ("help-char", &help_char, 4103 DEFVAR_LISP ("help-char", &help_char,
4083 "Character to recognize as meaning Help.\n\ 4104 "Character to recognize as meaning Help.\n\
4084 When it is read, do `(eval help-form)', and display result if it's a string.\n\ 4105 When it is read, do `(eval help-form)', and display result if it's a string.\n\
4085 If the value of `help-form' is nil, this char can be read normally."); 4106 If the value of `help-form' is nil, this char can be read normally.");