|
From: Ethan M. <merritt@u.washington.edu> - 2005-01-07 05:31:59
|
I suddenly realized that I have been thinking of this in the wrong way, and misinterpreting what is happening. Including "set term foo" in a key binding has nothing to do with it. The command "gnuplot < myscriptfile" resets stdin to a piped copy of the file myscriptfile. But now "pause -1" makes no sense, because it says to wait for the next input on stdin, and we know that stdin will keep on feeding characters from myscriptfile until it runs off the end. That's why it returns immediately in your original test case. OK, so we can't use "pause -1". The obvious replacement is "pause mouse key". And this almost works, but not quite. The glitch is that currently "pause mouse key" (a) only works in the active window, and (b) overrides all key bindings Both of these are fixable. So I have uploaded a new version of the patchset that changes gnuplot behaviour as follows: - "bind all <key> foo" causes that key to be terminate a "pause mouse key" even if it is typed in an inactive window - key bindings are evaluated *before* checking for "pause mouse key", so if you terminate the pause by hitting a key with a binding, the binding executes first With this revised version I think you can do everything you wanted. Here are my test files: bindall.dem: set mouse n=1; set term x11 n; plot x**n n=2; set term x11 n; plot x**n bind all Home 'n=MOUSE_KEY_WINDOW; set term x11 n; plot x**n' bind all End 'DONE = 1' bind all s 'show variable' DONE = 0 print "Hit <End> in any plot window to continue" load "wait_for_End" # print "Now I am done" wait_for_End: pause mouse key if (!DONE) print "Saw key in window ",MOUSE_KEY_WINDOW," but not yet done" if (!DONE) reread These scripts work as intended for either gnuplot < bindall.dem or gnuplot gnuplot> load 'bindall.dem' There is still something out of sync if you say gnuplot bindall.dem As before, please let me know if more, or different, functionality is ideally needed for your full application. -- Ethan A Merritt Biomolecular Structure Center University of Washington 98195-7742 |