8059 |
/* List of events for which a fake prefix key has been generated. */ |
/* List of events for which a fake prefix key has been generated. */ |
8060 |
volatile Lisp_Object fake_prefixed_keys = Qnil; |
volatile Lisp_Object fake_prefixed_keys = Qnil; |
8061 |
|
|
|
/* Save the status of key translation before each step, |
|
|
so that we can restore this after downcasing. */ |
|
|
Lisp_Object prev_fkey_map; |
|
|
int prev_fkey_start; |
|
|
int prev_fkey_end; |
|
|
|
|
|
Lisp_Object prev_keytran_map; |
|
|
int prev_keytran_start; |
|
|
int prev_keytran_end; |
|
|
|
|
8062 |
#if defined (GOBBLE_FIRST_EVENT) |
#if defined (GOBBLE_FIRST_EVENT) |
8063 |
int junk; |
int junk; |
8064 |
#endif |
#endif |
8220 |
just one key. */ |
just one key. */ |
8221 |
volatile int echo_local_start, keys_local_start, local_first_binding; |
volatile int echo_local_start, keys_local_start, local_first_binding; |
8222 |
|
|
8223 |
|
/* key-translation-map is applied *after* function-key-map. */ |
8224 |
|
eassert (keytran_end <= fkey_start); |
8225 |
|
|
8226 |
if (first_unbound < fkey_start && first_unbound < keytran_start) |
if (first_unbound < fkey_start && first_unbound < keytran_start) |
8227 |
{ /* The prefix upto first_unbound has no binding and has |
{ /* The prefix upto first_unbound has no binding and has |
8758 |
/* Record what part of this_command_keys is the current key sequence. */ |
/* Record what part of this_command_keys is the current key sequence. */ |
8759 |
this_single_command_key_start = this_command_key_count - t; |
this_single_command_key_start = this_command_key_count - t; |
8760 |
|
|
|
prev_fkey_map = fkey_map; |
|
|
prev_fkey_start = fkey_start; |
|
|
prev_fkey_end = fkey_end; |
|
|
|
|
|
prev_keytran_map = keytran_map; |
|
|
prev_keytran_start = keytran_start; |
|
|
prev_keytran_end = keytran_end; |
|
|
|
|
8761 |
/* If the sequence is unbound, see if we can hang a function key |
/* If the sequence is unbound, see if we can hang a function key |
8762 |
off the end of it. We only want to scan real keyboard input |
off the end of it. We only want to scan real keyboard input |
8763 |
for function key sequences, so if mock_input says that we're |
for function key sequences, so if mock_input says that we're |
8874 |
} |
} |
8875 |
} |
} |
8876 |
} |
} |
8877 |
|
else if (NILP (submaps[first_binding])) |
8878 |
|
/* There is a global binding and it's not a prefix. |
8879 |
|
There is thus no function-key in this sequence. |
8880 |
|
We can probably show that there can't be any afterwards either |
8881 |
|
but I can't seem to find a clear reason why not, so I'll |
8882 |
|
be conservative. |
8883 |
|
Moving fkey.start is important in this case to allow keytran.start |
8884 |
|
to go over the sequence before we return (since we keep the |
8885 |
|
invariant that keytran.end <= fkey.start). */ |
8886 |
|
(fkey_start = max (fkey_start, t), fkey_end = max (fkey_end, t)); |
8887 |
|
|
8888 |
/* Look for this sequence in key-translation-map. */ |
/* Look for this sequence in key-translation-map. */ |
8889 |
{ |
{ |
8890 |
Lisp_Object keytran_next; |
Lisp_Object keytran_next; |
8891 |
|
|
8892 |
/* Scan from keytran_end until we find a bound suffix. */ |
/* Scan from keytran_end until we find a bound suffix. */ |
8893 |
while (keytran_end < t) |
while (keytran_end < fkey_start) |
8894 |
{ |
{ |
8895 |
Lisp_Object key; |
Lisp_Object key; |
8896 |
|
|
8915 |
/* If the key translation map gives a function, not an |
/* If the key translation map gives a function, not an |
8916 |
array, then call the function with one arg and use |
array, then call the function with one arg and use |
8917 |
its value instead. */ |
its value instead. */ |
8918 |
if (SYMBOLP (keytran_next) && ! NILP (Ffboundp (keytran_next)) |
if (SYMBOLP (keytran_next) && ! NILP (Ffboundp (keytran_next))) |
|
&& keytran_end == t) |
|
8919 |
{ |
{ |
8920 |
struct gcpro gcpro1, gcpro2, gcpro3; |
struct gcpro gcpro1, gcpro2, gcpro3; |
8921 |
Lisp_Object tem; |
Lisp_Object tem; |
8938 |
key translation map and it's a suffix of the current |
key translation map and it's a suffix of the current |
8939 |
sequence (i.e. keytran_end == t), replace it with |
sequence (i.e. keytran_end == t), replace it with |
8940 |
the binding and restart with keytran_start at the end. */ |
the binding and restart with keytran_start at the end. */ |
8941 |
if ((VECTORP (keytran_next) || STRINGP (keytran_next)) |
if ((VECTORP (keytran_next) || STRINGP (keytran_next))) |
|
&& keytran_end == t) |
|
8942 |
{ |
{ |
8943 |
int len = XFASTINT (Flength (keytran_next)); |
int len = XFASTINT (Flength (keytran_next)); |
8944 |
|
int i, diff = len - (keytran_end - keytran_start); |
8945 |
|
|
8946 |
t = keytran_start + len; |
mock_input = max (t, mock_input); |
8947 |
if (t >= bufsize) |
if (mock_input + diff >= bufsize) |
8948 |
error ("Key sequence too long"); |
error ("Key sequence too long"); |
8949 |
|
|
8950 |
if (VECTORP (keytran_next)) |
/* Shift the keys that are after keytran_end. */ |
8951 |
bcopy (XVECTOR (keytran_next)->contents, |
if (diff < 0) |
8952 |
keybuf + keytran_start, |
for (i = keytran_end; i < mock_input; i++) |
8953 |
(t - keytran_start) * sizeof (keybuf[0])); |
keybuf[i + diff] = keybuf[i]; |
8954 |
else if (STRINGP (keytran_next)) |
else if (diff > 0) |
8955 |
{ |
for (i = mock_input - 1; i >= keytran_end; i--) |
8956 |
int i; |
keybuf[i + diff] = keybuf[i]; |
8957 |
|
/* Replace the keys between keytran_start and keytran_end |
8958 |
|
with those from keytran_next. */ |
8959 |
|
for (i = 0; i < len; i++) |
8960 |
|
keybuf[keytran_start + i] |
8961 |
|
= Faref (keytran_next, make_number (i)); |
8962 |
|
|
8963 |
for (i = 0; i < len; i++) |
mock_input += diff; |
8964 |
XSETFASTINT (keybuf[keytran_start + i], |
keytran_start = keytran_end += diff; |
|
XSTRING (keytran_next)->data[i]); |
|
|
} |
|
|
|
|
|
mock_input = t; |
|
|
keytran_start = keytran_end = t; |
|
8965 |
keytran_map = Vkey_translation_map; |
keytran_map = Vkey_translation_map; |
8966 |
|
|
8967 |
/* Don't pass the results of key-translation-map |
/* Adjust the function-key-map counters. */ |
8968 |
through function-key-map. */ |
fkey_start += diff; |
8969 |
fkey_start = fkey_end = t; |
fkey_end += diff; |
|
fkey_map = Vfunction_key_map; |
|
8970 |
|
|
8971 |
goto replay_sequence; |
goto replay_sequence; |
8972 |
} |
} |
9011 |
the lower-case char is defined in the keymaps, because they |
the lower-case char is defined in the keymaps, because they |
9012 |
might get translated through function-key-map. */ |
might get translated through function-key-map. */ |
9013 |
keybuf[t - 1] = new_key; |
keybuf[t - 1] = new_key; |
9014 |
mock_input = t; |
mock_input = max (t, mock_input); |
|
|
|
|
fkey_map = prev_fkey_map; |
|
|
fkey_start = prev_fkey_start; |
|
|
fkey_end = prev_fkey_end; |
|
|
|
|
|
keytran_map = prev_keytran_map; |
|
|
keytran_start = prev_keytran_start; |
|
|
keytran_end = prev_keytran_end; |
|
9015 |
|
|
9016 |
goto replay_sequence; |
goto replay_sequence; |
9017 |
} |
} |
9040 |
XCAR (breakdown)); |
XCAR (breakdown)); |
9041 |
|
|
9042 |
keybuf[t - 1] = new_key; |
keybuf[t - 1] = new_key; |
9043 |
mock_input = t; |
mock_input = max (t, mock_input); |
|
|
|
|
fkey_map = prev_fkey_map; |
|
|
fkey_start = prev_fkey_start; |
|
|
fkey_end = prev_fkey_end; |
|
|
|
|
|
keytran_map = prev_keytran_map; |
|
|
keytran_start = prev_keytran_start; |
|
|
keytran_end = prev_keytran_end; |
|
9044 |
|
|
9045 |
goto replay_sequence; |
goto replay_sequence; |
9046 |
} |
} |