From: Ethan M. <merritt@u.washington.edu> - 2004-01-07 17:56:30
|
On Wednesday 07 January 2004 01:07, arn...@we... wrote: > > Yes this is really nasty (sorry for bringing it up again ;-) - > anyway, I am just wondering if there is any chance at all that > this can be made to work in a reliable way? I do not think it is possible so long as the terminal and X11 input streams are intermingled. > Are there any reasonable alternatives? Yes, but it would be a major, major change to the existing layout. So it won't happen any time soon. > Alright, then I tried to re-compile with > ./configure --disable-mouse > Here the compile ended with > > In file included from term.h:267, > from term.c:1043: > ../term/x11.trm:304: error: `X11_MOUSE_FEEDBACK' undeclared (first use > in this function) I'll fix that immediately. > So all this feedback and mousing stuff seems problematic > when sending commands to gnuplot via a pipe... This is a known problem, but none of us fully understand it. It seems to depend on the environment from which the pipe is opened. For me, it works from C and from octave but fails from awk. It seems to work from perl also, but my perl scripts are not normally being run interactively so I'm not sure I would have seen the failure in practice. In the case of awk scripts, the problem can be ameliorated by commenting out the call to setvbuf() in x11.trm as in the=20 following patch: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --- gnuplot/term/x11.trm 2003-09-30 13:14:43.000000000 -0700 +++ gnuplot-cvs/term/x11.trm 2003-10-20 17:26:10.000000000 -0700 @@ -599,12 +607,14 @@ ipc_back_fd =3D fdes_back[0]; close(fdes_back[1]); /* the parent doesn't need this *= / =20 +#ifdef BROKEN /* EAM Oct 2003 - This has broken awk+gnuplot */ /* apparently multi-character inputs like escape sequences * but also mouse-pasted text got buffered and therefore * didn't trigger the select() function in X11_waitforinput()= =2E * Switching to unbuffered input solved this (although I don'= t * really like this solution 23 Jan 2002 (joze) */ setvbuf(stdin, (char *) 0, _IONBF, 0); +#endif=20 } else { /* we do not open a bidirectional communication * for non-tty's by default. If this is desired, %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% You may find that the same is true for your python environment. I say "ameliorated" rather than "fixed" because if you apply this patch then other peculiarities result - the main one being that "pause -1" behaves unreliably.=20 > 2.) I'd really love to have mousing working, even when gnuplot > is steered via a pipe. > Example: > - do a plot (in my case from python) > - send a "pause mouse" command > - read MOUSE_X and MOUSE_Y back to the calling program For that you need the full-blown feedback loop, not just --enable-mouse I did get this working nicely from C code, so the basic idea is sound. The problem comes from some difference in the scripting environment. I wish I knew exactly what. > See http://www.physik.tu-dresden.de/~baecker/python/plot.html > for a brief example on how to get variables from gnuplot > back to python. You may find that removing the call to setvbuf() makes your python example work. Please let us know. --=20 Ethan A Merritt merritt@u.washington.edu Biomolecular Structure Center Box 357742 University of Washington, Seattle, WA 98195 |