Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
I would like to know if a window has been closed (X11 term)
In fact, even with the set mouse verbose nothing is displayed on the console once the window has been closed
Would it be possible to have this notificated?
Logged In: YES
Please give an example of when/how this would be useful. Closing an x11 window is normally not a fatal, nor even a particularly interesting event. If you issue another plot or replot command, the window will simply re-open and things will continue as normal.
Logged In: YES
In fact it's quite tricky...
I have a code that generates a text file that I need to plot in real time (let's say every 10 seconds).
To do this I have a script using a pipe to send the "replot" command every 10 seconds.
Now the point is that the scripts is part of a GUI that needs to know when the user press some button (one of the reason might for exemple to make a zoom, change the variables to plot or simply to close the pipe).
For normal keys and mouse events is simple since I can grab the keypressed via a the gnuplot stdout and/or the stderr (using the "bind" and/or the "mouse verbose"), but if the user closes the window via the windowmanager, the GUI has no feedback of that event and after 10 seconds does a "replot" that reopen the X11 window.
I know is't quite strange and is difficoult to make a simple script reproducing all this (and moreover I use tcl/tk to manage the gui.... wery old!)
I hope is more clear my problem :-)
There are several difficulties here. One instance of gnuplot_x11 can manage multiple x11 windows. Only one of these (at most) can be the "current" window for plotting new commands from gnuplot. The others are managed by gnuplot_x11 itself. If you close one of these old windows, it seems useless to notify gnuplot of that fact. But it could be done, if you can think of something useful to do with the information on the gnuplot side.
If the "current" window is closed, gnuplot does get notified. It is called via the routine event_reset() in mouse.c, which terminates any zooming or other mouse interactions in progress. It could easily enough write out a warning message to stderr: "Somebody closed the plot window!". But I'm not sure how that would help your scripted environment any.
What exactly would you like to have gnuplot do if it sees that the active window has been closed?
Set a flag?
Print a message?
'bind' a command to the close event, similar to binding a command to a hotkey?
Issue a replot command by itself, to re-open the window?
"bind Close_Event 'some-gnuplot-command'"
Please try the attached patch. It allows you to use the "bind" command to bind an action to an XK_Cancel event, which normally means the window has closed. The syntax is
bind Close_Event "some-gnuplot-command-string"
Tested only on X11, and only lightly. It probably needs additional code in order to support other interactive terminal types. If this doesn't quite do what you need, please suggest modifications.
File Added: winclose_14may2007.patch
I'm really impressed!
the patch works perfectly!
regarding your previous question, I don't really need all this (thanks however for providing the binding)
it would be sufficent something that print "window closed"
and maybe since thaere maight be more than 1 x11 plot, printing something like "term x11 window 1 closed"
I really need a basic thing like the message for the ruler (with "set mouse verbose"): pressing on the plot the "r" key, gives alternatively
turning ruler on.
turning ruler off.
Thanks a lot!!
I have another request:
looking in the plot3d.c, I saw this other feature that might be the case to activate (I hope to explan this better than the previous):
when plotting in dgrid mode, alle the surface between the xmin and xmax and ymin and ymax of all plotted points is "dgridded" , in the source code there is thi comment of HBB:
/* Compute XY bounding box on the original data. */
/* FIXME HBB 20010424: Does this make any sense? Shouldn't we just
* use whatever the x and y ranges have been found to be, and
* that's that? The largest difference this is going to make is if
* we plot a datafile that doesn't span the whole x/y range
* used. Do we want a dgrid3d over the actual data rectangle, or
* over the xrange/yrange area? */
For me it's better this approach so I've added a couple of lines after this:
if (axis_array[FIRST_X_AXIS].min > xmin) xmin=axis_array[FIRST_X_AXIS].min;
if (axis_array[FIRST_X_AXIS].max < xmax) xmax=axis_array[FIRST_X_AXIS].max;
if (axis_array[FIRST_Y_AXIS].min > ymin) ymin=axis_array[FIRST_Y_AXIS].min;
if (axis_array[FIRST_Y_AXIS].max < ymax) ymax=axis_array[FIRST_Y_AXIS].max;
to Dgrid only the visible region .
Would it be possible in future to choose if dgrid extends (as it is now) to the maximum size or just to the zoomed region, maybe adding an option to the "set dgrid 30,30 zoomed" or "set dgrid 30,30 boundingbox" or whatever!
version 2; handle wxt terminal as well
File Added: winclose_16may2007.patch
Implemented for windows, wxt, and x11
bind Close "<some set of gnuplot commands>"