Mercurial > hg > octave-lyh
view scripts/plot/private/__gnuplot_ginput__.m @ 13141:e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
* bicg.m, gmres.m, pkg.m: Untabify and remove trailing whitespace.
* libcruft/Makefile.am, libcruft/blas-xtra/cdotc3.f,
libcruft/blas-xtra/cmatm3.f, libcruft/blas-xtra/ddot3.f,
libcruft/blas-xtra/dmatm3.f, libcruft/blas-xtra/sdot3.f,
libcruft/blas-xtra/smatm3.f, libcruft/blas-xtra/zdotc3.f,
libcruft/blas-xtra/zmatm3.f, libcruft/lapack-xtra/crsf2csf.f,
libcruft/lapack-xtra/zrsf2csf.f, liboctave/Array.cc,
liboctave/DASPK-opts.in, liboctave/DASRT-opts.in,
liboctave/DASSL-opts.in, liboctave/LSODE-opts.in,
liboctave/Makefile.a,mliboctave/Quad-opts.in,
liboctave/Sparse-perm-op-defs.h,
scripts/Makefile.a,mscripts/deprecated/glpkmex.m,
scripts/general/blkdiag.m, scripts/general/interp1.m,
scripts/general/profshow.m, scripts/general/quadl.m,
scripts/general/triplequad.m, scripts/help/__makeinfo__.m,
scripts/io/strread.m, scripts/io/textread.m, scripts/io/textscan.m,
scripts/linear-algebra/rank.m, scripts/miscellaneous/gzip.m,
scripts/miscellaneous/private/__xzip__.m,
scripts/miscellaneous/tempdir.m, scripts/miscellaneous/unpack.m,
scripts/pkg/pkg.m, scripts/plot/allchild.m, scripts/plot/ancestor.m,
scripts/plot/cla.m, scripts/plot/clf.m, scripts/plot/findall.m,
scripts/plot/findobj.m, scripts/plot/gca.m, scripts/plot/gcf.m,
scripts/plot/hggroup.m, scripts/plot/isfigure.m,
scripts/plot/ishghandle.m, scripts/plot/legend.m,
scripts/plot/line.m, scripts/plot/loglog.m, scripts/plot/patch.m,
scripts/plot/print.m, scripts/plot/private/__quiver__.m,
scripts/plot/private/__scatter__.m, scripts/plot/rectangle.m,
scripts/plot/semilogx.m, scripts/plot/semilogy.m,
scripts/plot/surface.m, scripts/plot/text.m, scripts/plot/title.m,
scripts/plot/trisurf.m, scripts/plot/view.m, scripts/plot/whitebg.m,
scripts/plot/xlabel.m, scripts/plot/xlim.m, scripts/plot/ylabel.m,
scripts/plot/ylim.m, scripts/plot/zlabel.m, scripts/plot/zlim.m,
scripts/polynomial/mkpp.m, scripts/polynomial/polygcd.m,
scripts/polynomial/ppint.m, scripts/polynomial/ppjumps.m,
scripts/polynomial/ppval.m, scripts/set/setxor.m,
scripts/sparse/bicgstab.m, scripts/sparse/cgs.m,
scripts/sparse/spconvert.m, scripts/specfun/nthroot.m,
scripts/strings/strmatch.m, scripts/strings/untabify.m,
scripts/testfun/demo.m, scripts/testfun/example.m,
src/DLD-FUNCTIONS/filter.cc, src/DLD-FUNCTIONS/mgorth.cc,
src/DLD-FUNCTIONS/quadcc.cc, src/DLD-FUNCTIONS/str2double.cc,
src/Makefile.a,msrc/gl-render.cc, src/gl2ps-renderer.cc,
src/graphics.cc, src/octave-config.cc.in, src/octave-config.in,
src/ov-class.h, src/ov-fcn.h, src/profiler.cc, src/profiler.h,
src/pt-binop.cc, src/pt-unop.cc, src/symtab.cc, src/txt-eng-ft.cc:
Remove trailing whitespace.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 15 Sep 2011 12:51:10 -0400 |
parents | 6f91ca83d2be |
children | 72c96de7a403 |
line wrap: on
line source
## Copyright (C) 2004-2011 Petr Mikulik ## ## This file is part of Octave. ## ## Octave is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## Octave is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{x}, @var{y}, @var{buttons}] =} __gnuplot_ginput__ (@var{f}, @var{n}) ## Undocumented internal function. ## @end deftypefn ## This is ginput.m implementation for gnuplot and X11. ## It requires gnuplot 4.1 and later. ## This file initially bore the copyright statement ## Petr Mikulik ## History: June 2006; August 2005; June 2004; April 2004 ## License: public domain function [x, y, button] = __gnuplot_ginput__ (f, n) ostream = get (f, "__plot_stream__"); if (numel (ostream) < 1) error ("ginput: stream to gnuplot not open"); elseif (ispc ()) if (numel (ostream) == 1) error ("ginput: Need mkfifo that is not implemented under Windows"); endif use_mkfifo = false; istream = ostream(2); ostream = ostream(1); else use_mkfifo = true; ostream = ostream(1); endif if (compare_versions (__gnuplot_version__ (), "4.0", "<=")) error ("ginput: version %s of gnuplot not supported", gnuplot_version ()); endif if (nargin == 1) x = zeros (100, 1); y = zeros (100, 1); button = zeros (100, 1); else x = zeros (n, 1); y = zeros (n, 1); button = zeros (n, 1); endif if (use_mkfifo) gpin_name = tmpnam (); ##Mode: 6*8*8 == 0600 [err, msg] = mkfifo (gpin_name, 6*8*8); if (err != 0) error ("ginput: Can not open fifo (%s)", msg); endif endif unwind_protect k = 0; while (true) k++; ## Notes: MOUSE_* can be undefined if user closes gnuplot by "q" ## or Alt-F4. Further, this abrupt close also requires the leading ## "\n" on the next line. if (use_mkfifo) fprintf (ostream, "set print \"%s\";\n", gpin_name); fflush (ostream); [gpin, err] = fopen (gpin_name, "r"); if (err != 0) error ("ginput: Can not open fifo (%s)", msg); endif fputs (ostream, "pause mouse any;\n\n"); fputs (ostream, "\nif (exists(\"MOUSE_KEY\") && exists(\"MOUSE_X\")) print MOUSE_X, MOUSE_Y, MOUSE_KEY; else print \"0 0 -1\"\n"); ## Close output file, to force it to be flushed fputs (ostream, "set print;\n"); fflush (ostream); ## Now read from fifo. [x(k), y(k), button(k), count] = fscanf (gpin, "%f %f %d", "C"); fclose (gpin); else fprintf (ostream, "set print \"-\";\n"); fflush (ostream); fputs (ostream, "pause mouse any;\n\n"); fputs (ostream, "\nif (exists(\"MOUSE_KEY\") && exists(\"MOUSE_X\")) print \"OCTAVE: \", MOUSE_X, MOUSE_Y, MOUSE_KEY; else print \"0 0 -1\"\n"); ## Close output file, to force it to be flushed fputs (ostream, "set print;\n"); fflush (ostream); str = {}; while (isempty (str)) str = char (fread (istream)'); if (isempty (str)) sleep (0.05); else str = regexp (str, 'OCTAVE:\s+[-+.\d]+\s+[-+.\d]+\s+\d*', 'match'); endif fclear (istream); endwhile [x(k), y(k), button(k), count] = sscanf (str{end}(8:end), "%f %f %d", "C"); endif if ([x(k), y(k), button(k)] == [0, 0, -1]) ## Mousing not active (no plot yet). break; endif if (nargin > 1) ## Input argument n was given => stop when k == n. if (k == n) break; endif else ## Input argument n not given => stop when hitting a return key. ## if (button(k) == 0x0D || button(k) == 0x0A) ## ## hit Return or Enter if (button(k) == 0x0D) ## hit Return x(k:end) = []; y(k:end) = []; button(k:end) = []; break; endif endif endwhile unwind_protect_cleanup if (use_mkfifo) unlink (gpin_name); endif end_unwind_protect endfunction