]> code.delx.au - gnu-emacs/blobdiff - src/keyboard.c
(lispy_function_keys): Add kp-numlock. Fix kp-backspace.
[gnu-emacs] / src / keyboard.c
index 023634663a5a1a83ca3d37f84cd3b25521e87d47..6b267bd8e087b362c33fc15593239c301ef89c54 100644 (file)
@@ -1230,6 +1230,45 @@ stop_polling ()
     }
 #endif
 }
+\f
+/* Applying the control modifier to CHARACTER.  */
+int
+make_ctrl_char (c)
+     int c;
+{
+  /* Save the upper bits here.  */
+  int upper = c & ~0177;
+
+  c &= 0177;
+
+  /* Everything in the columns containing the upper-case letters
+     denotes a control character.  */
+  if (c >= 0100 && c < 0140)
+    {
+      int oc = c;
+      c &= ~0140;
+      /* Set the shift modifier for a control char
+        made from a shifted letter.  But only for letters!  */
+      if (oc >= 'A' && oc <= 'Z')
+       c |= shift_modifier;
+    }
+
+  /* The lower-case letters denote control characters too.  */
+  else if (c >= 'a' && c <= 'z')
+    c &= ~0140;
+
+  /* Include the bits for control and shift
+     only if the basic ASCII code can't indicate them.  */
+  else if (c >= ' ')
+    c |= ctrl_modifier;
+
+  /* Replace the high bits.  */
+  c |= (upper & ~ctrl_modifier);
+
+  return c;
+}
+
+
 \f
 /* Input of single characters from keyboard */
 
@@ -1462,26 +1501,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
       if ((extra_keyboard_modifiers & CHAR_CTL)
          || ((extra_keyboard_modifiers & 0177) < ' '
              && (extra_keyboard_modifiers & 0177) != 0))
-       {
-         /* If it's already a control character, don't mess with it.  */
-         if ((c & 0177) == 0)
-           ;
-
-         /* Making ? a control character should result in DEL.  */
-         else if ((c & 0177) == '?')
-           c |= 0177;
-
-         /* ASCII control chars are made from letters (both cases),
-            as well as the non-letters within 0100...0137.  */
-         else if ((c & 0137) >= 0101 && (c & 0137) <= 0132)
-           c = (c & (037 | ~0177));
-         else if ((c & 0177) >= 0100 && (c & 0177) <= 0137)
-           c = (c & (037 | ~0177));
-
-         /* Anything else must get its high control bit set.  */
-         else
-           c = c | ctrl_modifier;
-       }
+       XSETINT (c, make_ctrl_char (XINT (c)));
 
       /* Transfer any other modifier bits directly from
         extra_keyboard_modifiers to c.  Ignore the actual character code
@@ -1692,6 +1712,9 @@ kbd_buffer_store_event (event)
     {
       register int c = XFASTINT (event->code) & 0377;
 
+      if (event->modifiers & ctrl_modifier)
+       c = make_ctrl_char (c);
+
       if (c == quit_char)
        {
          extern SIGTYPE interrupt_signal ();
@@ -2003,9 +2026,9 @@ static char *lispy_function_keys[] =
     "insertchar",
     "deletechar",
     "backtab",
-    "kp_backtab",              /* 0x1000ff75 */
+    "kp-backtab",              /* 0x1000ff75 */
     0,                         /* 0xff76 */
-    0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xff7f */
+    0, 0, 0, 0, 0, 0, 0, 0, "kp-numlock",      /* 0xff7f */
     "kp-space",                        /* 0xff80 */    /* IsKeypadKey */
     0, 0, 0, 0, 0, 0, 0, 0,
     "kp-tab",                  /* 0xff89 */
@@ -2093,23 +2116,11 @@ make_lispy_event (event)
        /* Turn ASCII characters into control characters
           when proper.  */
        if (event->modifiers & ctrl_modifier)
-         {
-           if (c >= 0100 && c < 0140)
-             {
-               int oc = c;
-               c &= ~0140;
-               /* Set the shift modifier for a control char
-                  made from a shifted letter.  But only for letters!  */
-               if (oc >= 'A' && oc <= 'Z')
-                 c |= shift_modifier;
-             }
-           else if (c >= 'a' && c <= 'z')
-             c &= ~0140;
-           /* Include the bits for control and shift
-              only if the basic ASCII code can't indicate them.  */
-           else
-             c |= ctrl_modifier;
-         }
+         c = make_ctrl_char (c);
+
+       /* Add in the other modifier bits.  We took care of ctrl_modifier
+          just above, and the shift key was taken care of by the X code,
+          and applied to control characters by make_ctrl_char.  */
        c |= (event->modifiers
              & (meta_modifier | alt_modifier
                 | hyper_modifier | super_modifier));
@@ -2343,6 +2354,8 @@ make_lispy_movement (frame, bar_window, part, x, y, time)
        {
          window = Qnil;
          posn = Qnil;
+         XFASTINT (x) = 0;
+         XFASTINT (y) = 0;
        }
 
       return Fcons (Qmouse_movement,
@@ -2510,8 +2523,8 @@ apply_modifiers_uncached (modifiers, base, base_len)
 
 static char *modifier_names[] =
 {
-  "up", 0, 0, 0, 0, 0, 0, "down",
-  "drag", "click", 0, 0, 0, 0, 0, 0,
+  "up", "down", "drag", "click", 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, "alt", "super", "hyper", "shift", "control", "meta"
 };
 #define NUM_MOD_NAMES (sizeof (modifier_names) / sizeof (modifier_names[0]))
@@ -2726,7 +2739,14 @@ modify_event_symbol (symbol_num, modifiers, symbol_kind, name_table,
   if (NILP (*slot))
     {
       /* No; let's create it.  */
-      *slot = intern (name_table[symbol_num]);
+      if (name_table[symbol_num])
+       *slot = intern (name_table[symbol_num]);
+      else
+       {
+         char buf[20];
+         sprintf (buf, "key-%d", symbol_num);
+         *slot = intern (buf);
+       }
 
       /* Fill in the cache entries for this symbol; this also  
         builds the Qevent_symbol_elements property, which the user