/[emacs]/emacs/src/keyboard.c
ViewVC logotype

Diff of /emacs/src/keyboard.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.680 by rms, Tue Jun 11 19:29:40 2002 UTC revision 1.681 by monnier, Tue Jun 11 19:50:45 2002 UTC
# Line 8059  read_key_sequence (keybuf, bufsize, prom Line 8059  read_key_sequence (keybuf, bufsize, prom
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
# Line 8230  read_key_sequence (keybuf, bufsize, prom Line 8220  read_key_sequence (keybuf, bufsize, prom
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
# Line 8766  read_key_sequence (keybuf, bufsize, prom Line 8758  read_key_sequence (keybuf, bufsize, prom
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
# Line 8890  read_key_sequence (keybuf, bufsize, prom Line 8874  read_key_sequence (keybuf, bufsize, prom
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    
# Line 8921  read_key_sequence (keybuf, bufsize, prom Line 8915  read_key_sequence (keybuf, bufsize, prom
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;
# Line 8945  read_key_sequence (keybuf, bufsize, prom Line 8938  read_key_sequence (keybuf, bufsize, prom
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                }                }
# Line 9019  read_key_sequence (keybuf, bufsize, prom Line 9011  read_key_sequence (keybuf, bufsize, prom
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          }          }
# Line 9056  read_key_sequence (keybuf, bufsize, prom Line 9040  read_key_sequence (keybuf, bufsize, prom
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              }              }

Legend:
Removed from v.1.680  
changed lines
  Added in v.1.681

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26