comparison src/keyboard.c @ 12800:1086fa1dfb89

(read_key_sequence): Undo previous change. Instead, put back the orig_uppercase event if key is not defined. When downcasing, back up one step in key-translation processing.
author Richard M. Stallman <rms@gnu.org>
date Tue, 08 Aug 1995 05:12:31 +0000
parents dd9049c5c51d
children cb9fe3733db5
comparison
equal deleted inserted replaced
12799:a252e42dabcc 12800:1086fa1dfb89
2423 { 2423 {
2424 sys_suspend (); 2424 sys_suspend ();
2425 return; 2425 return;
2426 } 2426 }
2427 } 2427 }
2428 /* Don't insert two buffer_switch_event's in a row.
2429 Just ignore the second one. */
2430 else if (event->kind == buffer_switch_event
2431 && kbd_fetch_ptr != kbd_store_ptr
2432 && kbd_store_ptr->kind == buffer_switch_event)
2433 return;
2428 2434
2429 if (kbd_store_ptr - kbd_buffer == KBD_BUFFER_SIZE) 2435 if (kbd_store_ptr - kbd_buffer == KBD_BUFFER_SIZE)
2430 kbd_store_ptr = kbd_buffer; 2436 kbd_store_ptr = kbd_buffer;
2431 2437
2432 /* Don't let the very last slot in the buffer become full, 2438 /* Don't let the very last slot in the buffer become full,
5189 /* Nonzero if we seem to have got the beginning of a binding 5195 /* Nonzero if we seem to have got the beginning of a binding
5190 in function_key_map. */ 5196 in function_key_map. */
5191 int function_key_possible = 0; 5197 int function_key_possible = 0;
5192 int key_translation_possible = 0; 5198 int key_translation_possible = 0;
5193 5199
5200 /* Save the status of key translation before each step,
5201 so that we can restore this after downcasing. */
5202 Lisp_Object prev_fkey_map;
5203 Lisp_Object prev_fkey_start;
5204 Lisp_Object prev_fkey_end;
5205
5206 Lisp_Object prev_keytran_map;
5207 Lisp_Object prev_keytran_start;
5208 Lisp_Object prev_keytran_end;
5209
5194 int junk; 5210 int junk;
5195 5211
5196 last_nonmenu_event = Qnil; 5212 last_nonmenu_event = Qnil;
5197 5213
5198 delayed_switch_frame = Qnil; 5214 delayed_switch_frame = Qnil;
5333 echo_local_start and keys_local_start allow us to throw away 5349 echo_local_start and keys_local_start allow us to throw away
5334 just one key. */ 5350 just one key. */
5335 int echo_local_start, keys_local_start, local_first_binding; 5351 int echo_local_start, keys_local_start, local_first_binding;
5336 5352
5337 if (t >= bufsize) 5353 if (t >= bufsize)
5338 error ("key sequence too long"); 5354 error ("Key sequence too long");
5339 5355
5340 if (INTERACTIVE) 5356 if (INTERACTIVE)
5341 echo_local_start = echo_length (); 5357 echo_local_start = echo_length ();
5342 keys_local_start = this_command_key_count; 5358 keys_local_start = this_command_key_count;
5343 local_first_binding = first_binding; 5359 local_first_binding = first_binding;
5542 /* Expand mode-line and scroll-bar events into two events: 5558 /* Expand mode-line and scroll-bar events into two events:
5543 use posn as a fake prefix key. */ 5559 use posn as a fake prefix key. */
5544 if (SYMBOLP (posn)) 5560 if (SYMBOLP (posn))
5545 { 5561 {
5546 if (t + 1 >= bufsize) 5562 if (t + 1 >= bufsize)
5547 error ("key sequence too long"); 5563 error ("Key sequence too long");
5548 keybuf[t] = posn; 5564 keybuf[t] = posn;
5549 keybuf[t+1] = key; 5565 keybuf[t+1] = key;
5550 mock_input = t + 2; 5566 mock_input = t + 2;
5551 5567
5552 /* Zap the position in key, so we know that we've 5568 /* Zap the position in key, so we know that we've
5577 /* Handle menu-bar events: 5593 /* Handle menu-bar events:
5578 insert the dummy prefix event `menu-bar'. */ 5594 insert the dummy prefix event `menu-bar'. */
5579 if (EQ (posn, Qmenu_bar)) 5595 if (EQ (posn, Qmenu_bar))
5580 { 5596 {
5581 if (t + 1 >= bufsize) 5597 if (t + 1 >= bufsize)
5582 error ("key sequence too long"); 5598 error ("Key sequence too long");
5583 keybuf[t] = posn; 5599 keybuf[t] = posn;
5584 keybuf[t+1] = key; 5600 keybuf[t+1] = key;
5585 5601
5586 /* Zap the position in key, so we know that we've 5602 /* Zap the position in key, so we know that we've
5587 expanded it, and don't try to do so again. */ 5603 expanded it, and don't try to do so again. */
5736 we don't update last_nonmenu_event; it continues to hold the mouse 5752 we don't update last_nonmenu_event; it continues to hold the mouse
5737 event that preceded the first level of menu. */ 5753 event that preceded the first level of menu. */
5738 if (!used_mouse_menu) 5754 if (!used_mouse_menu)
5739 last_nonmenu_event = key; 5755 last_nonmenu_event = key;
5740 5756
5757 prev_fkey_map = fkey_map;
5758 prev_fkey_start = fkey_start;
5759 prev_fkey_end = fkey_end;
5760
5761 prev_keytran_map = keytran_map;
5762 prev_keytran_start = keytran_start;
5763 prev_keytran_end = keytran_end;
5764
5741 /* If the sequence is unbound, see if we can hang a function key 5765 /* If the sequence is unbound, see if we can hang a function key
5742 off the end of it. We only want to scan real keyboard input 5766 off the end of it. We only want to scan real keyboard input
5743 for function key sequences, so if mock_input says that we're 5767 for function key sequences, so if mock_input says that we're
5744 re-reading old events, don't examine it. */ 5768 re-reading old events, don't examine it. */
5745 if (first_binding >= nmaps 5769 if (first_binding >= nmaps
5812 { 5836 {
5813 int len = XFASTINT (Flength (fkey_next)); 5837 int len = XFASTINT (Flength (fkey_next));
5814 5838
5815 t = fkey_start + len; 5839 t = fkey_start + len;
5816 if (t >= bufsize) 5840 if (t >= bufsize)
5817 error ("key sequence too long"); 5841 error ("Key sequence too long");
5818 5842
5819 if (VECTORP (fkey_next)) 5843 if (VECTORP (fkey_next))
5820 bcopy (XVECTOR (fkey_next)->contents, 5844 bcopy (XVECTOR (fkey_next)->contents,
5821 keybuf + fkey_start, 5845 keybuf + fkey_start,
5822 (t - fkey_start) * sizeof (keybuf[0])); 5846 (t - fkey_start) * sizeof (keybuf[0]));
5912 { 5936 {
5913 int len = XFASTINT (Flength (keytran_next)); 5937 int len = XFASTINT (Flength (keytran_next));
5914 5938
5915 t = keytran_start + len; 5939 t = keytran_start + len;
5916 if (t >= bufsize) 5940 if (t >= bufsize)
5917 error ("key sequence too long"); 5941 error ("Key sequence too long");
5918 5942
5919 if (VECTORP (keytran_next)) 5943 if (VECTORP (keytran_next))
5920 bcopy (XVECTOR (keytran_next)->contents, 5944 bcopy (XVECTOR (keytran_next)->contents,
5921 keybuf + keytran_start, 5945 keybuf + keytran_start,
5922 (t - keytran_start) * sizeof (keybuf[0])); 5946 (t - keytran_start) * sizeof (keybuf[0]));
5965 < XSTRING (current_buffer->downcase_table)->size) 5989 < XSTRING (current_buffer->downcase_table)->size)
5966 && UPPERCASEP (XINT (key) & 0x3ffff)) 5990 && UPPERCASEP (XINT (key) & 0x3ffff))
5967 || (XINT (key) & shift_modifier))) 5991 || (XINT (key) & shift_modifier)))
5968 { 5992 {
5969 Lisp_Object new_key; 5993 Lisp_Object new_key;
5970 int new_first_binding;
5971 5994
5972 original_uppercase = key; 5995 original_uppercase = key;
5973 original_uppercase_position = t - 1; 5996 original_uppercase_position = t - 1;
5974 5997
5975 if (XINT (new_key) & shift_modifier) 5998 if (XINT (new_key) & shift_modifier)
5976 XSETINT (new_key, XINT (key) & ~shift_modifier); 5999 XSETINT (new_key, XINT (key) & ~shift_modifier);
5977 else 6000 else
5978 XSETINT (new_key, (DOWNCASE (XINT (key) & 0x3ffff) 6001 XSETINT (new_key, (DOWNCASE (XINT (key) & 0x3ffff)
5979 | (XINT (key) & ~0x3ffff))); 6002 | (XINT (key) & ~0x3ffff)));
5980 6003
5981 /* See if new_key has a binding. 6004 /* We have to do this unconditionally, regardless of whether
5982 If it does not have one, this does not alter SUBMAPS. */ 6005 the lower-case char is defined in the keymaps, because they
5983 new_first_binding 6006 might get translated through function-key-map. */
5984 = (follow_key (new_key, 6007 keybuf[t - 1] = new_key;
5985 nmaps - local_first_binding, 6008 mock_input = t;
5986 submaps + local_first_binding, 6009
5987 defs + local_first_binding, 6010 fkey_map = prev_fkey_map;
5988 submaps + local_first_binding) 6011 fkey_start = prev_fkey_start;
5989 + local_first_binding); 6012 fkey_end = prev_fkey_end;
5990 6013
5991 /* If that lower-case char is bound, use it instead. */ 6014 keytran_map = prev_keytran_map;
5992 if (new_first_binding < nmaps) 6015 keytran_start = prev_keytran_start;
5993 { 6016 keytran_end = prev_keytran_end;
5994 keybuf[t - 1] = new_key; 6017
5995 mock_input = t; 6018 goto replay_sequence;
5996 goto replay_sequence;
5997 }
5998 } 6019 }
5999 /* If KEY is not defined in any of the keymaps, 6020 /* If KEY is not defined in any of the keymaps,
6000 and cannot be part of a function key or translation, 6021 and cannot be part of a function key or translation,
6001 and is a shifted function key, 6022 and is a shifted function key,
6002 use the corresponding unshifted function key instead. */ 6023 use the corresponding unshifted function key instead. */
6005 && SYMBOLP (key)) 6026 && SYMBOLP (key))
6006 { 6027 {
6007 Lisp_Object breakdown; 6028 Lisp_Object breakdown;
6008 int modifiers; 6029 int modifiers;
6009 6030
6010 original_uppercase = key;
6011 original_uppercase_position = t - 1;
6012
6013 breakdown = parse_modifiers (key); 6031 breakdown = parse_modifiers (key);
6014 modifiers = XINT (XCONS (XCONS (breakdown)->cdr)->car); 6032 modifiers = XINT (XCONS (XCONS (breakdown)->cdr)->car);
6015 if (modifiers & shift_modifier) 6033 if (modifiers & shift_modifier)
6016 { 6034 {
6017 Lisp_Object new_key; 6035 Lisp_Object new_key;
6018 int new_first_binding; 6036
6037 original_uppercase = key;
6038 original_uppercase_position = t - 1;
6019 6039
6020 modifiers &= ~shift_modifier; 6040 modifiers &= ~shift_modifier;
6021 new_key = apply_modifiers (modifiers, 6041 new_key = apply_modifiers (modifiers,
6022 XCONS (breakdown)->car); 6042 XCONS (breakdown)->car);
6023 6043
6024 /* See if new_key has a binding. 6044 keybuf[t - 1] = new_key;
6025 If it does not have one, this does not alter SUBMAPS. */ 6045 mock_input = t;
6026 new_first_binding 6046
6027 = (follow_key (new_key, 6047 fkey_map = prev_fkey_map;
6028 nmaps - local_first_binding, 6048 fkey_start = prev_fkey_start;
6029 submaps + local_first_binding, 6049 fkey_end = prev_fkey_end;
6030 defs + local_first_binding, 6050
6031 submaps + local_first_binding) 6051 keytran_map = prev_keytran_map;
6032 + local_first_binding); 6052 keytran_start = prev_keytran_start;
6033 6053 keytran_end = prev_keytran_end;
6034 /* If that unshifted key is bound, use it instead. */ 6054
6035 if (new_first_binding < nmaps) 6055 goto replay_sequence;
6036 {
6037 keybuf[t - 1] = new_key;
6038 mock_input = t;
6039 goto replay_sequence;
6040 }
6041 } 6056 }
6042 } 6057 }
6043 } 6058 }
6044 6059
6045 if (!dummyflag) 6060 if (!dummyflag)
6048 : Qnil); 6063 : Qnil);
6049 6064
6050 unread_switch_frame = delayed_switch_frame; 6065 unread_switch_frame = delayed_switch_frame;
6051 unbind_to (count, Qnil); 6066 unbind_to (count, Qnil);
6052 6067
6053 if (dont_downcase_last && t - 1 == original_uppercase_position) 6068 /* Don't downcase the last character if the caller says don't.
6069 Don't downcase it if the result is undefined, either. */
6070 if ((dont_downcase_last || first_binding >= nmaps)
6071 && t - 1 == original_uppercase_position)
6054 keybuf[t - 1] = original_uppercase; 6072 keybuf[t - 1] = original_uppercase;
6055 6073
6056 /* Occasionally we fabricate events, perhaps by expanding something 6074 /* Occasionally we fabricate events, perhaps by expanding something
6057 according to function-key-map, or by adding a prefix symbol to a 6075 according to function-key-map, or by adding a prefix symbol to a
6058 mouse click in the scroll bar or modeline. In this cases, return 6076 mouse click in the scroll bar or modeline. In this cases, return