comparison src/keyboard.c @ 9445:712af9626dc0

(read_key_sequence): The output of function-key-map goes to key-translation-map, but not vice versa. Don't exit if either of them is a possibility.
author Richard M. Stallman <rms@gnu.org>
date Tue, 11 Oct 1994 09:22:44 +0000
parents c5d9742c47b3
children b36d5e88cccc
comparison
equal deleted inserted replaced
9444:e21d4ebc3160 9445:712af9626dc0
4441 struct buffer *starting_buffer; 4441 struct buffer *starting_buffer;
4442 4442
4443 /* Nonzero if we seem to have got the beginning of a binding 4443 /* Nonzero if we seem to have got the beginning of a binding
4444 in function_key_map. */ 4444 in function_key_map. */
4445 int function_key_possible = 0; 4445 int function_key_possible = 0;
4446 int key_translation_possible = 0;
4446 4447
4447 int junk; 4448 int junk;
4448 4449
4449 last_nonmenu_event = Qnil; 4450 last_nonmenu_event = Qnil;
4450 4451
4492 keybuf[0..mock_input] holds the sequence we should reread. */ 4493 keybuf[0..mock_input] holds the sequence we should reread. */
4493 replay_sequence: 4494 replay_sequence:
4494 4495
4495 starting_buffer = current_buffer; 4496 starting_buffer = current_buffer;
4496 function_key_possible = 0; 4497 function_key_possible = 0;
4498 key_translation_possible = 0;
4497 4499
4498 /* Build our list of keymaps. 4500 /* Build our list of keymaps.
4499 If we recognize a function key and replace its escape sequence in 4501 If we recognize a function key and replace its escape sequence in
4500 keybuf with its symbol, or if the sequence starts with a mouse 4502 keybuf with its symbol, or if the sequence starts with a mouse
4501 click and we need to switch buffers, we jump back here to rebuild 4503 click and we need to switch buffers, we jump back here to rebuild
4553 while ((first_binding < nmaps && ! NILP (submaps[first_binding])) 4555 while ((first_binding < nmaps && ! NILP (submaps[first_binding]))
4554 || (first_binding >= nmaps 4556 || (first_binding >= nmaps
4555 && fkey_start < t 4557 && fkey_start < t
4556 /* mock input is never part of a function key's sequence. */ 4558 /* mock input is never part of a function key's sequence. */
4557 && mock_input <= fkey_start) 4559 && mock_input <= fkey_start)
4558 || (first_binding >= nmaps 4560 || (keytran_start < t && key_translation_possible)
4559 && keytran_start < t
4560 /* mock input is never part of a function key's sequence. */
4561 && mock_input <= keytran_start)
4562 /* Don't return in the middle of a possible function key sequence, 4561 /* Don't return in the middle of a possible function key sequence,
4563 if the only bindings we found were via case conversion. 4562 if the only bindings we found were via case conversion.
4564 Thus, if ESC O a has a function-key-map translation 4563 Thus, if ESC O a has a function-key-map translation
4565 and ESC o has a binding, don't return after ESC O, 4564 and ESC o has a binding, don't return after ESC O,
4566 so that we can translate ESC O plus the next character. */ 4565 so that we can translate ESC O plus the next character. */
5012 5011
5013 mock_input = t; 5012 mock_input = t;
5014 fkey_start = fkey_end = t; 5013 fkey_start = fkey_end = t;
5015 fkey_map = Vfunction_key_map; 5014 fkey_map = Vfunction_key_map;
5016 5015
5016 /* Do pass the results through key-translation-map. */
5017 keytran_start = keytran_end = 0;
5018 keytran_map = Vkey_translation_map;
5019
5017 goto replay_sequence; 5020 goto replay_sequence;
5018 } 5021 }
5019 5022
5020 fkey_map = get_keymap_1 (fkey_next, 0, 1); 5023 fkey_map = get_keymap_1 (fkey_next, 0, 1);
5021 5024
5076 other variables.) */ 5079 other variables.) */
5077 if (! (VECTORP (keytran_next) || STRINGP (keytran_next))) 5080 if (! (VECTORP (keytran_next) || STRINGP (keytran_next)))
5078 error ("Function in key-translation-map returns invalid key sequence"); 5081 error ("Function in key-translation-map returns invalid key sequence");
5079 } 5082 }
5080 5083
5084 key_translation_possible = ! NILP (keytran_next);
5085
5081 /* If keybuf[keytran_start..keytran_end] is bound in the 5086 /* If keybuf[keytran_start..keytran_end] is bound in the
5082 key translation map and it's a suffix of the current 5087 key translation map and it's a suffix of the current
5083 sequence (i.e. keytran_end == t), replace it with 5088 sequence (i.e. keytran_end == t), replace it with
5084 the binding and restart with keytran_start at the end. */ 5089 the binding and restart with keytran_start at the end. */
5085 if ((VECTORP (keytran_next) || STRINGP (keytran_next)) 5090 if ((VECTORP (keytran_next) || STRINGP (keytran_next))
5106 5111
5107 mock_input = t; 5112 mock_input = t;
5108 keytran_start = keytran_end = t; 5113 keytran_start = keytran_end = t;
5109 keytran_map = Vkey_translation_map; 5114 keytran_map = Vkey_translation_map;
5110 5115
5116 /* Don't pass the results of key-translation-map
5117 through function-key-map. */
5118 fkey_start = fkey_end = t;
5119 fkey_map = Vkey_translation_map;
5120
5111 goto replay_sequence; 5121 goto replay_sequence;
5112 } 5122 }
5113 5123
5114 keytran_map = get_keymap_1 (keytran_next, 0, 1); 5124 keytran_map = get_keymap_1 (keytran_next, 0, 1);
5115 5125
5117 keytran_start. */ 5127 keytran_start. */
5118 if (NILP (keytran_map)) 5128 if (NILP (keytran_map))
5119 { 5129 {
5120 keytran_end = ++keytran_start; 5130 keytran_end = ++keytran_start;
5121 keytran_map = Vkey_translation_map; 5131 keytran_map = Vkey_translation_map;
5132 key_translation_possible = 0;
5122 } 5133 }
5123 } 5134 }
5124 } 5135 }
5125 5136
5126 /* If KEY is not defined in any of the keymaps, 5137 /* If KEY is not defined in any of the keymaps,
5127 and cannot be part of a function key or translation, 5138 and cannot be part of a function key or translation,
5128 and is an upper case letter 5139 and is an upper case letter
5129 use the corresponding lower-case letter instead. */ 5140 use the corresponding lower-case letter instead. */
5130 if (first_binding == nmaps && ! function_key_possible 5141 if (first_binding == nmaps && ! function_key_possible
5142 && ! key_translation_possible
5131 && INTEGERP (key) 5143 && INTEGERP (key)
5132 && ((((XINT (key) & 0x3ffff) 5144 && ((((XINT (key) & 0x3ffff)
5133 < XSTRING (current_buffer->downcase_table)->size) 5145 < XSTRING (current_buffer->downcase_table)->size)
5134 && UPPERCASEP (XINT (key) & 0x3ffff)) 5146 && UPPERCASEP (XINT (key) & 0x3ffff))
5135 || (XINT (key) & shift_modifier))) 5147 || (XINT (key) & shift_modifier)))