Mercurial > emacs
comparison src/keyboard.c @ 109302:60516122d066
Merge changes from emacs-23 branch.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sat, 10 Jul 2010 14:52:53 -0400 |
parents | 8cfee7d2955f 2b7e4e256ac1 |
children | d81bdcde8ec3 |
comparison
equal
deleted
inserted
replaced
109190:8afa85da3f2d | 109302:60516122d066 |
---|---|
40 #include "keymap.h" | 40 #include "keymap.h" |
41 #include "blockinput.h" | 41 #include "blockinput.h" |
42 #include "puresize.h" | 42 #include "puresize.h" |
43 #include "systime.h" | 43 #include "systime.h" |
44 #include "atimer.h" | 44 #include "atimer.h" |
45 #include <setjmp.h> | |
46 #include <errno.h> | 45 #include <errno.h> |
47 | 46 |
48 #ifdef HAVE_GTK_AND_PTHREAD | 47 #ifdef HAVE_GTK_AND_PTHREAD |
49 #include <pthread.h> | 48 #include <pthread.h> |
50 #endif | 49 #endif |
8998 static int | 8997 static int |
8999 read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | 8998 read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, |
9000 int dont_downcase_last, int can_return_switch_frame, | 8999 int dont_downcase_last, int can_return_switch_frame, |
9001 int fix_current_buffer) | 9000 int fix_current_buffer) |
9002 { | 9001 { |
9003 volatile Lisp_Object from_string; | 9002 Lisp_Object from_string; |
9004 volatile int count = SPECPDL_INDEX (); | 9003 int count = SPECPDL_INDEX (); |
9005 | 9004 |
9006 /* How many keys there are in the current key sequence. */ | 9005 /* How many keys there are in the current key sequence. */ |
9007 volatile int t; | 9006 int t; |
9008 | 9007 |
9009 /* The length of the echo buffer when we started reading, and | 9008 /* The length of the echo buffer when we started reading, and |
9010 the length of this_command_keys when we started reading. */ | 9009 the length of this_command_keys when we started reading. */ |
9011 volatile int echo_start; | 9010 int echo_start; |
9012 volatile int keys_start; | 9011 int keys_start; |
9013 | 9012 |
9014 /* The number of keymaps we're scanning right now, and the number of | 9013 /* The number of keymaps we're scanning right now, and the number of |
9015 keymaps we have allocated space for. */ | 9014 keymaps we have allocated space for. */ |
9016 volatile int nmaps; | 9015 int nmaps; |
9017 volatile int nmaps_allocated = 0; | 9016 int nmaps_allocated = 0; |
9018 | 9017 |
9019 /* defs[0..nmaps-1] are the definitions of KEYBUF[0..t-1] in | 9018 /* defs[0..nmaps-1] are the definitions of KEYBUF[0..t-1] in |
9020 the current keymaps. */ | 9019 the current keymaps. */ |
9021 Lisp_Object *volatile defs = NULL; | 9020 Lisp_Object *defs = NULL; |
9022 | 9021 |
9023 /* submaps[0..nmaps-1] are the prefix definitions of KEYBUF[0..t-1] | 9022 /* submaps[0..nmaps-1] are the prefix definitions of KEYBUF[0..t-1] |
9024 in the current keymaps, or nil where it is not a prefix. */ | 9023 in the current keymaps, or nil where it is not a prefix. */ |
9025 Lisp_Object *volatile submaps = NULL; | 9024 Lisp_Object *submaps = NULL; |
9026 | 9025 |
9027 /* The local map to start out with at start of key sequence. */ | 9026 /* The local map to start out with at start of key sequence. */ |
9028 volatile Lisp_Object orig_local_map; | 9027 Lisp_Object orig_local_map; |
9029 | 9028 |
9030 /* The map from the `keymap' property to start out with at start of | 9029 /* The map from the `keymap' property to start out with at start of |
9031 key sequence. */ | 9030 key sequence. */ |
9032 volatile Lisp_Object orig_keymap; | 9031 Lisp_Object orig_keymap; |
9033 | 9032 |
9034 /* 1 if we have already considered switching to the local-map property | 9033 /* 1 if we have already considered switching to the local-map property |
9035 of the place where a mouse click occurred. */ | 9034 of the place where a mouse click occurred. */ |
9036 volatile int localized_local_map = 0; | 9035 int localized_local_map = 0; |
9037 | 9036 |
9038 /* The index in submaps[] of the first keymap that has a binding for | 9037 /* The index in submaps[] of the first keymap that has a binding for |
9039 this key sequence. In other words, the lowest i such that | 9038 this key sequence. In other words, the lowest i such that |
9040 submaps[i] is non-nil. */ | 9039 submaps[i] is non-nil. */ |
9041 volatile int first_binding; | 9040 int first_binding; |
9042 /* Index of the first key that has no binding. | 9041 /* Index of the first key that has no binding. |
9043 It is useless to try fkey.start larger than that. */ | 9042 It is useless to try fkey.start larger than that. */ |
9044 volatile int first_unbound; | 9043 int first_unbound; |
9045 | 9044 |
9046 /* If t < mock_input, then KEYBUF[t] should be read as the next | 9045 /* If t < mock_input, then KEYBUF[t] should be read as the next |
9047 input key. | 9046 input key. |
9048 | 9047 |
9049 We use this to recover after recognizing a function key. Once we | 9048 We use this to recover after recognizing a function key. Once we |
9054 this_command_keys, and the submaps and defs arrays are wrong. In | 9053 this_command_keys, and the submaps and defs arrays are wrong. In |
9055 this situation, we set mock_input to t, set t to 0, and jump to | 9054 this situation, we set mock_input to t, set t to 0, and jump to |
9056 restart_sequence; the loop will read keys from keybuf up until | 9055 restart_sequence; the loop will read keys from keybuf up until |
9057 mock_input, thus rebuilding the state; and then it will resume | 9056 mock_input, thus rebuilding the state; and then it will resume |
9058 reading characters from the keyboard. */ | 9057 reading characters from the keyboard. */ |
9059 volatile int mock_input = 0; | 9058 int mock_input = 0; |
9060 | 9059 |
9061 /* If the sequence is unbound in submaps[], then | 9060 /* If the sequence is unbound in submaps[], then |
9062 keybuf[fkey.start..fkey.end-1] is a prefix in Vfunction_key_map, | 9061 keybuf[fkey.start..fkey.end-1] is a prefix in Vfunction_key_map, |
9063 and fkey.map is its binding. | 9062 and fkey.map is its binding. |
9064 | 9063 |
9065 These might be > t, indicating that all function key scanning | 9064 These might be > t, indicating that all function key scanning |
9066 should hold off until t reaches them. We do this when we've just | 9065 should hold off until t reaches them. We do this when we've just |
9067 recognized a function key, to avoid searching for the function | 9066 recognized a function key, to avoid searching for the function |
9068 key's again in Vfunction_key_map. */ | 9067 key's again in Vfunction_key_map. */ |
9069 volatile keyremap fkey; | 9068 keyremap fkey; |
9070 | 9069 |
9071 /* Likewise, for key_translation_map and input-decode-map. */ | 9070 /* Likewise, for key_translation_map and input-decode-map. */ |
9072 volatile keyremap keytran, indec; | 9071 keyremap keytran, indec; |
9073 | 9072 |
9074 /* Non-zero if we are trying to map a key by changing an upper-case | 9073 /* Non-zero if we are trying to map a key by changing an upper-case |
9075 letter to lower case, or a shifted function key to an unshifted | 9074 letter to lower case, or a shifted function key to an unshifted |
9076 one. */ | 9075 one. */ |
9077 volatile int shift_translated = 0; | 9076 int shift_translated = 0; |
9078 | 9077 |
9079 /* If we receive a `switch-frame' or `select-window' event in the middle of | 9078 /* If we receive a `switch-frame' or `select-window' event in the middle of |
9080 a key sequence, we put it off for later. | 9079 a key sequence, we put it off for later. |
9081 While we're reading, we keep the event here. */ | 9080 While we're reading, we keep the event here. */ |
9082 volatile Lisp_Object delayed_switch_frame; | 9081 Lisp_Object delayed_switch_frame; |
9083 | 9082 |
9084 /* See the comment below... */ | 9083 /* See the comment below... */ |
9085 #if defined (GOBBLE_FIRST_EVENT) | 9084 #if defined (GOBBLE_FIRST_EVENT) |
9086 Lisp_Object first_event; | 9085 Lisp_Object first_event; |
9087 #endif | 9086 #endif |
9088 | 9087 |
9089 volatile Lisp_Object original_uppercase; | 9088 Lisp_Object original_uppercase; |
9090 volatile int original_uppercase_position = -1; | 9089 int original_uppercase_position = -1; |
9091 | 9090 |
9092 /* Gets around Microsoft compiler limitations. */ | 9091 /* Gets around Microsoft compiler limitations. */ |
9093 int dummyflag = 0; | 9092 int dummyflag = 0; |
9094 | 9093 |
9095 struct buffer *starting_buffer; | 9094 struct buffer *starting_buffer; |
9096 | 9095 |
9097 /* List of events for which a fake prefix key has been generated. */ | 9096 /* List of events for which a fake prefix key has been generated. */ |
9098 volatile Lisp_Object fake_prefixed_keys = Qnil; | 9097 Lisp_Object fake_prefixed_keys = Qnil; |
9099 | 9098 |
9100 #if defined (GOBBLE_FIRST_EVENT) | 9099 #if defined (GOBBLE_FIRST_EVENT) |
9101 int junk; | 9100 int junk; |
9102 #endif | 9101 #endif |
9103 | 9102 |
9250 /* Where the last real key started. If we need to throw away a | 9249 /* Where the last real key started. If we need to throw away a |
9251 key that has expanded into more than one element of keybuf | 9250 key that has expanded into more than one element of keybuf |
9252 (say, a mouse click on the mode line which is being treated | 9251 (say, a mouse click on the mode line which is being treated |
9253 as [mode-line (mouse-...)], then we backtrack to this point | 9252 as [mode-line (mouse-...)], then we backtrack to this point |
9254 of keybuf. */ | 9253 of keybuf. */ |
9255 volatile int last_real_key_start; | 9254 int last_real_key_start; |
9256 | 9255 |
9257 /* These variables are analogous to echo_start and keys_start; | 9256 /* These variables are analogous to echo_start and keys_start; |
9258 while those allow us to restart the entire key sequence, | 9257 while those allow us to restart the entire key sequence, |
9259 echo_local_start and keys_local_start allow us to throw away | 9258 echo_local_start and keys_local_start allow us to throw away |
9260 just one key. */ | 9259 just one key. */ |
9261 volatile int echo_local_start, keys_local_start, local_first_binding; | 9260 int echo_local_start, keys_local_start, local_first_binding; |
9262 | 9261 |
9263 eassert (indec.end == t || (indec.end > t && indec.end <= mock_input)); | 9262 eassert (indec.end == t || (indec.end > t && indec.end <= mock_input)); |
9264 eassert (indec.start <= indec.end); | 9263 eassert (indec.start <= indec.end); |
9265 eassert (fkey.start <= fkey.end); | 9264 eassert (fkey.start <= fkey.end); |
9266 eassert (keytran.start <= keytran.end); | 9265 eassert (keytran.start <= keytran.end); |