changeset 28479:5e8fd5aab7a7

(lispy_mouse_names): Variable removed. (Vlispy_mouse_stem): New variable. (syms_of_keyboard): Initialize Vlispy_mouse_stem. (make_lispy_event) <mouse_click, scroll_bar_click>: Don't abort for any mouse button number. Increase size of mouse_syms and button_down_location as needed. Call modify_event_symbol with different arguments. (make_lispy_event) <scroll_bar_click> [USE_TOOLKIT_SCROLL_BARS]: Call modify_event_symbol with different arguments. (make_lispy_event) <w32_scroll_bar_click> [WINDOWSNT]: Don't abort for any button number. Call modify_event_symbol with different arguments. (modify_event_symbol): Rename NAME_ALIST to NAME_ALIST_OR_STEM. Accept a string for NAME_ALIST_OR_STEM.
author Gerd Moellmann <gerd@gnu.org>
date Mon, 03 Apr 2000 12:11:39 +0000
parents 55576e0788b1
children cbe58003b232
files src/keyboard.c
diffstat 1 files changed, 43 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/src/keyboard.c	Mon Apr 03 11:39:31 2000 +0000
+++ b/src/keyboard.c	Mon Apr 03 12:11:39 2000 +0000
@@ -4085,12 +4085,7 @@
 
 #endif /* not HAVE_NTGUI */
 
-static char *lispy_mouse_names[] =
-{
-  "mouse-1", "mouse-2", "mouse-3", "mouse-4", "mouse-5",
-  "mouse-6", "mouse-7", "mouse-8", "mouse-9", "mouse-10",
-  "mouse-11", "mouse-12", "mouse-13", "mouse-14", "mouse-15"
-};
+Lisp_Object Vlispy_mouse_stem;
 
 #ifdef WINDOWSNT
 /* mouse-wheel events are generated by the wheel on devices such as
@@ -4276,9 +4271,6 @@
 	Lisp_Object *start_pos_ptr;
 	Lisp_Object start_pos;
 
-	if (button < 0 || button >= NUM_MOUSE_BUTTONS)
-	  abort ();
-
 	/* Build the position as appropriate for this mouse click.  */
 	if (event->kind == mouse_click)
 	  {
@@ -4430,6 +4422,13 @@
 	  }
 #endif /* not USE_TOOLKIT_SCROLL_BARS */
 
+	if (button >= XVECTOR (button_down_location)->size)
+	  {
+	    button_down_location = larger_vector (button_down_location,
+						  button + 1, Qnil);
+	    mouse_syms = larger_vector (mouse_syms, button + 1, Qnil);
+	  }
+	
 	start_pos_ptr = &XVECTOR (button_down_location)->contents[button];
 
 	start_pos = *start_pos_ptr;
@@ -4519,10 +4518,10 @@
 
 	  head = modify_event_symbol (button,
 				      event->modifiers,
-				      Qmouse_click, Qnil,
-				      lispy_mouse_names, &mouse_syms,
-				      (sizeof (lispy_mouse_names)
-				       / sizeof (lispy_mouse_names[0])));
+				      Qmouse_click, Vlispy_mouse_stem,
+				      NULL,
+				      &mouse_syms,
+				      XVECTOR (mouse_syms)->size);
 	  if (event->modifiers & drag_modifier)
 	    return Fcons (head,
 			  Fcons (start_pos,
@@ -4580,10 +4579,10 @@
 	/* Get the symbol we should use for the mouse click.  */
 	head = modify_event_symbol (event->code,
 				    event->modifiers,
-				    Qmouse_click, Qnil,
-				    lispy_mouse_names, &mouse_syms,
-				    (sizeof (lispy_mouse_names)
-				     / sizeof (lispy_mouse_names[0])));
+				    Qmouse_click, 
+				    Vlispy_mouse_stem,
+				    NULL, &mouse_syms,
+				    XVECTOR (mouse_syms)->size);
 	return Fcons (head, Fcons (position, Qnil));
       }
       
@@ -4598,9 +4597,6 @@
 	Lisp_Object *start_pos_ptr;
 	Lisp_Object start_pos;
 
-	if (button < 0 || button >= NUM_MOUSE_BUTTONS)
-	  abort ();
-
 	{
 	  Lisp_Object window;
 	  Lisp_Object portion_whole;
@@ -4627,10 +4623,10 @@
 
 	  head = modify_event_symbol (button,
 				      event->modifiers,
-				      Qmouse_click, Qnil,
-				      lispy_mouse_names, &mouse_syms,
-				      (sizeof (lispy_mouse_names)
-				       / sizeof (lispy_mouse_names[0])));
+				      Qmouse_click, 
+				      Vlispy_mouse_stem,
+				      NULL, &mouse_syms,
+				      XVECTOR (mouse_syms)->size);
 	  return Fcons (head,
 			Fcons (position,
 			       Qnil));
@@ -5220,8 +5216,11 @@
    is the name of the i'th symbol.  TABLE_SIZE is the number of elements
    in the table.
 
-   Alternatively, NAME_ALIST is an alist mapping codes into symbol names.
-   NAME_ALIST is used if it is non-nil; otherwise NAME_TABLE is used.
+   Alternatively, NAME_ALIST_OR_STEM is either an alist mapping codes
+   into symbol names, or a string specifying a name stem used to
+   contruct a symbol name or the form `STEM-N', where N is the decimal
+   representation of SYMBOL_NUM.  NAME_ALIST_OR_STEM is used if it is
+   non-nil; otherwise NAME_TABLE is used.
 
    SYMBOL_TABLE should be a pointer to a Lisp_Object whose value will
    persist between calls to modify_event_symbol that it can use to
@@ -5241,12 +5240,12 @@
    in the symbol's name.  */
 
 static Lisp_Object
-modify_event_symbol (symbol_num, modifiers, symbol_kind, name_alist,
+modify_event_symbol (symbol_num, modifiers, symbol_kind, name_alist_or_stem,
                      name_table, symbol_table, table_size)
      int symbol_num;
      unsigned modifiers;
      Lisp_Object symbol_kind;
-     Lisp_Object name_alist;
+     Lisp_Object name_alist_or_stem;
      char **name_table;
      Lisp_Object *symbol_table;
      unsigned int table_size;
@@ -5286,8 +5285,16 @@
   if (NILP (value))
     {
       /* No; let's create it.  */
-      if (!NILP (name_alist))
-	value = Fcdr_safe (Fassq (symbol_int, name_alist));
+      if (CONSP (name_alist_or_stem))
+	value = Fcdr_safe (Fassq (symbol_int, name_alist_or_stem));
+      else if (STRINGP (name_alist_or_stem))
+	{
+	  int len = STRING_BYTES (XSTRING (name_alist_or_stem));
+	  char *buf = (char *) alloca (len + 50);
+	  sprintf (buf, "%s-%d", XSTRING (name_alist_or_stem)->data,
+		   XINT (symbol_int) + 1);
+	  value = intern (buf);
+	}
       else if (name_table != 0 && name_table[symbol_num])
 	value = intern (name_table[symbol_num]);
 
@@ -9638,6 +9645,9 @@
 void
 syms_of_keyboard ()
 {
+  Vlispy_mouse_stem = build_string ("mouse");
+  staticpro (&Vlispy_mouse_stem);
+  
   /* Tool-bars.  */
   QCimage = intern (":image");
   staticpro (&QCimage);
@@ -9803,8 +9813,10 @@
       }
   }
 
-  button_down_location = Fmake_vector (make_number (NUM_MOUSE_BUTTONS), Qnil);
+  button_down_location = Fmake_vector (make_number (1), Qnil);
   staticpro (&button_down_location);
+  mouse_syms = Fmake_vector (make_number (1), Qnil);
+  staticpro (&mouse_syms);
 
   {
     int i;
@@ -9840,9 +9852,6 @@
   func_key_syms = Qnil;
   staticpro (&func_key_syms);
 
-  mouse_syms = Qnil;
-  staticpro (&mouse_syms);
-
 #ifdef WINDOWSNT
   mouse_wheel_syms = Qnil;
   staticpro (&mouse_wheel_syms);