Index: /trunk/Ohana/src/kapa/graph/cursor.c
===================================================================
--- /trunk/Ohana/src/kapa/graph/cursor.c	(revision 5348)
+++ /trunk/Ohana/src/kapa/graph/cursor.c	(revision 5349)
@@ -1,4 +1,4 @@
 # include "Ximage.h"
-# define EventMask (long) (KeyPressMask | ExposureMask | StructureNotifyMask)
+# define EventMask (long) (KeyPressMask | ExposureMask | StructureNotifyMask | ButtonPressMask)
 
 int cursor () {
@@ -8,9 +8,10 @@
   int             status, value;
   XComposeStatus  composestatus;
-  char            string[10], line[35];
+  char            string[10], line[40], *name;
   double          x, y;
   char            buffer[10];
   Layout         *layout;
-  
+  XButtonEvent   *mouse_event;
+
   layout = &section[TheSection];
 
@@ -22,23 +23,23 @@
     
     switch (status) {
-    case -1:
-      /* no input from pipe: continue */
-      break;
+      case -1:
+	/* no input from pipe: continue */
+	break;
       
-    case 0:
-      fprintf (stderr, "pipe has died!\n");
-      return (FALSE);
-      break;
+      case 0:
+	fprintf (stderr, "pipe has died!\n");
+	return (FALSE);
+	break;
 
-    case 4:
-      if (!strcmp (buffer, "NCUR")) {  /* stop reading cursor */
+      case 4:
+	if (!strcmp (buffer, "NCUR")) {  /* stop reading cursor */
+	  return (TRUE);
+	}
+	break;
+
+      default:
+	fprintf (stderr, "weird signal: too many or few bytes!  %d\n", status);
 	return (TRUE);
-      }
-      break;
-
-    default:
-      fprintf (stderr, "weird signal: too many or few bytes!  %d\n", status);
-      return (TRUE);
-      break;
+	break;
     }
 
@@ -53,34 +54,60 @@
       switch (event.type)  {
 
-      case MotionNotify:
-	break;
+	case MotionNotify:
+	  break;
 
-      case Expose:
-	if (HAVE_BACKING) {
-	  continue;
-	}
-	if (XEventsQueued (graphic.display, QueuedAlready) < 2) {
-	  Refresh (1);
-	}
-	break;
+	case Expose:
+	  if (HAVE_BACKING) {
+	    continue;
+	  }
+	  if (XEventsQueued (graphic.display, QueuedAlready) < 2) {
+	    Refresh (1);
+	  }
+	  break;
 	
-      case ConfigureNotify:
-	status = Reconfig (&event);
-	break;
+	case ConfigureNotify:
+	  status = Reconfig (&event);
+	  break;
 	
-      case MappingNotify:
-	XRefreshKeyboardMapping ((XMappingEvent *) &event);
-	break;
+	case MappingNotify:
+	  XRefreshKeyboardMapping ((XMappingEvent *) &event);
+	  break;
 	
-      case KeyPress:
-	string[0] = 0;
-	value = XLookupString ((XKeyEvent *) &event, string, 9, &keysym, &composestatus);
-	x = (event.xkey.x - layout[0].axis[0].fx)*(layout[0].axis[0].max - layout[0].axis[0].min)/layout[0].axis[0].dfx + layout[0].axis[0].min;
-	y = (event.xkey.y - layout[0].axis[1].fy)*(layout[0].axis[1].max - layout[0].axis[1].min)/layout[0].axis[1].dfy + layout[0].axis[1].min;
-	if ((value > 0) && (isdigit(string[0]) || isalpha(string[0]))) {
-	  sprintf (line, "%c %12.6f %12.6f ", string[0], x, y);
-	  write (sock, line, 32);
-	}
-	break;
+	case ButtonPress:
+	  mouse_event = (XButtonEvent *) &event;
+	  sprintf (string, "Button%d", mouse_event[0].button);
+	  x = (mouse_event[0].x - layout[0].axis[0].fx)*(layout[0].axis[0].max - layout[0].axis[0].min)/layout[0].axis[0].dfx + layout[0].axis[0].min;
+	  y = (mouse_event[0].y - layout[0].axis[1].fy)*(layout[0].axis[1].max - layout[0].axis[1].min)/layout[0].axis[1].dfy + layout[0].axis[1].min;
+	  snprintf (line, 40, "%12s %12.6f %12.6f ", string, x, y);
+	  write (sock, line, 40);
+	  break;
+
+	case KeyPress:
+	  value = XLookupString ((XKeyEvent *) &event, string, 9, &keysym, &composestatus);
+	  name = XKeysymToString (keysym);
+
+	  x = (event.xkey.x - layout[0].axis[0].fx)*(layout[0].axis[0].max - layout[0].axis[0].min)/layout[0].axis[0].dfx + layout[0].axis[0].min;
+	  y = (event.xkey.y - layout[0].axis[1].fy)*(layout[0].axis[1].max - layout[0].axis[1].min)/layout[0].axis[1].dfy + layout[0].axis[1].min;
+
+	  // skip the following keys: 
+	  if (!strcmp (name, "Shift_L")) break;
+	  if (!strcmp (name, "Shift_R")) break;
+	  if (!strcmp (name, "Control_L")) break;
+	  if (!strcmp (name, "Control_R")) break;
+	  if (!strcmp (name, "Alt_L")) break;
+	  if (!strcmp (name, "Alt_R")) break;
+	  if (!strcmp (name, "Super_L")) break;
+	  if (!strcmp (name, "Super_R")) break;
+	  if (!strcmp (name, "Caps_Lock")) break;
+	  if (!strcmp (name, "Pause")) break;
+	  if (!strcmp (name, "Break")) break;
+	  if (!strcmp (name, "Num_Lock")) break;
+	  if (!strcmp (name, "Scroll_Lock")) break;
+	  if (!strcmp (name, "Print")) break;
+	  if (!strcmp (name, "(null)")) break;
+
+	  snprintf (line, 40, "%12s %12.6f %12.6f ", name, x, y);
+	  write (sock, line, 40);
+	  break;
       }
     }
Index: /trunk/Ohana/src/kii/picture/cursor.c
===================================================================
--- /trunk/Ohana/src/kii/picture/cursor.c	(revision 5348)
+++ /trunk/Ohana/src/kii/picture/cursor.c	(revision 5349)
@@ -10,5 +10,5 @@
   int             status;
   XComposeStatus  composestatus;
-  char            string[10], line[500];
+  char            string[10], line[40], *name;
   double          x, y;
   
@@ -35,9 +35,7 @@
     if (LastEvent (display, MotionNotify,    &event)) UpdatePointer (graphic, layout, (XMotionEvent *) &event);
     if (LastEvent (display, ButtonPress,     &event)) InterpretPresses (graphic, layout, (XButtonEvent *) &event);
-
     if (LastEvent (display, KeyPress,        &event)) {
       status = XLookupString ((XKeyEvent *) &event, string, 9, &keysym, &composestatus);
 
-      if (!status) continue;
       if (event.xkey.x < layout[0].picture.x) continue;
       if (event.xkey.x > layout[0].picture.x + layout[0].picture.dx) continue;
@@ -46,11 +44,25 @@
 	
       Screen_to_Image (&x, &y, (double)event.xkey.x, (double)event.xkey.y, layout);
+      name = XKeysymToString (keysym);
 
-      if (isprint(string[0]))
-	sprintf (line, "%c %6.1f %6.1f ", string[0], x, y);
-      else {
-	sprintf (line, "X %6.1f %6.1f ", x, y);
-      }
-      write (layout[0].Ximage, line, 16);
+      // skip the following keys: 
+      if (!strcmp (name, "Shift_L")) continue;
+      if (!strcmp (name, "Shift_R")) continue;
+      if (!strcmp (name, "Control_L")) continue;
+      if (!strcmp (name, "Control_R")) continue;
+      if (!strcmp (name, "Alt_L")) continue;
+      if (!strcmp (name, "Alt_R")) continue;
+      if (!strcmp (name, "Super_L")) continue;
+      if (!strcmp (name, "Super_R")) continue;
+      if (!strcmp (name, "Caps_Lock")) continue;
+      if (!strcmp (name, "Pause")) continue;
+      if (!strcmp (name, "Continue")) continue;
+      if (!strcmp (name, "Num_Lock")) continue;
+      if (!strcmp (name, "Scroll_Lock")) continue;
+      if (!strcmp (name, "Print")) continue;
+      if (!strcmp (name, "(null)")) continue;
+
+      snprintf (line, 40, "%12s %12.6f %12.6f ", name, x, y);
+      write (layout[0].Ximage, line, 40);
     }
   }
Index: /trunk/Ohana/src/opihi/cmd.data/cursor.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/cursor.c	(revision 5348)
+++ /trunk/Ohana/src/opihi/cmd.data/cursor.c	(revision 5349)
@@ -3,5 +3,5 @@
 int cursor (int argc, char **argv) {
 
-  char buffer[40], string[20], key;
+  char buffer[40], string[20], key[20], keyname[20];
   int i, N, Nsource, Source, IsImage;
   double X, Y, R, D, Z;
@@ -49,15 +49,18 @@
   Z = -1.0;
   for (i = 0; ((i < N) || (N == 0)) && !interrupt; i++) {
-    bzero (buffer, 20);
-    read (Source, buffer, 32);
-    buffer[32] = 0;
-    sscanf (buffer, "%c %lf %lf", &key, &X, &Y);
-
-    sprintf (string, "X%1c", key);
+    bzero (buffer, 40);
+    read (Source, buffer, 40);
+    buffer[39] = 0;
+    sscanf (buffer, "%s %lf %lf", key, &X, &Y);
+    if (ispunct(key[0])) {
+      strcpy (keyname, "_");
+    } else {
+      strcpy (keyname, key);
+    }
+    sprintf (string, "X%s", keyname);
     set_variable (string, X);
-    sprintf (string, "Y%1c", key);
+    sprintf (string, "Y%s", keyname);
     set_variable (string, Y);
-    sprintf (string, "%c", key);
-    set_str_variable ("KEY", string);
+    set_str_variable ("KEY", key);
     
     if (IsImage && (buf != NULL)) 
@@ -66,7 +69,7 @@
     if (!IsImage) {
       XY_to_RD (&R, &D, X, Y, &graphmode.coords);
-      sprintf (string, "R%1c", key);
+      sprintf (string, "R%s", keyname);
       set_variable (string, R);
-      sprintf (string, "D%1c", key);
+      sprintf (string, "D%s", keyname);
       set_variable (string, D);
     }
@@ -74,10 +77,10 @@
     /* I still don't like this, but I have to decide which to print... */
     if (IsImage) {
-      fprintf (GetOutfile(), "%c %f %f  %f\n", key, X, Y, Z);
+      fprintf (GetOutfile(), "%s %f %f  %f\n", key, X, Y, Z);
     } else {
-      fprintf (GetOutfile(), "%c %f %f\n", key, X, Y);
+      fprintf (GetOutfile(), "%s %f %f\n", key, X, Y);
     }
 
-    if ((key == 'q') || (key == 'Q')) {
+    if (!strcasecmp (key, "Q")) {
       signal (SIGINT, (void *) oldsignal);
       write (Source, "NCUR", 4); /* ask Source to stop looking for the keystrokes */
