|
From: James R. V. Z. <jr...@co...> - 2009-08-01 03:22:34
|
I would like to propose the patch below, which makes three changes to
the way mouse-mode (the display in the lower left corner of the mouse
cursor location) and clipboard-mode (what is written to the clipboard
on a double click) are handled:
- Mode 2 (MOUSE_COORDINATES_FRACTIONAL) works even with logscale.
- In mode 2, the coordinates are displayed in this format:
graph 0.692328, 1.01163
I.e. including the word "graph". This is the same format used to
position labels or arrows, so it helps the user know what
mouse-mode he has. Also, with clipboard-mode 1 or 2, the user can
paste directly into a gnuplot script without having to remember the
"graph". (I can't think of any applications for pasting fractional
coordinates other than into a gnuplot script.)
- Shortcut keys 1 and 2, that currently change mouse-mode, now also
change clipboard-mode to match. This makes the interface slightly
less obscure. (If you want different formats, you can still use
keys 3 and 4 to change clipboard-mode only.)
The last point might be controversial, which is why I'm posting a
patch instead of just committing the changes.
Actually I don't understand why we have separate mouse- and clipboard-
modes. It seems unnecessarily complicated to me. (I would really
like to deprecate shortcut keys 3 and 4, and eventually eliminate
clipboard-mode as a separate concept.) When is it convenient to have
the two formats be different?
By the way, the first two modes are documented this way:
0 real coordinates in brackets e.g. [1.23, 2.45]
1 real coordinates w/o brackets e.g. 1.23, 2.45
The square brackets got dropped somewhere along the line, so at
present, mode 0 is the same as mode 1. Actually I never saw the
application for the square brackets. But two modes for the same thing
doesn't make sense either. How about just omitting the comma in mode
0:
0 real coordinates separated by spaces e.g. 1.23 2.45
1 real coordinates separated by a comma e.g. 1.23, 2.45
- Jim Van Zandt
Index: src/mouse.c
===================================================================
RCS file: /cvsroot/gnuplot/gnuplot/src/mouse.c,v
retrieving revision 1.121
diff -u -r1.121 mouse.c
--- src/mouse.c 24 Jul 2009 01:35:55 -0000 1.121
+++ src/mouse.c 1 Aug 2009 02:30:54 -0000
@@ -400,25 +400,24 @@
strcat(format, "]");
sprintf(s, format, xDateTimeFormat(x, buf, mode), y);
} else if (mode == MOUSE_COORDINATES_FRACTIONAL) {
- double xrange = axis_array[FIRST_X_AXIS].max - axis_array[FIRST_X_AXIS].min;
- double yrange = axis_array[FIRST_Y_AXIS].max - axis_array[FIRST_Y_AXIS].min;
+ double xrange = axis_array[FIRST_X_AXIS].term_upper - axis_array[FIRST_X_AXIS].term_lower;
+ double yrange = axis_array[FIRST_Y_AXIS].term_upper - axis_array[FIRST_Y_AXIS].term_lower;
/* calculate fractional coordinates.
* prevent division by zero */
if (xrange) {
- char format[0xff] = "/";
+ char format[0xff] = "graph ";
strcat(format, mouse_setting.fmt);
- sprintf(s, format, (x - axis_array[FIRST_X_AXIS].min) / xrange);
+ sprintf(s, format, (mouse_x - axis_array[FIRST_X_AXIS].term_lower) / xrange);
} else {
- sprintf(s, "/(undefined)");
+ sprintf(s, "(undefined)");
}
s += strlen(s);
if (yrange) {
char format[0xff] = ", ";
strcat(format, mouse_setting.fmt);
- strcat(format, "/");
- sprintf(s, format, (y - axis_array[FIRST_Y_AXIS].min) / yrange);
+ sprintf(s, format, (mouse_y - axis_array[FIRST_Y_AXIS].term_lower) / yrange);
} else {
- sprintf(s, ", (undefined)/");
+ sprintf(s, ", (undefined)");
}
} else if (mode == MOUSE_COORDINATES_REAL1) {
sprintf(s, xy_format(), x, y); /* w/o brackets */
@@ -739,6 +738,7 @@
incr_mousemode(const int amount)
{
long int old = mouse_mode;
+ long int old_clip = clipboard_mode;
mouse_mode += amount;
if (MOUSE_COORDINATES_ALT == mouse_mode && !mouse_alt_string) {
mouse_mode += amount; /* stepping over */
@@ -752,8 +752,10 @@
}
}
UpdateStatusline();
+ clipboard_mode = mouse_mode;
if (display_ipc_commands()) {
fprintf(stderr, "switched mouse format from %ld to %ld\n", old, mouse_mode);
+ fprintf(stderr, "switched clipboard format from %ld to %ld\n", old_clip, clipboard_mode);
}
}
|